Sha256: d7f963f046b05f8bd0819967796f40e3fd620874bf3a4f9b37cdfe950f2aa95c
Contents?: true
Size: 1.53 KB
Versions: 34
Compression:
Stored size: 1.53 KB
Contents
# frozen_string_literal: true require 'spec_helper' module Synvert::Core describe Rewriter::ReplaceWithAction do context 'replace with single line' do subject { source = 'post = FactoryGirl.create_list :post, 2' send_node = Parser::CurrentRuby.parse(source).children[1] instance = double(current_node: send_node) Rewriter::ReplaceWithAction.new(instance, 'create_list {{arguments}}') } it 'gets begin_pos' do expect(subject.begin_pos).to eq 'post = '.length end it 'gets end_pos' do expect(subject.end_pos).to eq 'post = FactoryGirl.create_list :post, 2'.length end it 'gets rewritten_code' do expect(subject.rewritten_code).to eq 'create_list :post, 2' end end context '#replace with multiple line' do subject { source = ' its(:size) { should == 1 }' send_node = Parser::CurrentRuby.parse(source) instance = double(current_node: send_node) Rewriter::ReplaceWithAction.new( instance, "describe '#size' do subject { super().size } it { {{body}} } end", autoindent: false ) } it 'gets begin_pos' do expect(subject.begin_pos).to eq 2 end it 'gets end_pos' do expect(subject.end_pos).to eq ' its(:size) { should == 1 }'.length end it 'gets rewritten_code' do expect(subject.rewritten_code).to eq "describe '#size' do subject { super().size } it { should == 1 } end" end end end end
Version data entries
34 entries across 34 versions & 1 rubygems