Sha256: 901e9b584e53aac589e2f4799f79a08a0105beab1f330903b35211d3423bf004

Contents?: true

Size: 1.48 KB

Versions: 2

Compression:

Stored size: 1.48 KB

Contents

RSpec.describe RuboCop::Cop::RSpec::Capybara::FeatureMethods do
  subject(:cop) { described_class.new }

  it 'flags violations for `background`' do
    expect_offense(<<-RUBY)
      background do; end
      ^^^^^^^^^^ Use `before` instead of `background`.
    RUBY
  end

  it 'flags violations for `scenario`' do
    expect_offense(<<-RUBY)
      scenario 'Foo' do; end
      ^^^^^^^^ Use `it` instead of `scenario`.
    RUBY
  end

  it 'flags violations for `xscenario`' do
    expect_offense(<<-RUBY)
      RSpec.xscenario 'Foo' do; end
            ^^^^^^^^^ Use `xit` instead of `xscenario`.
    RUBY
  end

  it 'flags violations for `given`' do
    expect_offense(<<-RUBY)
      given(:foo) { :foo }
      ^^^^^ Use `let` instead of `given`.
    RUBY
  end

  it 'flags violations for `given!`' do
    expect_offense(<<-RUBY)
      given!(:foo) { :foo }
      ^^^^^^ Use `let!` instead of `given!`.
    RUBY
  end

  it 'flags violations for `feature`' do
    expect_offense(<<-RUBY)
      RSpec.feature 'Foo' do; end
            ^^^^^^^ Use `describe` instead of `feature`.
    RUBY
  end

  include_examples 'autocorrect', 'background { }',    'before { }'
  include_examples 'autocorrect', 'scenario { }',      'it { }'
  include_examples 'autocorrect', 'xscenario { }',     'xit { }'
  include_examples 'autocorrect', 'given(:foo) { }',   'let(:foo) { }'
  include_examples 'autocorrect', 'given!(:foo) { }',  'let!(:foo) { }'
  include_examples 'autocorrect', 'RSpec.feature { }', 'RSpec.describe { }'
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rubocop-rspec-1.17.1 spec/rubocop/cop/rspec/capybara/feature_methods_spec.rb
rubocop-rspec-1.17.0 spec/rubocop/cop/rspec/capybara/feature_methods_spec.rb