Skip to content

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

Open
@mariszin

Description

@mariszin

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions