lib/rubocop/cop/rspec/subject_stub.rb in rubocop-rspec-1.18.0 vs lib/rubocop/cop/rspec/subject_stub.rb in rubocop-rspec-1.19.0
- old
+ new
@@ -38,12 +38,12 @@
# @param node [RuboCop::Node]
#
# @yield [Symbol] subject name
def_node_matcher :subject, <<-PATTERN
{
- (block (send nil :subject (sym $_)) args ...)
- (block (send nil $:subject) args ...)
+ (block (send nil? :subject (sym $_)) args ...)
+ (block (send nil? $:subject) args ...)
}
PATTERN
# @!method message_expectation?(node, method_name)
# Match `allow` and `expect(...).to receive`
@@ -55,20 +55,22 @@
# expect(foo).to receive(:bar)
# expect(foo).to receive(:bar).with(1)
# expect(foo).to receive(:bar).with(1).and_return(2)
def_node_matcher :message_expectation?, <<-PATTERN
{
- (send nil :allow (send nil %))
- (send (send nil :expect (send nil %)) :to #receive_message?)
+ (send nil? :allow (send nil? %))
+ (send (send nil? :expect (send nil? %)) :to #receive_message?)
}
PATTERN
- def_node_search :receive_message?, '(send nil :receive ...)'
+ def_node_search :receive_message?, '(send nil? :receive ...)'
def on_block(node)
return unless example_group?(node)
- find_subject_stub(node) { |stub| add_offense(stub, :expression) }
+ find_subject_stub(node) do |stub|
+ add_offense(stub, location: :expression)
+ end
end
private
# Find subjects within tree and then find (send) nodes for that subject