Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add simple specs for DependencyResolver
  • Loading branch information
adambeynon committed Dec 18, 2013
1 parent deb05d4 commit 1f6506b
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions spec/cli/dependency_resolver_spec.rb
@@ -0,0 +1,40 @@
require File.expand_path('../spec_helper.rb', __FILE__)

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(*parts)
Opal::Sexp.new(parts)
end

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

0 comments on commit 1f6506b

Please sign in to comment.