Module: Transpec::Syntax::Mixin::MonkeyPatch

Extended by:
ActiveSupport::Concern
Includes:
Send
Included in:
MonkeyPatchAnyInstance, Should
Defined in:
lib/transpec/syntax/mixin/monkey_patch.rb

Instance Method Summary collapse

Methods included from 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

Instance Method Details

#check_syntax_availability(key) ⇒ Object



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

def check_syntax_availability(key)
  node_data = runtime_node_data(@node)

  if node_data
    node_data[key].result
  else
    static_context_inspector.send(key)
  end
end

#register_request_of_syntax_availability_inspection(rewriter, key, methods) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/transpec/syntax/mixin/monkey_patch.rb', line 13

def register_request_of_syntax_availability_inspection(rewriter, key, methods)
  code = "self.class.ancestors.any? { |a| a.name.start_with?('RSpec::') }"

  methods.each do |method|
    code << " && respond_to?(#{method.inspect})"
  end

  rewriter.register_request(@node, key, code, :context)
end

#subject_nodeObject



33
34
35
# File 'lib/transpec/syntax/mixin/monkey_patch.rb', line 33

def subject_node
  receiver_node
end

#subject_rangeObject



37
38
39
# File 'lib/transpec/syntax/mixin/monkey_patch.rb', line 37

def subject_range
  receiver_range
end