#336: NoMethodError with shoulda tests ----------------------------------------+----------------------------------- Reporter: macruby@… | Owner: lsansonetti@… Type: defect | Status: new Priority: major | Milestone: Component: MacRuby | Keywords: shoulda ----------------------------------------+----------------------------------- Comment(by mike@…): I've been trying to create a reduction, but haven't been successful yet. I have gotten closer to the problem though. In shoulda/context.rb in create_test_from_should_hash (line 337) shoulda binds the new method names to the test class. In MacRuby, something goes wrong here. We end up with two new methods bound instead of one and they have slightly different names. In Ruby 1.9, we just get the bound method. So, if you use the tc_foo.rb example and set a break point in Ruby 1.9, after the define_method: {{{
ruby -rdebug tc_foo.rb Debug.rb Emacs support available.
tc_foo.rb:1:require 'rubygems' (rdb:1) break /Users/mtaylor/.gem/ruby/1.8/gems/thoughtbot- shoulda-2.10.2/lib/shoulda/context.rb:345 Set breakpoint 1 at /Users/mtaylor/.gem/ruby/1.8/gems/thoughtbot- shoulda-2.10.2/lib/shoulda/context.rb:345 (rdb:1) c Breakpoint 1, create_test_from_should_hash at /Users/mtaylor/.gem/ruby/1.8/gems/thoughtbot- shoulda-2.10.2/lib/shoulda/context.rb:345 /Users/mtaylor/.gem/ruby/1.8/gems/thoughtbot- shoulda-2.10.2/lib/shoulda/context.rb:345: test_unit_class.send(:define_method, test_name) do (rdb:1) n /Users/mtaylor/.gem/ruby/1.8/gems/thoughtbot- shoulda-2.10.2/lib/shoulda/context.rb:392: subcontexts.each { |context| context.build } (rdb:1) test_unit_class.instance_methods }}} If you then print {{{test_unit_class.instance_methods}}} you can see that the list includes {{{"test: My factorial method should return 1 when passed 0. "}}} Now, I couldn't figure out how to get macrubyd to break in context.rb, so I injected some puts statements. After the call to define_method we end up with two entries in {{{test_unit_class.instance_methods}}} {{{ "test: My factorial method should return 1 when passed 0. :" "test: My factorial method should return 1 when passed 0." }}} The last method should match the one MacRuby is looking for in the error message: {{{ test: My factorial method should return 1 when passed 0.(TC_Test): NoMethodError: undefined method `test: My factorial method should return 1 when passed 0.' for #<TC_Test:0x2002772e0> }}} I will keep trying to find a reduction when I have time, but it may be a few days before I can get back to it. -- Ticket URL: <http://www.macruby.org/trac/ticket/336#comment:7> MacRuby <http://macruby.org/>