Class: Transpec::Syntax::MatcherDefinition
- Inherits:
-
Transpec::Syntax
- Object
- Transpec::Syntax
- Transpec::Syntax::MatcherDefinition
- Includes:
- Transpec::Syntax::Mixin::Send
- Defined in:
- lib/transpec/syntax/matcher_definition.rb
Constant Summary collapse
- CONVERSION_CORRESPONDENCE =
{ match_for_should: :match, match_for_should_not: :match_when_negated, failure_message_for_should: :failure_message, failure_message_for_should_not: :failure_message_when_negated }
Instance Attribute Summary
Attributes inherited from Transpec::Syntax
#node, #report, #runtime_data, #source_rewriter
Class Method Summary collapse
Instance Method Summary collapse
Methods included from Transpec::Syntax::Mixin::Send
#arg_node, #arg_nodes, #arg_range, #args_range, included, #method_name, #parentheses_range, #range_after_arg, #range_in_between_receiver_and_selector, #range_in_between_selector_and_arg, #receiver_node, #receiver_range, #selector_range
Methods inherited from Transpec::Syntax
conversion_target_node?, #expression_range, #initialize, #parent_node, snake_case_name, standalone?, #static_context_inspector, target_node?
Methods included from Collection
#all_syntaxes, #inherited, #require_all, #standalone_syntaxes
Methods included from DynamicAnalysis
#register_request_for_dynamic_analysis
Constructor Details
This class inherits a constructor from Transpec::Syntax
Class Method Details
.target_method?(receiver_node, method_name) ⇒ Boolean
18 19 20 |
# File 'lib/transpec/syntax/matcher_definition.rb', line 18 def self.target_method?(receiver_node, method_name) receiver_node.nil? && CONVERSION_CORRESPONDENCE.keys.include?(method_name) end |
Instance Method Details
#convert_deprecated_method! ⇒ Object
22 23 24 25 26 27 |
# File 'lib/transpec/syntax/matcher_definition.rb', line 22 def convert_deprecated_method! replacement_method_name = CONVERSION_CORRESPONDENCE[method_name].to_s replace(selector_range, replacement_method_name) @report.records << Record.new("#{method_name} { }", "#{replacement_method_name} { }") end |