Sha256: e33f65928b33757e4b1ec47e474a04e816db9caaac9006a00b9c77bc572c3999
Contents?: true
Size: 1.43 KB
Versions: 34
Compression:
Stored size: 1.43 KB
Contents
# frozen_string_literal: true require 'spec_helper' module Synvert::Core describe Rewriter::WithinScope do let(:instance) { rewriter = Rewriter.new('foo', 'bar') Rewriter::Instance.new(rewriter, 'file pattern') } let(:source) { <<~EOS } describe Post do it 'gets post' do FactoryGirl.create :post end end EOS let(:node) { Parser::CurrentRuby.parse(source) } before do Rewriter::Instance.reset instance.current_node = node end describe '#process' do it 'not call block if no matching node' do run = false scope = Rewriter::WithinScope.new instance, type: 'send', message: 'missing' do run = true end scope.process expect(run).to be_falsey end it 'call block if there is matching node' do run = false type_in_scope = nil scope = Rewriter::WithinScope.new instance, type: 'send', receiver: 'FactoryGirl', message: 'create', arguments: [':post'] do run = true type_in_scope = node.type end scope.process expect(run).to be_truthy expect(type_in_scope).to eq :send expect(instance.current_node.type).to eq :block end end end end
Version data entries
34 entries across 34 versions & 1 rubygems