spec/rubocop/cop/rspec/described_class_spec.rb in rubocop-rspec-1.15.1 vs spec/rubocop/cop/rspec/described_class_spec.rb in rubocop-rspec-1.16.0
- old
+ new
@@ -5,11 +5,11 @@
{ 'EnforcedStyle' => enforced_style }
end
shared_examples 'SkipBlocks enabled' do
it 'does not flag violations within non-rspec blocks' do
- expect_violation(<<-RUBY)
+ expect_offense(<<-RUBY)
describe MyClass do
controller(ApplicationController) do
bar = MyClass
end
@@ -26,11 +26,11 @@
end
end
shared_examples 'SkipBlocks disabled' do
it 'flags violations within all blocks' do
- expect_violation(<<-RUBY)
+ expect_offense(<<-RUBY)
describe MyClass do
controller(ApplicationController) do
bar = MyClass
^^^^^^^ Use `described_class` instead of `MyClass`.
end
@@ -75,11 +75,11 @@
context 'when EnforcedStyle is :described_class' do
let(:enforced_style) { :described_class }
it 'checks for the use of the described class' do
- expect_violation(<<-RUBY)
+ expect_offense(<<-RUBY)
describe MyClass do
include MyClass
^^^^^^^ Use `described_class` instead of `MyClass`.
subject { MyClass.do_something }
@@ -90,27 +90,27 @@
end
RUBY
end
it 'ignores described class as string' do
- expect_no_violations(<<-RUBY)
+ expect_no_offenses(<<-RUBY)
describe MyClass do
subject { "MyClass" }
end
RUBY
end
it 'ignores describe that do not reference to a class' do
- expect_no_violations(<<-RUBY)
+ expect_no_offenses(<<-RUBY)
describe "MyClass" do
subject { "MyClass" }
end
RUBY
end
it 'ignores class if the scope is changing' do
- expect_no_violations(<<-RUBY)
+ expect_no_offenses(<<-RUBY)
describe MyClass do
Class.new { foo = MyClass }
Module.new { bar = MyClass }
def method
@@ -127,11 +127,11 @@
end
RUBY
end
it 'only takes class from top level describes' do
- expect_violation(<<-RUBY)
+ expect_offense(<<-RUBY)
describe MyClass do
describe MyClass::Foo do
subject { MyClass::Foo }
let(:foo) { MyClass }
@@ -140,37 +140,37 @@
end
RUBY
end
it 'ignores subclasses' do
- expect_no_violations(<<-RUBY)
+ expect_no_offenses(<<-RUBY)
describe MyClass do
subject { MyClass::SubClass }
end
RUBY
end
it 'ignores if namespace is not matching' do
- expect_no_violations(<<-RUBY)
+ expect_no_offenses(<<-RUBY)
describe MyNamespace::MyClass do
subject { ::MyClass }
let(:foo) { MyClass }
end
RUBY
end
it 'checks for the use of described class with namespace' do
- expect_violation(<<-RUBY)
+ expect_offense(<<-RUBY)
describe MyNamespace::MyClass do
subject { MyNamespace::MyClass }
^^^^^^^^^^^^^^^^^^^^ Use `described_class` instead of `MyNamespace::MyClass`.
end
RUBY
end
it 'does not flag violations within a class scope change' do
- expect_no_violations(<<-RUBY)
+ expect_no_offenses(<<-RUBY)
describe MyNamespace::MyClass do
before do
class Foo
thing = MyNamespace::MyClass.new
end
@@ -178,11 +178,11 @@
end
RUBY
end
it 'does not flag violations within a hook scope change' do
- expect_no_violations(<<-RUBY)
+ expect_no_offenses(<<-RUBY)
describe do
before do
MyNamespace::MyClass.new
end
end
@@ -190,11 +190,11 @@
end
it 'checks for the use of described class with module' do
skip
- expect_violation(<<-RUBY)
+ expect_offense(<<-RUBY)
module MyNamespace
describe MyClass do
subject { MyNamespace::MyClass }
^^^^^^^^^^^^^^^^^^^^ Use `described_class` instead of `MyNamespace::MyClass`
end
@@ -217,11 +217,11 @@
context 'when EnforcedStyle is :explicit' do
let(:enforced_style) { :explicit }
it 'checks for the use of the described_class' do
- expect_violation(<<-RUBY)
+ expect_offense(<<-RUBY)
describe MyClass do
include described_class
^^^^^^^^^^^^^^^ Use `MyClass` instead of `described_class`.
subject { described_class.do_something }
@@ -232,27 +232,27 @@
end
RUBY
end
it 'ignores described_class as string' do
- expect_no_violations(<<-RUBY)
+ expect_no_offenses(<<-RUBY)
describe MyClass do
subject { "described_class" }
end
RUBY
end
it 'ignores describe that do not reference to a class' do
- expect_no_violations(<<-RUBY)
+ expect_no_offenses(<<-RUBY)
describe "MyClass" do
subject { described_class }
end
RUBY
end
it 'does not flag violations within a class scope change' do
- expect_no_violations(<<-RUBY)
+ expect_no_offenses(<<-RUBY)
describe MyNamespace::MyClass do
before do
class Foo
thing = described_class.new
end
@@ -260,10 +260,10 @@
end
RUBY
end
it 'does not flag violations within a hook scope change' do
- expect_no_violations(<<-RUBY)
+ expect_no_offenses(<<-RUBY)
describe do
before do
described_class.new
end
end