Sha256: 8e4b8c1ab6a28b1b40c099d593e8a25e219a9362fdd1e4de668bb911f7f0bcc0
Contents?: true
Size: 1.88 KB
Versions: 6
Compression:
Stored size: 1.88 KB
Contents
# encoding: utf-8 require 'spec_helper' module Rubocop module Cop describe 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 = Corrector.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 = Corrector.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 = Corrector.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 = Corrector.new(processed_source.buffer, [correction]) expect(corrector.rewrite).to eq 'true or false' end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems