Class: Transpec::Syntax::BeBoolean

Inherits:
Transpec::Syntax show all
Includes:
Mixin::Send
Defined in:
lib/transpec/syntax/be_boolean.rb

Instance Attribute Summary

Attributes inherited from Transpec::Syntax

#node, #project, #report, #runtime_data, #source_rewriter

Instance Method Summary collapse

Methods included from Mixin::Send

#arg_node, #arg_nodes, #arg_range, #args_range, #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 included from Mixin::Send::TargetDetection

#conversion_target?

Methods inherited from Transpec::Syntax

#conversion_target?, #dependent_syntaxes, #expression_range, #initialize, #inspect, #parent_node, #rspec_version, snake_case_name, standalone?, #static_context_inspector

Methods included from Collection

#all_syntaxes, #inherited, #mixins, #require_all, #standalone_syntaxes

Methods included from DynamicAnalysis

#register_dynamic_analysis_request

Constructor Details

This class inherits a constructor from Transpec::Syntax

Instance Method Details

#be_true?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/transpec/syntax/be_boolean.rb', line 15

def be_true?
  method_name == :be_true
end

#convert_to_conditional_matcher!(form_of_be_falsey = 'be_falsey') ⇒ Object



19
20
21
22
23
# File 'lib/transpec/syntax/be_boolean.rb', line 19

def convert_to_conditional_matcher!(form_of_be_falsey = 'be_falsey')
  replacement = be_true? ? 'be_truthy' : form_of_be_falsey
  replace(expression_range, replacement)
  add_record(replacement)
end

#convert_to_exact_matcher!Object



25
26
27
28
29
# File 'lib/transpec/syntax/be_boolean.rb', line 25

def convert_to_exact_matcher!
  replacement = be_true? ? 'be true' : 'be false'
  replace(expression_range, replacement)
  add_record(replacement)
end

#dynamic_analysis_target?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/transpec/syntax/be_boolean.rb', line 11

def dynamic_analysis_target?
  super && receiver_node.nil? && [:be_true, :be_false].include?(method_name)
end