lib/rr_to_rspec_converter/text_transformer.rb
# Find any never or times(0) methods chained in the expression and remove them.
# Return true if a node was found and removed, false otherwise.
Find any never or times(0) methods chained in the expression and remove them.
Return true if a node was found and removed, false otherwise.
Find any never or times ( 0 ) methods chained in the expression and remove them . Return true if a node was found and removed false otherwise .
def remove_never_node(node)
      if never_node = node.each_ancestor(:send).find { |n| n.children[1] == :never }
        @source_rewriter.remove(range(never_node.children.first.loc.expression.end_pos, never_node.loc.selector.end_pos))
        return true
      elsif times_zero_node = node.each_ancestor(:send).find { |n| n.children[1] == :times && n.children[2].int_type? && n.children[2].children[0] == 0 }
        @source_rewriter.remove(range(times_zero_node.children[0].loc.expression.end_pos, times_zero_node.loc.expression.end_pos))
        return true
      end
      false
    end
def remove_never_node ( node ) if never_node = node . each_ancestor ( :send ) . find { | n | n . children [ 1 ] == :never } @source_rewriter . remove ( range ( never_node . children . first . loc . expression . end_pos , never_node . loc . selector . end_pos ) ) return true elsif times_zero_node = node . each_ancestor ( :send ) . find { | n | n . children [ 1 ] == :times && n . children [ 2 ] . int_type? && n . children [ 2 ] . children [ 0 ] == 0 } @source_rewriter . remove ( range ( times_zero_node . children [ 0 ] . loc . expression . end_pos , times_zero_node . loc . expression . end_pos ) ) return true end false end
Find any never or times(0) methods chained in the expression and remove them.
Find any never or times ( 0 ) methods chained in the expression and remove them .
node
<not_specific>