Skip to content

Review RSpec/BeforeAfterAll: Beware of using before/after(:all) rubocop warning #199

Description

@vinzent

new error with rubocop-rspec 1.12:

spec/acceptance/selinux_permissive_spec.rb:9:5: C: RSpec/BeforeAfterAll: Beware of using before/after(:all) as it may cause state to leak between tests. If you are using rspec-rails, and use_transactional_fixtures is enabled, then records created in before(:all) are not rolled back. 
    after :all do
    ^^^^^^^^^

comment on IRC:

the spec's not well-structured.. it has multiple "it" blocks (examples) that rely on the state set by a previous example, e.g. one example calls result.exit_code, the next runs a check, then after(:all) resets the system state.

probably best to move the shell() checks into the same it {} block that actually runs the test, or have the test re-run in each it {} block (rather unnecessary)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions