Class: Transpec::Syntax::BeClose

Inherits:
Transpec::Syntax show all
Defined in:
lib/transpec/syntax/be_close.rb

Instance Attribute Summary

Attributes inherited from Transpec::Syntax

#ancestor_nodes, #in_example_group_context, #node, #source_rewriter

Instance Method Summary collapse

Methods inherited from Transpec::Syntax

all, #expression_range, inherited, #initialize, #parent_node, snake_case_name, target_node?

Constructor Details

This class inherits a constructor from Transpec::Syntax

Instance Method Details

#convert_to_be_within!Object



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/transpec/syntax/be_close.rb', line 9

def convert_to_be_within!
  _receiver_node, _method_name, expected_node, delta_node = *node

  be_within_source = 'be_within('
  be_within_source << delta_node.loc.expression.source
  be_within_source << ').of('
  be_within_source << expected_node.loc.expression.source
  be_within_source << ')'

  replace(expression_range, be_within_source)
end