Skip to content

Make proc_to_ast dependency optional #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions lib/rspec/parameterized/core.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
require "rspec/parameterized/core/version"
require 'parser'
require 'unparser'
require 'proc_to_ast'
require 'rspec/parameterized/core/helper_methods'
require 'rspec/parameterized/core/example_helper_methods'

begin
require 'proc_to_ast'
rescue LoadError
end

module RSpec
module Parameterized
module Core
Expand Down Expand Up @@ -144,7 +148,7 @@ def define_cases(parameter, *args, &block)

def params_inspect(obj)
begin
obj.is_a?(Proc) ? obj.to_raw_source : obj.inspect
obj.is_a?(Proc) && obj.respond_to?(:to_raw_source) ? obj.to_raw_source : obj.inspect
rescue Parser::SyntaxError
return obj.inspect
end
Expand Down
2 changes: 2 additions & 0 deletions lib/rspec/parameterized/core/lazy_arg.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ def apply(obj)
end

def inspect
return super.inspect unless @block.respond_to?(:to_raw_source)

"#{@block.to_raw_source}"
rescue Parser::SyntaxError
super.inspect
Expand Down
2 changes: 1 addition & 1 deletion rspec-parameterized-core.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ I was inspired by [udzura's mock](https://gist.github.com/1881139).}
spec.require_paths = ["lib"]

spec.add_dependency "parser"
spec.add_dependency "proc_to_ast", ">= 0.2.0"
spec.add_dependency "rspec", ">= 2.13", "< 4"
spec.add_dependency "unparser"

spec.add_development_dependency "proc_to_ast", ">= 0.2.0"
spec.add_development_dependency "rake", ">= 12.0.0"

# For more information and examples about making a new gem, check out our
Expand Down
2 changes: 1 addition & 1 deletion spec/rspec/parameterized/core_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@
end
end

context "when the where block is between with_thems" do
context "when the where block is between with_them" do
with_them do
it "should do additions" do
expect(a + b).to eq answer
Expand Down
Loading