module Transpec::Syntax::Mixin::ExpectBase
Public Instance Methods
block_node()
click to toggle source
# File lib/transpec/syntax/mixin/expect_base.rb, line 62 def block_node Util.block_node_taken_by_method(to_node) end
current_syntax_type()
click to toggle source
# File lib/transpec/syntax/mixin/expect_base.rb, line 24 def current_syntax_type :expect end
dynamic_analysis_target?()
click to toggle source
Calls superclass method
# File lib/transpec/syntax/mixin/expect_base.rb, line 20 def dynamic_analysis_target? super && receiver_node.nil? && matcher_node end
matcher_node()
click to toggle source
# File lib/transpec/syntax/mixin/expect_base.rb, line 54 def matcher_node return nil unless to_node to_arg_node = to_node.children[2] return nil unless to_arg_node Util.each_forward_chained_node(to_arg_node, :include_origin) .select(&:send_type?).to_a.last end
method_name_for_instance()
click to toggle source
# File lib/transpec/syntax/mixin/expect_base.rb, line 28 def method_name_for_instance fail NotImplementedError end
positive?()
click to toggle source
# File lib/transpec/syntax/mixin/expect_base.rb, line 32 def positive? to_method_name = to_node.children[1] # `expect { do_something }.should raise_error` is possible in RSpec 2. [:to, :should].include?(to_method_name) end
subject_node()
click to toggle source
# File lib/transpec/syntax/mixin/expect_base.rb, line 38 def subject_node arg_node || parent_node end
subject_range()
click to toggle source
# File lib/transpec/syntax/mixin/expect_base.rb, line 66 def subject_range subject_node.loc.expression end
to_node()
click to toggle source
# File lib/transpec/syntax/mixin/expect_base.rb, line 42 def to_node return nil unless parent_node if parent_node.block_type? && parent_node.children.first.equal?(node) parent_node.parent elsif parent_node.send_type? && parent_node.children.first.equal?(node) parent_node else nil end end