Skip to content

Commit

Permalink
Merge pull request #141 from nevir/fix/describe_class-regression
Browse files Browse the repository at this point in the history
Fix regression in DescribeClass
  • Loading branch information
backus authored Aug 1, 2016
2 parents cf185f7 + 6080375 commit 4922fd6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/rubocop/cop/rspec/describe_class.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ class DescribeClass < Cop
'the class or module being tested.'.freeze

def_node_matcher :valid_describe?, <<-PATTERN
{(send nil :describe const ...) (send nil :describe)}
{(send {(const nil :RSpec) nil} :describe const ...) (send nil :describe)}
PATTERN

def_node_matcher :describe_with_metadata, <<-PATTERN
(send nil :describe
(send {(const nil :RSpec) nil} :describe
!const
...
(hash $...))
Expand Down
14 changes: 14 additions & 0 deletions spec/rubocop/cop/rspec/describe_class_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
'the class or module being tested.'])
end

it 'supports RSpec.describe' do
inspect_source(cop, 'RSpec.describe Foo do; end')
expect(cop.offenses).to be_empty
end

it 'checks describe statements after a require' do
inspect_source(
cop,
Expand Down Expand Up @@ -50,6 +55,15 @@
expect(cop.offenses).to be_empty
end

it 'ignores feature specs when RSpec.describe is used' do
inspect_source(
cop,
"RSpec.describe 'my new feature', type: :feature do; end"
)

expect(cop.offenses).to be_empty
end

it 'flags specs with non :type metadata' do
inspect_source(cop, "describe 'my new feature', foo: :feature do; end")
expect(cop.messages).to eq(['The first argument to describe should be ' \
Expand Down

0 comments on commit 4922fd6

Please sign in to comment.