Module: Transpec::Syntax::Mixin::MonkeyPatch
- Included in:
- Transpec::Syntax::MethodStub, Should, ShouldReceive
- Defined in:
- lib/transpec/syntax/mixin/monkey_patch.rb
Instance Method Summary collapse
- #check_syntax_availability(key) ⇒ Object
- #register_request_of_syntax_availability_inspection(rewriter, key, methods) ⇒ Object
- #subject_node ⇒ Object
- #subject_range ⇒ Object
Instance Method Details
#check_syntax_availability(key) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/transpec/syntax/mixin/monkey_patch.rb', line 17 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
7 8 9 10 11 12 13 14 15 |
# File 'lib/transpec/syntax/mixin/monkey_patch.rb', line 7 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_node ⇒ Object
27 28 29 |
# File 'lib/transpec/syntax/mixin/monkey_patch.rb', line 27 def subject_node receiver_node end |
#subject_range ⇒ Object
31 32 33 |
# File 'lib/transpec/syntax/mixin/monkey_patch.rb', line 31 def subject_range receiver_range end |