Sha256: 53945184e1f0f0f34f6ee9aa2737b159d34b01972d20f6a0f4aebd54d661cb0e
Contents?: true
Size: 1.94 KB
Versions: 1
Compression:
Stored size: 1.94 KB
Contents
RSpec.describe RuboCop::Cop::RSpec::LetBeforeExamples do subject(:cop) { described_class.new } it 'flags `let` after `it`' do expect_offense(<<-RUBY) RSpec.describe User do it { is_expected.to be_after_let } let(:foo) { bar } ^^^^^^^^^^^^^^^^^ Move `let` before the examples in the group. end RUBY end it 'flags `let` after `context`' do expect_offense(<<-RUBY) RSpec.describe User do context 'a context' do it { is_expected.to be_after_let } end let(:foo) { bar } ^^^^^^^^^^^^^^^^^ Move `let` before the examples in the group. end RUBY end it 'flags `let` after `include_examples`' do expect_offense(<<-RUBY) RSpec.describe User do include_examples('should be after let') let(:foo) { bar } ^^^^^^^^^^^^^^^^^ Move `let` before the examples in the group. end RUBY end it 'does not flag `let` before the examples' do expect_no_offenses(<<-RUBY) RSpec.describe User do let(:foo) { bar } it { is_expected.to be_after_let } context 'a context' do it { is_expected.to work } end include_examples('everything is fine') end RUBY end it 'does not flag `let` in a nested context' do expect_no_offenses(<<-RUBY) RSpec.describe User do let(:foo) { bar } context 'something else' do let(:foo) { baz } it { is_expected.to work } end include_examples('everything is fine') end RUBY end it 'allows inclusion of context before `let`' do expect_no_offenses(<<-RUBY) RSpec.describe User do include_context 'special user' let(:foo) { bar } end RUBY end it 'does not encounter an error when handling an empty describe' do expect { inspect_source(cop, 'RSpec.describe(User) do end', 'a_spec.rb') } .not_to raise_error end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rubocop-rspec-1.16.0 | spec/rubocop/cop/rspec/let_before_examples_spec.rb |