Sha256: efe3768dce25dc0b880293891edc1102e3c91c84eeeaaef22ad6db50ff6f1043
Contents?: true
Size: 1.43 KB
Versions: 1
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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
synvert-core-0.35.1 | spec/synvert/core/rewriter/scope/within_scope.rb |