Module: Transpec::Syntax::Mixin::ShouldBase

Included in:
OnelinerShould, Should
Defined in:
lib/transpec/syntax/mixin/should_base.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(syntax) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/transpec/syntax/mixin/should_base.rb', line 9

def self.included(syntax)
  syntax.add_dynamic_analysis_request do |rewriter|
    if OperatorMatcher.dynamic_analysis_target_node?(matcher_node)
      create_operator_matcher.register_request_for_dynamic_analysis(rewriter)
    end
  end
end

Instance Method Details

#matcher_nodeObject



21
22
23
# File 'lib/transpec/syntax/mixin/should_base.rb', line 21

def matcher_node
  arg_node || parent_node
end

#operator_matcherObject



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/transpec/syntax/mixin/should_base.rb', line 33

def operator_matcher
  return @operator_matcher if instance_variable_defined?(:@operator_matcher)

  @operator_matcher ||= begin
    if OperatorMatcher.conversion_target_node?(matcher_node, @runtime_data)
      create_operator_matcher
    else
      nil
    end
  end
end

#positive?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/transpec/syntax/mixin/should_base.rb', line 17

def positive?
  method_name == :should
end

#should_rangeObject



25
26
27
28
29
30
31
# File 'lib/transpec/syntax/mixin/should_base.rb', line 25

def should_range
  if arg_node
    selector_range
  else
    selector_range.join(expression_range.end)
  end
end