Sha256: 00aad9ea69a2ac7a952d15bc8318c692748efd2da10022660cccf3487081510e

Contents?: true

Size: 915 Bytes

Versions: 34

Compression:

Stored size: 915 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) { <<~EOS }
      Factory.define :user do |user|
      end
    EOS

    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.receiver' do
            run = true
            type_in_scope = node.type
          end
        scope.process
        expect(run).to be_truthy
        expect(type_in_scope).to eq :const
        expect(instance.current_node.type).to eq :block
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
synvert-core-1.4.0 spec/synvert/core/rewriter/scope/goto_scope_spec.rb
synvert-core-1.3.1 spec/synvert/core/rewriter/scope/goto_scope_spec.rb
synvert-core-1.3.0 spec/synvert/core/rewriter/scope/goto_scope_spec.rb
synvert-core-1.2.1 spec/synvert/core/rewriter/scope/goto_scope_spec.rb
synvert-core-1.2.0 spec/synvert/core/rewriter/scope/goto_scope_spec.rb
synvert-core-1.1.1 spec/synvert/core/rewriter/scope/goto_scope_spec.rb
synvert-core-1.1.0 spec/synvert/core/rewriter/scope/goto_scope_spec.rb
synvert-core-1.0.5 spec/synvert/core/rewriter/scope/goto_scope_spec.rb
synvert-core-1.0.4 spec/synvert/core/rewriter/scope/goto_scope_spec.rb
synvert-core-1.0.3 spec/synvert/core/rewriter/scope/goto_scope_spec.rb
synvert-core-1.0.2 spec/synvert/core/rewriter/scope/goto_scope_spec.rb
synvert-core-1.0.1 spec/synvert/core/rewriter/scope/goto_scope_spec.rb
synvert-core-0.64.0 spec/synvert/core/rewriter/scope/goto_scope_spec.rb
synvert-core-0.63.1 spec/synvert/core/rewriter/scope/goto_scope_spec.rb
synvert-core-0.63.0 spec/synvert/core/rewriter/scope/goto_scope_spec.rb
synvert-core-0.62.1 spec/synvert/core/rewriter/scope/goto_scope_spec.rb
synvert-core-0.62.0 spec/synvert/core/rewriter/scope/goto_scope_spec.rb
synvert-core-0.61.2 spec/synvert/core/rewriter/scope/goto_scope_spec.rb
synvert-core-0.61.1 spec/synvert/core/rewriter/scope/goto_scope_spec.rb
synvert-core-0.61.0 spec/synvert/core/rewriter/scope/goto_scope_spec.rb