Sha256: 4977fed0c8c9a62979a32bb472e06d17e7fd5e2f2629719d20226df45775137b
Contents?: true
Size: 1.25 KB
Versions: 11
Compression:
Stored size: 1.25 KB
Contents
# frozen_string_literal: true require 'spec_helper' module Synvert::Core describe Rewriter::InsertAction do context 'at end' do subject { source = " User.where(username: 'Richard')" node = Parser::CurrentRuby.parse(source) instance = double(current_node: node) Rewriter::InsertAction.new(instance, '.first', at: 'end').process } it 'gets begin_pos' do expect(subject.begin_pos).to eq " User.where(username: 'Richard')".length end it 'gets end_pos' do expect(subject.end_pos).to eq " User.where(username: 'Richard')".length end it 'gets rewritten_code' do expect(subject.rewritten_code).to eq '.first' end end context 'at beginning' do subject { source = " open('http://test.com')" node = Parser::CurrentRuby.parse(source) instance = double(current_node: node) Rewriter::InsertAction.new(instance, 'URI.', at: 'beginning').process } it 'gets begin_pos' do expect(subject.begin_pos).to eq 2 end it 'gets end_pos' do expect(subject.end_pos).to eq 2 end it 'gets rewritten_code' do expect(subject.rewritten_code).to eq 'URI.' end end end end
Version data entries
11 entries across 11 versions & 1 rubygems