Class: Transpec::Syntax::MethodStub
- Inherits:
-
Transpec::Syntax
- Object
- Transpec::Syntax
- Transpec::Syntax::MethodStub
- Includes:
- AbleToAllowNoMessage, AbleToTargetAnyInstance, Util
- Defined in:
- lib/transpec/syntax/method_stub.rb
Constant Summary collapse
- CLASSES_DEFINING_OWN_STUB_METHOD =
[ 'Typhoeus', # https://github.com/typhoeus/typhoeus/blob/6a59c62/lib/typhoeus.rb#L66-L85 'Excon' # https://github.com/geemus/excon/blob/6af4f9c/lib/excon.rb#L143-L178 ]
Instance Attribute Summary
Attributes inherited from Transpec::Syntax
#ancestor_nodes, #node, #report, #source_rewriter
Instance Method Summary collapse
Methods included from AbleToAllowNoMessage
#allow_no_message?, #remove_allowance_for_no_message!
Methods included from AbleToTargetAnyInstance
#any_instance?, #class_node_of_any_instance
Methods included from SendNodeSyntax
#arg_node, #arg_nodes, #arg_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 Util
const_name, here_document?, in_parentheses?, indentation_of_line, proc_literal?
Methods inherited from Transpec::Syntax
all, #context, #expression_range, inherited, #initialize, #parent_node, snake_case_name, target_node?
Constructor Details
This class inherits a constructor from Transpec::Syntax
Instance Method Details
#allowize! ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/transpec/syntax/method_stub.rb', line 19 def allowize! # There's no way of unstubbing in #allow syntax. return unless [:stub, :stub!].include?(method_name) fail 'Already replaced deprecated method, cannot allowize.' if @replaced_deprecated_method unless context.allow_to_receive_available? fail InvalidContextError.new(selector_range, "##{method_name}", '#allow') end if arg_node.type == :hash expressions = build_allow_expressions_from_hash_node(arg_node) replace(expression_range, expressions) else expression = build_allow_expression(arg_node) replace(expression_range, expression) end register_record(:allow) @allowized = true end |
#replace_deprecated_method! ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/transpec/syntax/method_stub.rb', line 42 def replace_deprecated_method! return unless replacement_method_for_deprecated_method fail 'Already allowized, cannot replace deprecated method.' if @allowized replace(selector_range, replacement_method_for_deprecated_method) register_record(:deprecated) @replaced_deprecated_method = true end |