Ruby 1.9 - helper methods aren't recognized when example group is nested in a module
Reported by David Chelimsky | December 29th, 2007 @ 05:18 AM
This example can be found in rspec/examples/pure/helper_method_example.rb in trunk (r3205):
module HelperMethodExample
describe "an example group with helper a method" do
def helper_method
"received call"
end
it "should make that method available to specs" do
helper_method.should == "received call"
end
end
end
Running against 1.8.6 produces:
.
Finished in 0.005994 seconds
1 example, 0 failures
Running against Ruby 1.9 produces:
F
1)
NameError in 'an example group with helper a method should make that method available to specs'
undefined local variable or method `helper_method' for #<Spec::Example::ExampleGroup::Subclass_1:0x3cc33c>
examples/pure/helper_method_example.rb:10:in `block (2 levels) in <module:HelperMethodExample>'
Finished in 0.012416 seconds
1 example, 1 failure
Comments and changes to this ticket
-
David Chelimsky December 29th, 2007 @ 05:19 AM
- → State changed from new to open
NOTE: This is only a problem when the example group is nested in a module.
-
Cheah Chu Yeow December 30th, 2007 @ 08:02 AM
This is due to a known bug with module_eval in 1.9: http://www.ruby-forum.com/topic/...
I just tried it on the latest 1.9 trunk (r14793) and it hasn't been fixed yet. May be worth putting in a shim for 1.9 (if it's at all possible to shim) while this bug is being worked on - I'll take a shot at it later today.
-
Cheah Chu Yeow December 30th, 2007 @ 03:24 PM
Unfortunately I am not clever enough to come up with a workaround (if it's at all possible to workaround the bug). I guess we have to wait for it to be fixed in Ruby's trunk.
-
Cheah Chu Yeow June 7th, 2008 @ 10:28 AM
This bug has been fixed in a recent Ruby 1.9 trunk. Probably closes this bug (I haven't tested, just thought you'd like to know).
Please Login or create a free account to add a new comment.
You can update this ticket by sending an email to from your email client. (help)
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
Behaviour Driven Development for Ruby.
