Sha256: 00afb185ee16a071f5da69f8fdcbccd8d899a464aeca4ba820b9b3b65e4f4176

Contents?: true

Size: 1.36 KB

Versions: 1

Compression:

Stored size: 1.36 KB

Contents

require 'lib/spec_helper'

describe Opal::Nodes::CallNode::DependencyResolver do
  let(:compiler) { double(:compiler, :dynamic_require_severity => :none) }

  it "resolves simple strings to themselves" do
    expect(resolve s(:str, 'foo')).to eq('foo')
  end

  context "using a dynamic segment not supported" do
    it "raises a compiler error when severity is :error" do
      compiler = double(:compiler, :dynamic_require_severity => :error)
      expect(compiler).to receive(:error).once
      expect(compiler).to receive(:dynamic_require_severity).once
      described_class.new(compiler, s(:self)).resolve
    end

    it "produces a compiler warning when severity is :warning" do
      compiler = double(:compiler, :dynamic_require_severity => :warning)
      expect(compiler).to receive(:warning).once
      expect(compiler).to receive(:dynamic_require_severity).once
      described_class.new(compiler, s(:self)).resolve
    end

    it "does not produce a warning or error for other options" do
      compiler = double(:compiler, :dynamic_require_severity => :foo)
      expect(compiler).to_not receive(:warning)
      expect(compiler).to_not receive(:error)
      described_class.new(compiler, s(:self)).resolve
    end
  end

  def s(type, *children)
    ::Opal::AST::Node.new(type, children)
  end

  def resolve(sexp)
    described_class.new(compiler, sexp).resolve
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
opal-0.11.0.rc1 spec/lib/dependency_resolver_spec.rb