Class: Transpec::Syntax::Should
- Inherits:
-
Transpec::Syntax
- Object
- Transpec::Syntax
- Transpec::Syntax::Should
- Includes:
- Mixin::Expectizable, Mixin::MonkeyPatch, Mixin::ShouldBase, Util
- Defined in:
- lib/transpec/syntax/should.rb
Defined Under Namespace
Classes: RecordBuilder
Constant Summary
Constants included from Util
Util::LITERAL_TYPES, Util::WHITESPACES
Instance Attribute Summary
Attributes inherited from Transpec::Syntax
#node, #project, #report, #runtime_data, #source_rewriter
Instance Method Summary collapse
- #dynamic_analysis_target? ⇒ Boolean
- #expectize!(negative_form = 'not_to') ⇒ Object
- #name_of_subject_method_taking_block ⇒ Object
- #proc_subject? ⇒ Boolean
Methods included from Mixin::ShouldBase
#current_syntax_type, #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
Methods inherited from Transpec::Syntax
#add_record, #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
#dynamic_analysis_target? ⇒ Boolean
22 23 24 |
# File 'lib/transpec/syntax/should.rb', line 22 def dynamic_analysis_target? super && receiver_node && [:should, :should_not].include?(method_name) end |
#expectize!(negative_form = 'not_to') ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/transpec/syntax/should.rb', line 26 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(RecordBuilder.build(self, negative_form)) end |
#name_of_subject_method_taking_block ⇒ Object
49 50 51 |
# File 'lib/transpec/syntax/should.rb', line 49 def name_of_subject_method_taking_block range_of_subject_method_taking_block.source end |
#proc_subject? ⇒ Boolean
41 42 43 44 45 46 47 |
# File 'lib/transpec/syntax/should.rb', line 41 def proc_subject? return true if proc_literal?(subject_node) return false unless subject_node.block_type? send_node = subject_node.children.first receiver_node, method_name, = *send_node receiver_node.nil? && method_name == :expect end |