Sha256: 2e45bc1180c20713cdef2401693281e37cd97958d330741ed050550603b46c58
Contents?: true
Size: 1.7 KB
Versions: 4
Compression:
Stored size: 1.7 KB
Contents
# frozen_string_literal: true RSpec.describe RuboCop::Cop::RSpec::RepeatedDescription do subject(:cop) { described_class.new } it 'registers an offense for repeated descriptions' do expect_violation(<<-RUBY) describe 'doing x' do it "does x" do ^^^^^^^^^^^ Don't repeat descriptions within an example group. end it "does x" do ^^^^^^^^^^^ Don't repeat descriptions within an example group. end end RUBY end it 'registers offense for repeated descriptions separated by a context' do expect_violation(<<-RUBY) describe 'doing x' do it "does x" do ^^^^^^^^^^^ Don't repeat descriptions within an example group. end context 'during some use case' do it "does x" do # this should be fine end end it "does x" do ^^^^^^^^^^^ Don't repeat descriptions within an example group. end end RUBY end it 'ignores descriptions repeated in a shared context' do expect_no_violations(<<-RUBY) describe 'doing x' do it "does x" do end shared_context 'shared behavior' do it "does x" do end end end RUBY end it 'ignores repeated descriptions in a nested context' do expect_no_violations(<<-RUBY) describe 'doing x' do it "does x" do end context 'in a certain use case' do it "does x" do end end end RUBY end it 'does not flag tests which do not contain description strings' do expect_no_violations(<<-RUBY) describe 'doing x' do it { foo } it { bar } end RUBY end end
Version data entries
4 entries across 4 versions & 1 rubygems