Class: Transpec::Syntax::BeClose

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.target_method_names ⇒ Object



29
30
31
# File 'lib/transpec/syntax/be_close.rb', line 29

def self.target_method_names
  [:be_close]
end

.target_receiver_node?(node) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/transpec/syntax/be_close.rb', line 25

def self.target_receiver_node?(node)
  node.nil?
end

Instance Method Details

#convert_to_be_within! ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
# 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)

  register_record
end