jkutner / guard-jruby-rspec

RSpec on JRuby without the startup cost.
MIT License
62 stars 16 forks source link

Tests are failing after first rspec run #13

Open iRonin opened 12 years ago

iRonin commented 12 years ago

My rspec tests are failing after first rspec run. Color output is disabled after first run as well. Tried with master just a second ago.

I get errors like the following for get and visit methods inside my tests:

OrderPagesController GET 'choose_plan' returns http success
     Failure/Error: get :choose_plan
     NoMethodError:
       undefined method `get' for #<#<Class:0xa8182c5>::Nested_1:0x469657c4>
     # ./spec/controllers/order_pages_controller_spec.rb:7:in `(root)'

I also get different output for test descriptions:

Order
  as a new record
    example at ./spec/models/order_spec.rb:22 # instead of the description from the first run

On other application in the second run I get the following error for VCR:

ERROR: Guard::JRubyRSpec failed to achieve its <run_all>, exception was:
NameError: undefined local variable or method `use_vcr_cassette' for #<Class:0x66d278af>

It looks like rspec doesn't recognize macros added by other gems.

cfitz commented 12 years ago

I'm having the same problem. Using jruby 1.6.7.2 in 1.9 mode doing jruby -S bundle exec guard

jeremyjh commented 12 years ago

Me too.

patrickmcelwee commented 11 years ago

I get this problem too using jruby 1.6.7.2 in 1.9 mode. There also seems to be a conflict with DatabaseCleaner, because on my second run (not my first), I also got errors about non-unique attributes when I created the same kind of object in subsequent tests. My DatabaseCleaner set up looks like this:

Rspec.configure do |config|
  config.use_transactional_fixtures = false

  config.before :each do
    if Capybara.current_driver == :rack_test
      DatabaseCleaner.strategy = :transaction
    else
      DatabaseCleaner.strategy = :truncation
    end
    DatabaseCleaner.start
  end

  config.after :each do
    DatabaseCleaner.clean
  end
end
clupprich commented 11 years ago

Same here. I've just updated to jruby 1.6.8, running in 1.9 mode. Had the same problems with jruby 1.6.7.2 as described above (including the DatabaseCleaner strategy).

doxavore commented 11 years ago

I think I'm seeing the same issue. For me, it stems from the fact that my RSpec.configure block (from spec_helper) isn't being called between tests, since my spec file uses require 'spec_helper'. If I change it to an appropriate load (i.e. load File.expand_path('../../spec_helper.rb', __FILE__)) it will run on subsequent runs.

Since we only load the changed files (per https://github.com/jkutner/guard-jruby-rspec/blob/076dbbb4845d57cea0a815cb71a7122cb8ed9300/lib/guard/jruby-rspec.rb#L85), I imagine we'll need to use load for spec_helper. But of course that's no fun. :)

Can anyone else confirm using load works for them, or am I running into a separate issue?

@jkutner Is this something you ran into, and why there are stubs for monitor_file around?