Can't run RSpec test

I attached the gem as described in the video but am getting a basic error when running the project:

Fail to load: /Users/antonystubbs/RubymineProjects/untitled/receipt_processor_spec.rb:1
      Exception message: undefined method `describe' for main:Object
        /Users/antonystubbs/RubymineProjects/untitled/receipt_processor_spec.rb:5
        /Applications/RubyMine 2.0 Beta 2.app/rb/testing/runner/tunit_in_folder_runner.rb:41:in `require'
        /Applications/RubyMine 2.0 Beta 2.app/rb/testing/runner/tunit_in_folder_runner.rb:41
        /Applications/RubyMine 2.0 Beta 2.app/rb/testing/runner/tunit_in_folder_runner.rb:35:in `each'
        /Applications/RubyMine 2.0 Beta 2.app/rb/testing/runner/tunit_in_folder_runner.rb:35
        -e:1:in `load'
        -e:1



i.e.


require 'receipt_processor'


describe ReceiptProcessor do




  it "should calculate gst for input 1" do
    input1 = <<ML


And when I try to run spec as a rake task, typing 's' after going run task, brings up on results - "no matches found". In fact, there are no matches for any letter I try - that's probably a clue.

Any clues?

P.s. it runs fine using 'spec' form the command line.

10 comments
Comment actions Permalink

Hi,

Add following lines to the top of the file.

require 'rspec'


In you case RubyMine doesn't understand that your file is rspec test and tries to launch it using ruby interpreter as general ruby script (instead of spec runner script).  Attaching gems in RubyMine affects RubyMine's code insight features (resolve, autocompletion, etc) but RM also always analyzes files which are required in current file.

0
Comment actions Permalink

Thanks. But now I get this error: undefined method bin_path for Gem:Module. It's the same problem I get in NetBeans. But again, it runs fine from the command line. Environment problem? I originally installed Ruby etc using macports.

/usr/bin/ruby -e STDOUT.sync=true;STDERR.sync=true;load($0=ARGV.shift) /Applications/RubyMine 2.0 Beta 2.app/rb/testing/runner/specs_in_folder_runner.rb
Testing started at 11:36 ...
Work directory: /Users/antonystubbs/RubymineProjects/untitled}
Searching files....
=========================================
1. /Users/antonystubbs/RubymineProjects/untitled/line_item_spec.rb:1
2. /Users/antonystubbs/RubymineProjects/untitled/my_currency_spec.rb:1
3. /Users/antonystubbs/RubymineProjects/untitled/receipt_processor_spec.rb:1
3 files were found.
=========================================
RSpec script : /Users/antonystubbs/.gem/ruby/1.8/bin/spec
Ruby Options:
["-e", "STDOUT.sync=true;STDERR.sync=true;load($0=ARGV.shift)"]
Spec Options:
[]
=========================================
Running specs...
Ruby interpreter arguments:
["-e", "STDOUT.sync=true;STDERR.sync=true;load($0=ARGV.shift)", "/Users/antonystubbs/.gem/ruby/1.8/bin/spec", "--require", "teamcity/spec/runner/formatter/teamcity/formatter", "--format", "Spec::Runner::Formatter::TeamcityFormatter:matrix", "/Users/antonystubbs/RubymineProjects/untitled/line_item_spec.rb", "/Users/antonystubbs/RubymineProjects/untitled/my_currency_spec.rb", "/Users/antonystubbs/RubymineProjects/untitled/receipt_processor_spec.rb"]
/Users/antonystubbs/.gem/ruby/1.8/bin/spec:19: undefined method `bin_path' for Gem:Module (NoMethodError)
     from -e:1:in `load'
     from -e:1
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:971:in `sh': Command failed with status (1): [/System/Library/Frameworks/Ruby.framework/...] (RuntimeError)
     from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:984:in `call'
     from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:984:in `sh'
     from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1072:in `sh'
     from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1005:in `ruby'
     from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1072:in `ruby'
     from /Applications/RubyMine 2.0 Beta 2.app/rb/testing/runner/specs_in_folder_runner.rb:130
     from -e:1:in `load'
     from -e:1
Empty test suite.

Process finished with exit code 1

0
Comment actions Permalink

Please execute "which ruby" command in console

0
Comment actions Permalink

Last login: Tue Oct 27 08:38:34 on console
antony-stubbss-macbook-pro-4:~ antonystubbs$ which ruby
/opt/local/bin/ruby
antony-stubbss-macbook-pro-4:~ antonystubbs$ ls -la /opt/local/bin/ruby
-rwxr-xr-x  2 root  admin  8880 22 Oct 23:40 /opt/local/bin/ruby
antony-stubbss-macbook-pro-4:~ antonystubbs$ ruby --version
ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin10]
antony-stubbss-macbook-pro-4:~ antonystubbs$

0
Comment actions Permalink

As you can mention RubyMine and your console uses different Ruby interpreters

Output from RubyMine:

/usr/bin/ruby -e STDOUT.sync=true;STDERR.sync=true;load($0=ARGV.shift) /Applications/RubyMine 2.0 Beta 2.app/rb/testing/runner/specs_in_folder_runner.rb
Testing started at 11:36 ... 

and you console:
Last login: Tue Oct 27 08:38:34 on console
antony-stubbss-macbook-pro-4:~ antonystubbs$ which ruby
/opt/local/bin/ruby 

It is due to Mac OS general problem related to environment variables, please read javascript:;
Or instead of correct environment setup you can just ask RubyMine to use /opt/local/bin/ruby as your ruby interpreter - see RubyMine | File | Settings | RubySDK and Gems,  "Add SDK" button

0
Comment actions Permalink

Ok, that's made some progress. Switching RubyMine to use /opt/local/bin/ruby seems run the the tests, Rubymine very quickly reports "all tests passed", but then goes into an unresponsive state, and I have to force quit :/

However I don't think it's actually running the tests - or perhaps not running all the tests, because if i modify a test so that it will fail before running this, it still reports all tests pass.

Hmm, after 4 restarts, not it seems to work as expected, without me having changed anything to prevent the crashing.

0
Comment actions Permalink

And this is RubyMine bug, please track issue http://youtrack.jetbrains.net/issue/RUBY-5201. As far as I know it appeared in RubyMine 2.0 Beta 2 and first our beta doesn't contain it.. Bug will be fixed in next public build.

0
Comment actions Permalink

Cool- thanks for the support.
Will have to check RubyMine out again for my next job interview

0
Comment actions Permalink

Antony, we've just published RubyMine 2.0 Beta 3. Please try it, I hope the issue is fixed there

0
Comment actions Permalink

Cool - a quick test looks good.

0

Please sign in to leave a comment.