Sha256: 7e9c5196806e4822876d0f3e5edcfb23c453a43876d488d144233a0c0ae1cad6

Contents?: true

Size: 894 Bytes

Versions: 22

Compression:

Stored size: 894 Bytes

Contents

# frozen_string_literal: true

require 'spec_helper'

module Synvert::Core
  describe Rewriter::GotoScope do
    let(:instance) {
      rewriter = Rewriter.new('foo', 'bar')
      Rewriter::Instance.new(rewriter, 'file pattern')
    }
    let(:source) {
      '
Factory.define :user do |user|
end
    '
    }
    let(:node) { Parser::CurrentRuby.parse(source) }
    before do
      Rewriter::Instance.reset
      instance.current_node = node
    end

    describe '#process' do
      it 'call block with child node' do
        run = false
        type_in_scope = nil
        scope =
          Rewriter::GotoScope.new instance, :caller 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

22 entries across 22 versions & 1 rubygems

Version Path
synvert-core-0.29.0 spec/synvert/core/rewriter/scope/goto_scope_spec.rb
synvert-core-0.28.1 spec/synvert/core/rewriter/scope/goto_scope_spec.rb
synvert-core-0.28.0 spec/synvert/core/rewriter/scope/goto_scope_spec.rb
synvert-core-0.27.4 spec/synvert/core/rewriter/scope/goto_scope_spec.rb
synvert-core-0.27.3 spec/synvert/core/rewriter/scope/goto_scope_spec.rb
synvert-core-0.27.2 spec/synvert/core/rewriter/scope/goto_scope_spec.rb
synvert-core-0.27.1 spec/synvert/core/rewriter/scope/goto_scope_spec.rb
synvert-core-0.27.0 spec/synvert/core/rewriter/scope/goto_scope_spec.rb
synvert-core-0.26.1 spec/synvert/core/rewriter/scope/goto_scope_spec.rb
synvert-core-0.26.0 spec/synvert/core/rewriter/scope/goto_scope_spec.rb
synvert-core-0.25.1 spec/synvert/core/rewriter/scope/goto_scope_spec.rb
synvert-core-0.25.0 spec/synvert/core/rewriter/scope/goto_scope_spec.rb
synvert-core-0.24.0 spec/synvert/core/rewriter/scope/goto_scope_spec.rb
synvert-core-0.23.0 spec/synvert/core/rewriter/scope/goto_scope_spec.rb
synvert-core-0.22.0 spec/synvert/core/rewriter/scope/goto_scope_spec.rb
synvert-core-0.21.2 spec/synvert/core/rewriter/scope/goto_scope_spec.rb
synvert-core-0.21.1 spec/synvert/core/rewriter/scope/goto_scope_spec.rb
synvert-core-0.21.0 spec/synvert/core/rewriter/scope/goto_scope_spec.rb
synvert-core-0.20.1 spec/synvert/core/rewriter/scope/goto_scope_spec.rb
synvert-core-0.20.0 spec/synvert/core/rewriter/scope/goto_scope_spec.rb