[MacRuby] #336: NoMethodError with shoulda tests
#336: NoMethodError with shoulda tests ----------------------------------------+----------------------------------- Reporter: macruby@… | Owner: lsansonetti@… Type: defect | Status: new Priority: major | Milestone: MacRuby 0.5 Component: MacRuby | Keywords: shoulda ----------------------------------------+----------------------------------- When running shoulda tests a NoMethodError is raised, not quite sure how/why as it looks like the test passes. -- Ticket URL: <http://www.macruby.org/trac/ticket/336> MacRuby <http://macruby.org/>
#336: NoMethodError with shoulda tests ----------------------------------------+----------------------------------- Reporter: macruby@… | Owner: lsansonetti@… Type: defect | Status: new Priority: major | Milestone: MacRuby 0.5 Component: MacRuby | Keywords: shoulda ----------------------------------------+----------------------------------- Comment(by macruby@…): Apologies for the extremely bad formatting, here is a slightly better formatted version {{{ #!ruby require 'test/unit' require 'rubygems' require 'shoulda' require 'shoulda/test_unit' framework 'Foundation' class MacRubyShouldaTest < Test::Unit::TestCase context "NSString instance" do setup do @string = NSString.stringWithString("~/Documents") end should "expand tilde in path" do assert @string.stringByExpandingTildeInPath.isEqualToString("#{ENV['HOME']}/Documents") end end end }}} with the output of {{{ Started E. Finished in 0.096728 seconds. 1) Error: test: NSString instance should expand tilde in path.(MacRubyShouldaTest): NoMethodError: undefined method `test: NSString instance should expand tilde in path.' for #<MacRubyShouldaTest:0x2004db7c0> 0:in `send:' 0:in `run:' 0:in `each' 0:in `each' 0:in `run_test_suites:' 0:in `run:' 2 tests, 1 assertions, 0 failures, 1 errors, 0 skips }}} -- Ticket URL: <http://www.macruby.org/trac/ticket/336#comment:1> MacRuby <http://macruby.org/>
#336: NoMethodError with shoulda tests ----------------------------------------+----------------------------------- Reporter: macruby@… | Owner: lsansonetti@… Type: defect | Status: new Priority: major | Milestone: MacRuby 0.5 Component: MacRuby | Keywords: shoulda ----------------------------------------+----------------------------------- Comment(by eloy.de.enige@…): Thanks for the report! In the meantime you could give Bacon a try if you want. It's a sweet lean test framework and all of it's tests run on MacRuby 0.5. However, until a new version is released you will have to grab the HEAD version from: http://github.com/chneukirchen/bacon -- Ticket URL: <http://www.macruby.org/trac/ticket/336#comment:2> MacRuby <http://macruby.org/>
#336: NoMethodError with shoulda tests ----------------------------------------+----------------------------------- Reporter: macruby@… | Owner: lsansonetti@… Type: defect | Status: new Priority: major | Milestone: MacRuby 0.5 Component: MacRuby | Keywords: shoulda ----------------------------------------+----------------------------------- Comment(by macruby@…): Thanks, not sure what I've done now but I can't seem to get macruby or macirb to load any gems at all. Can't work out why as it was working this morning. -- Ticket URL: <http://www.macruby.org/trac/ticket/336#comment:3> MacRuby <http://macruby.org/>
#336: NoMethodError with shoulda tests ----------------------------------------+----------------------------------- Reporter: macruby@… | Owner: lsansonetti@… Type: defect | Status: new Priority: major | Milestone: MacRuby 0.5 Component: MacRuby | Keywords: shoulda ----------------------------------------+----------------------------------- Comment(by macruby@…): Replying to [comment:3 macruby@…]:
Thanks, not sure what I've done now but I can't seem to get macruby or macirb to load any gems at all. Can't work out why as it was working this morning. Noticed that `rip` was in my $LOAD_PATH so I've installed Bacon with that, working much more smoothly now.
-- Ticket URL: <http://www.macruby.org/trac/ticket/336#comment:4> MacRuby <http://macruby.org/>
#336: NoMethodError with shoulda tests ----------------------------------------+----------------------------------- Reporter: macruby@… | Owner: lsansonetti@… Type: defect | Status: new Priority: major | Milestone: MacRuby 0.5 Component: MacRuby | Keywords: shoulda ----------------------------------------+----------------------------------- Comment(by eloy.de.enige@…): Great tip, thanks! -- Ticket URL: <http://www.macruby.org/trac/ticket/336#comment:5> MacRuby <http://macruby.org/>
#336: NoMethodError with shoulda tests ----------------------------------------+----------------------------------- Reporter: macruby@… | Owner: lsansonetti@… Type: defect | Status: new Priority: major | Milestone: Component: MacRuby | Keywords: shoulda ----------------------------------------+----------------------------------- Changes (by lsansonetti@…): * milestone: MacRuby 0.5 => Comment: We need a reduction for that problem. -- Ticket URL: <http://www.macruby.org/trac/ticket/336#comment:6> MacRuby <http://macruby.org/>
#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/>
participants (1)
-
MacRuby