guard-jruby-rspec icon indicating copy to clipboard operation
guard-jruby-rspec copied to clipboard

Repeat tests not passing when using w/ capybara/rspec - #<NoMethodError: undefined method `background' for #<Class:0x203d2643>>

Open mariszin opened this issue 12 years ago • 4 comments

Hi!

When using guard-jruby-rspec for model testing, everything works as expected - when saving a file, tests are run. But there's an issue w/ capybara/rspec integration tests - You can only run the tests once. When running repeat tests, You get the error:

#<NoMethodError: undefined method `background' for #<Class:0x203d2643>> 

The corresponding helpers are not included in the test case. Here's the test case:

require 'spec_helper'
feature 'FunctionalZone' do
  ap self.included_modules
  background do
    ...
  end
  ...
end

When running the test for the first time, this is the list of the included modules:

[
    [ 0] Capybara::RSpecMatchers,
    [ 1] Capybara::DSL,
    [ 2] Capybara::Features,
    [ 3] RSpec::Rails::RequestExampleGroup,
    [ 4] RSpec::Rails::Matchers::RenderTemplate,
    [ 5] RSpec::Rails::Matchers::RedirectTo,
    [ 6] ActionDispatch::Integration::Runner,
    [ 7] ActionController::TemplateAssertions,
    [ 8] ActionDispatch::Assertions,
    [ 9] ActionDispatch::Assertions::TagAssertions,
    [10] ActionDispatch::Assertions::SelectorAssertions,
    [11] ActionDispatch::Assertions::RoutingAssertions,
    [12] ActionDispatch::Assertions::DomAssertions,
    [13] ActionDispatch::Assertions::ResponseAssertions,
    [14] RSpec::Rails::RailsExampleGroup,
    [15] RSpec::Rails::Matchers,
    [16] RSpec::Rails::Mocks,
    [17] RSpec::Rails::FixtureSupport,
    [18] ActiveRecord::TestFixtures,
    [19] RSpec::Rails::TestUnitAssertionAdapter,
    [20] RSpec::Rails::SetupAndTeardownAdapter,
    [21] RSpec::Matchers,
    [22] RSpec::Core::MockFrameworkAdapter,
    [23] RSpec::Core::SharedExampleGroup,
    [24] RSpec::Core::Let::ExampleMethods,
    [25] RSpec::Core::Let,
    [26] RSpec::Core::Pending,
    [27] RSpec::Core::Subject::ExampleMethods,
    [28] RSpec::Core::Extensions::InstanceEvalWithArgs,
    [29] FactoryGirl::Syntax::Vintage,
    [30] Nori::CoreExt::Object,
    [31] JSON::Ext::Generator::GeneratorMethods::Object,
    [32] ActiveSupport::Dependencies::Loadable,
    [33] PP::ObjectMixin,
    [34] Kernel
]

On subsequent runs, this list is much smaller:

[
    [ 0] RSpec::Matchers,
    [ 1] RSpec::Core::MockFrameworkAdapter,
    [ 2] RSpec::Core::SharedExampleGroup,
    [ 3] RSpec::Core::Let::ExampleMethods,
    [ 4] RSpec::Core::Let,
    [ 5] RSpec::Core::Pending,
    [ 6] RSpec::Core::Subject::ExampleMethods,
    [ 7] RSpec::Core::Extensions::InstanceEvalWithArgs,
    [ 8] FactoryGirl::Syntax::Vintage,
    [ 9] Nori::CoreExt::Object,
    [10] JSON::Ext::Generator::GeneratorMethods::Object,
    [11] ActiveSupport::Dependencies::Loadable,
    [12] PP::ObjectMixin,
    [13] Kernel,
    [14] RSpec::Mocks::Methods
]

As You can see, Capybara helpers are not included anymore. Is this a problem that only I have, or do others have this too? I'll try to reproduce this issue in a small aplication later today.

I'm using JRuby 1.7.0 (also tried 1.6.7.2 - same result), Rails 3.2.8, RSpec 2.12.0, guard-jruby-rspec 0.1.5, capybara 1.1.3

mariszin avatar Nov 13 '12 12:11 mariszin

@mariszin I'm able to reproduce this with all helpers, not just Capybara specs, so I think it's a legitimate issue.

doxavore avatar Nov 13 '12 17:11 doxavore

@mariszin Is this fixed now that #25 was merged?

nilbus avatar May 29 '13 19:05 nilbus

We since moved away from guard-jruby-rspec. I will recreate the environment and retest to verify once I have some time (maybe weekend).

mariszin avatar May 29 '13 20:05 mariszin

Hi guys,

I'm having same issue. Any one resolved this?

Error: Repeat tests not passing when using w/ capybara/rspec - #<NoMethodError: undefined method `background' for #Class:0x203d2643>

Thanks

m-ramizraja avatar Jul 22 '13 23:07 m-ramizraja