Class: RuboCop::Cop::RSpecRails::MinitestAssertions::InDeltaAssertion
- Inherits:
-
BasicAssertion
- Object
- BasicAssertion
- RuboCop::Cop::RSpecRails::MinitestAssertions::InDeltaAssertion
- Defined in:
- lib/rubocop/cop/rspec_rails/minitest_assertions.rb
Overview
:nodoc:
Constant Summary collapse
- MATCHERS =
%i[ assert_in_delta assert_not_in_delta refute_in_delta ].freeze
Instance Attribute Summary
Attributes inherited from BasicAssertion
#actual, #expected, #failure_message
Class Method Summary collapse
Instance Method Summary collapse
- #assertion ⇒ Object
-
#initialize(expected, actual, delta, fail_message) ⇒ InDeltaAssertion
constructor
A new instance of InDeltaAssertion.
Methods inherited from BasicAssertion
Constructor Details
#initialize(expected, actual, delta, fail_message) ⇒ InDeltaAssertion
Returns a new instance of InDeltaAssertion.
174 175 176 177 178 |
# File 'lib/rubocop/cop/rspec_rails/minitest_assertions.rb', line 174 def initialize(expected, actual, delta, ) super(expected, actual, ) @delta = delta&.source || '0.001' end |
Class Method Details
.match(expected, actual, delta, failure_message) ⇒ Object
170 171 172 |
# File 'lib/rubocop/cop/rspec_rails/minitest_assertions.rb', line 170 def self.match(expected, actual, delta, ) new(expected, actual, delta.first, .first) end |
.minitest_assertion(node) ⇒ Object
166 167 |
# File 'lib/rubocop/cop/rspec_rails/minitest_assertions.rb', line 166
def_node_matcher 'self.minitest_assertion', <<~PATTERN # rubocop:disable InternalAffairs/NodeMatcherDirective
(send nil? {:assert_in_delta :assert_not_in_d
|
Instance Method Details
#assertion ⇒ Object
180 181 182 |
# File 'lib/rubocop/cop/rspec_rails/minitest_assertions.rb', line 180 def assertion "be_within(#{@delta}).of(#{expected})" end |