Skip to content

Instantly share code, notes, and snippets.

@rafaelss
Created May 14, 2010 15:09
Show Gist options
  • Save rafaelss/401267 to your computer and use it in GitHub Desktop.
Save rafaelss/401267 to your computer and use it in GitHub Desktop.
# using implicit subject may throw the following error on ruby 1.9.2
# wrong number of arguments (1 for 0)
# /Users/rafael/.rvm/gems/ruby-1.9.2-head/gems/rspec-1.3.0/lib/spec/example/subject.rb:43:in `block in implicit_subject'
# /Users/rafael/.rvm/gems/ruby-1.9.2-head/gems/rspec-1.3.0/lib/spec/example/subject.rb:77:in `instance_eval'
# /Users/rafael/.rvm/gems/ruby-1.9.2-head/gems/rspec-1.3.0/lib/spec/example/subject.rb:77:in `subject'
# /Users/rafael/.rvm/gems/ruby-1.9.2-head/gems/rspec-1.3.0/lib/spec/example/subject.rb:25:in `block (2 levels) in its'
# /Users/rafael/.rvm/gems/ruby-1.9.2-head/gems/rspec-1.3.0/lib/spec/example/subject.rb:91:in `should'
# spec/models/category_spec.rb:17:in `block (3 levels) in <top (required)>'
# seems instance_eval call on line 77 send an argument to lambda returned by implicit_subject, and on ruby 1.9 if you send arguments to a lambda, you need to declare them, the same doesnt happens with proc/Proc.new
# this patch solve this
module Spec
module Example
module Subject
module ExampleGroupMethods
def implicit_subject
# http://github.com/dchelimsky/rspec/blob/master/lib/spec/example/subject.rb#L43
(described_class ? proc {described_class.new} : proc {description_args.first})
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment