Class: RuboCop::Cop::RSpec::ExpectOutput
- Defined in:
- lib/rubocop/cop/rspec/expect_output.rb
Overview
Checks for opportunities to use ‘expect { … }.to output`.
Constant Summary collapse
- MSG =
'Use `expect { ... }.to output(...).to_%<name>s` '\ 'instead of mutating $%<name>s.'.freeze
Constants inherited from Cop
Constants included from RSpec::Language
Instance Method Summary collapse
Methods inherited from Cop
Instance Method Details
#on_gvasgn(node) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/rubocop/cop/rspec/expect_output.rb', line 23 def on_gvasgn(node) return unless inside_example_scope?(node) variable_name, _rhs = *node name = variable_name[1..-1] return unless name.eql?('stdout') || name.eql?('stderr') add_offense(node, :name, format(MSG, name: name)) end |