Class: Transpec::Syntax::Should
- Inherits:
-
Syntax
- Object
- Syntax
- Transpec::Syntax::Should
- Includes:
- Mixin::Expectizable, Mixin::MonkeyPatch, Mixin::ShouldBase, Util
- Defined in:
- lib/transpec/syntax/should.rb
Constant Summary
Constants included from Util
Util::LITERAL_TYPES, Util::WHITESPACES
Instance Attribute Summary collapse
-
#current_syntax_type ⇒ Object
readonly
Returns the value of attribute current_syntax_type.
Instance Method Summary collapse
- #dynamic_analysis_target? ⇒ Boolean
- #expectize!(negative_form = 'not_to') ⇒ Object
-
#initialize ⇒ Should
constructor
A new instance of Should.
Methods included from Mixin::ShouldBase
#matcher_node, #positive?, #should_range
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
Methods included from Mixin::MatcherOwner
Methods included from Mixin::MonkeyPatch
#register_syntax_availability_analysis_request, #subject_node, #subject_range, #syntax_available?
Methods included from Mixin::Expectizable
Methods included from Util
beginning_of_line_range, block_node_taken_by_method, chainable_source, const_name, contain_here_document?, each_backward_chained_node, each_forward_chained_node, each_line_range, expand_range_to_adjacent_whitespaces, find_consecutive_whitespace_position, first_block_arg_name, here_document?, in_explicit_parentheses?, indentation_of_line, line_range, literal?, proc_literal?, range_from_arg
Constructor Details
#initialize ⇒ Should
Returns a new instance of Should.
24 25 26 27 |
# File 'lib/transpec/syntax/should.rb', line 24 def initialize(*) super @current_syntax_type = :should end |
Instance Attribute Details
#current_syntax_type ⇒ Object (readonly)
Returns the value of attribute current_syntax_type.
14 15 16 |
# File 'lib/transpec/syntax/should.rb', line 14 def current_syntax_type @current_syntax_type end |
Instance Method Details
#dynamic_analysis_target? ⇒ Boolean
29 30 31 |
# File 'lib/transpec/syntax/should.rb', line 29 def dynamic_analysis_target? super && receiver_node && [:should, :should_not].include?(method_name) end |
#expectize!(negative_form = 'not_to') ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/transpec/syntax/should.rb', line 33 def expectize!(negative_form = 'not_to') fail ContextError.new("##{method_name}", '#expect', selector_range) unless expect_available? if proc_subject? replace(range_of_subject_method_taking_block, 'expect') else wrap_subject_in_expect! end replace(should_range, positive? ? 'to' : negative_form) @current_syntax_type = :expect add_record(negative_form) end |