Sha256: a65bdf05746996626e6f5842d7f0737b390cd388e039389a5992bc02b2871d82
Contents?: true
Size: 1.7 KB
Versions: 14
Compression:
Stored size: 1.7 KB
Contents
# encoding: utf-8 require 'spec_helper' describe Rubocop::Cop::Corrector do describe '#rewrite' do it 'allows removal of a range' do source = 'true and false' processed_source = parse_source(source) correction = lambda do |corrector| node = processed_source.ast corrector.remove(node.loc.operator) end corrector = described_class.new(processed_source.buffer, [correction]) expect(corrector.rewrite).to eq 'true false' end it 'allows insertion before a source range' do source = 'true and false' processed_source = parse_source(source) correction = lambda do |corrector| node = processed_source.ast corrector.insert_before(node.loc.operator, ';nil ') end corrector = described_class.new(processed_source.buffer, [correction]) expect(corrector.rewrite).to eq 'true ;nil and false' end it 'allows insertion after a source range' do source = 'true and false' processed_source = parse_source(source) correction = lambda do |corrector| node = processed_source.ast corrector.insert_after(node.loc.operator, ' nil;') end corrector = described_class.new(processed_source.buffer, [correction]) expect(corrector.rewrite).to eq 'true and nil; false' end it 'allows replacement of a range' do source = 'true and false' processed_source = parse_source(source) correction = lambda do |corrector| node = processed_source.ast corrector.replace(node.loc.operator, 'or') end corrector = described_class.new(processed_source.buffer, [correction]) expect(corrector.rewrite).to eq 'true or false' end end end
Version data entries
14 entries across 14 versions & 2 rubygems