This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 176295 - "run again" option on failed tests does nothing
Summary: "run again" option on failed tests does nothing
Status: RESOLVED FIXED
Alias: None
Product: ruby
Classification: Unclassified
Component: Testing (show other bugs)
Version: 6.x
Hardware: PC All
: P3 normal (vote)
Assignee: Erno Mononen
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-11-09 14:51 UTC by benfyvie
Modified: 2010-04-28 14:51 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
detailed log that was requested (41.62 KB, text/plain)
2009-11-10 10:10 UTC, benfyvie
Details
detailed log generated after replacing requested file (40.69 KB, text/plain)
2009-11-11 14:33 UTC, benfyvie
Details

Note You need to log in before you can comment on or make changes to this bug.
Description benfyvie 2009-11-09 14:51:24 UTC
In a Ruby on Rails project using Rspec right-clicking a failed Rspec test gives the option to "Run Again" but choosing that option does nothing. This occurs both at the test level and the describe level. No matter what I try I must run all tests over again.
Comment 1 Erno Mononen 2009-11-10 02:32:45 UTC
Thanks for the report. I can reproduce the problem when using JRuby, can you please confirm whether you also experience this with JRuby only? I'll commit a fix for this soon.
Comment 2 Erno Mononen 2009-11-10 05:08:53 UTC
Fixed for the JRuby case in d7696fcb37f3. Please reopen if you ran into this problem when not using JRuby - thanks.
Comment 3 benfyvie 2009-11-10 08:34:31 UTC
None of my project use JRuby, rather my projects use Ruby 1.8.6-p111
Comment 4 Erno Mononen 2009-11-10 08:42:55 UTC
OK, thanks for the info - must be a different issue then. Which RSpec version do you use? Also, can you please turn on detailed logging  (http://wiki.netbeans.org/FaqRubyNBLogging67), reproduce the problem and attach the log file here then.
Comment 5 benfyvie 2009-11-10 08:53:33 UTC
We have rspec-1.2.9 and rspec-rails-1.2.7.1 both installed as frozen gems in our Rails app. It may be important to note that we use the rspec gem(s) and not plugin(s), as that may make a difference with how NetBeans handles things (I dunno). 

I will try to get back to you within the hour with the detailed log you requested.
Comment 6 benfyvie 2009-11-10 10:10:45 UTC
Created attachment 90731 [details]
detailed log that was requested

A couple of things to note:

1. I could not find the log file anywhere in my NB install directory or any subfolders so I ended up copying the contents from Menu | View | IDE Log File

2. When I click on "Run Again" nothing seems to be appended to the log. I tried clicking it multiple times, but every time I checked the log there had been nothing added to it.
Comment 7 benfyvie 2009-11-10 10:13:09 UTC
A couple of things to note:

1. I could not find the log anywhere in my NB install directory or any subfolders so I ended up copying the contents of Menu | View | IDE Log File

2. It seems that nothing is appended to the log when I click "Run Again" I tried clicking it multiple times and there was never anything added to the end of the log.
Comment 8 Erno Mononen 2009-11-11 01:28:54 UTC
Thanks for the log. Looks like I'll need to add some more logging, but I'll first try whether I can reproduce this with the same configuration that you have.
Comment 9 Erno Mononen 2009-11-11 02:05:45 UTC
After looking at the log in more details, I spotted one thing that might have been causing this. There was a change in RSpec 1.2.6 (or so) that changed the return value of RSpec's Example#location causing some issues with the IDE's test runner. This was fixed just recently, so can you please try the latest dev build (http://wiki.netbeans.org/RubyInstallation#section-RubyInstallation-GettingADevelopmentBuild) and see if the problem still exist? Or alternatively you can just download http://hg.netbeans.org/main-silver/raw-file/394f868d1494/ruby.testrunner/release/nb_rspec_mediator.rb and place it to "C:\Program Files\NetBeans 6.7\ruby2" (overwrite the existing file).
Comment 10 benfyvie 2009-11-11 08:54:25 UTC
I replaced the specified file, restarted the IDE and the problem persists.
Comment 11 Erno Mononen 2009-11-11 09:21:01 UTC
Hmm, not sure then where the problem lies. I wasn't able to reproduce this with a similar conf, but I haven't had a chance to test this on Windows (might be the key here). Can you please attach a new log file (after running a test with the updated nb_rspec_mediator)?
Comment 12 benfyvie 2009-11-11 14:33:04 UTC
Created attachment 90847 [details]
detailed log generated after replacing requested file

Here is the log you requested. I went through the same steps as before, but this time with the new nb_rspec_mediator.rb file in place
Comment 13 Erno Mononen 2009-11-12 05:28:09 UTC
Thanks - I should be able to fix this now based on the new log.
Comment 14 Erno Mononen 2009-11-12 05:52:59 UTC
Should be fixed now in ef2c8a49a21d. It seems that for whatever reason RSpec doesn't output example locations on Windows. For failed tests I can however use the location from the backtrace (that's what the fix accomplishes), so re-running failed tests should work now. For passed tests this isn't unfortunately fixable until the location issue is fixed in RSpec.
Comment 15 benfyvie 2009-11-30 11:37:41 UTC
I tried to verify that this issue is fixed by installing NB 6.8 RC1

Now when I right click on a failed test and choose "Run Again" it does attempt to do something instead of doing nothing which was the behavior in 6.7, however it blows up prior to running the test again. I receive the following error in the test results output window:


D:/svn_projects/trunk/vendor/gems/rspec-1.2.9/lib/spec/runner/line_number_query.rb:67:in `expand_path': can't convert nil into String (TypeError)

        from D:/svn_projects/trunk/vendor/gems/rspec-1.2.9/lib/spec/runner/line_number_query.rb:67:in `is_best_match?'
Finished in  seconds
        from D:/svn_projects/trunk/vendor/gems/rspec-1.2.9/lib/spec/runner/line_number_query.rb:49:in `consider_example_group_for_best_match'

0 examples, 0 failures
        from D:/svn_projects/trunk/vendor/gems/rspec-1.2.9/lib/spec/runner/options.rb:126:in `run_examples'
        from D:/svn_projects/trunk/vendor/gems/rspec-1.2.9/lib/spec/runner/command_line.rb:9:in `run'
        from D:/svn_projects/trunk/script/spec:10
Comment 16 Erno Mononen 2009-12-08 04:34:17 UTC
Thanks for following up on this, I'll take a look why it's still not working for you.
Comment 17 ayqazi 2010-04-27 16:29:49 UTC
I can confirm that this bug exists on Ruby 1.8, Rails 2.3.5, NetBeans 6.8, rspec 1.3.0 and rspec-rails 1.3.2.  It is actually due to running tests on a particular line with the '-l' or '--line' argument to ./script/spec .

I manually invoke the test runner in my Rails app:

./script/spec spec/controllers/bookings_controller_spec.rb -l 159 --runner NbRspecMediator --require /home/asfandq/apps/netbeans-6.8/ruby2/nb_rspec_mediator.rb --options /home/asfandq/src/ygt-sales/spec/spec.opts


The following output is produced:

/usr/local/lib/ruby/gems/1.8/gems/rspec-1.3.0/lib/spec/runner/line_number_query.rb:67:in `expand_path': can't convert nil into String (TypeError)
        from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.3.0/lib/spec/runner/line_number_query.rb:67:in `is_best_match?'
        from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.3.0/lib/spec/runner/line_number_query.rb:49:in `consider_example_group_for_best_match'
        from /home/asfandq/apps/netbeans-6.8/ruby2/nb_rspec_mediator.rb:233:in `spec_name_for'
        from /home/asfandq/apps/netbeans-6.8/ruby2/nb_rspec_mediator.rb:231:in `each'
        from /home/asfandq/apps/netbeans-6.8/ruby2/nb_rspec_mediator.rb:231:in `spec_name_for'
        from /home/asfandq/apps/netbeans-6.8/ruby2/nb_rspec_mediator.rb:70:in `run'
        from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.3.0/lib/spec/runner/options.rb:152:in `run_examples'
        from /usr/local/lib/ruby/gems/1.8/gems/rspec-1.3.0/lib/spec/runner/command_line.rb:9:in `run'
        from ./script/spec:10


Looking at nb_rspec_mediator.rb, on line 233, it is calling 'consider_example_group_for_best_match' with an example_group whose location is 'nil'.  That 'nil' is what expand_path is attempting to be called on.

I hacked nb_rspec_mediator.rb a bit, inserting the following just before the fatal call to 'consider_example_group_for_best_match', hoping it would tell me what the kind of example_group is that does not seem to be compatible the NetBeans mediator:

        if example_group.location.nil?
          p example_group
        end

and the class it gave me was 'Spec::Rails::Example::IntegrationExampleGroup'

Obviously, the NetBeans mediator does not like custom example groups.. PLEASE fix this, I have tried but cannot for the life of me figure out how to do it.

Thanks
Comment 18 Erno Mononen 2010-04-28 06:41:33 UTC
Thanks for looking into this! I'll try come up with a fix for this.
Comment 19 Erno Mononen 2010-04-28 12:52:54 UTC
Should be fixed now in http://hg.netbeans.org/ruby-main/rev/b714aef48b9a. 

Please give it a try if you can, it should work with 6.8 too - just download 

http://hg.netbeans.org/ruby-main/file/b714aef48b9a/ruby.testrunner/release/nb_rspec_mediator.rb

and copy it to <nb_install_dir>/ruby/

Let me know if that doesn't fix the issue for you - thanks.
Comment 20 benfyvie 2010-04-28 14:51:13 UTC
It works! Thanks so much for fixing this bug. It was the biggest cause of productivity loss in NetBeans for me. Now I can re-run a failed spec without having to wait 5 minutes for the rest of the related specs to run. Again, thank you!