Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

Commit

Permalink
Added specs for DSL error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
koraktor committed Feb 12, 2012
1 parent daf5d4a commit 7b03d84
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions spec/bundler/dsl_spec.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
require 'spec_helper'

describe Bundler::Dsl do
describe '#_normalize_options' do
before do
@rubygems = mock("rubygems")
Bundler::Source::Rubygems.stub(:new){ @rubygems }
end
before do
rubygems = mock("rubygems")
Bundler::Source::Rubygems.stub(:new){ rubygems }
end

describe '#_normalize_options' do
it "should convert :github to :git" do
subject.gem("sparks", :github => "indirect/sparks")
github_uri = "git://github.com/indirect/sparks.git"
Expand All @@ -19,4 +19,15 @@
subject.dependencies.first.source.uri.should == github_uri
end
end

describe '#method_missing' do
it 'should raise an error for unknown DSL methods' do
dsl = Bundler::Dsl.new
dsl.stub(:caller => ['Gemfile:3'])
Bundler.should_receive(:read_file).with('Gemfile').and_return("source :rubygems\ngemspec\nunknown")

error_msg = "The Gemfile doesn't support the method `unknown`.\nPlease check your Gemfile's syntax at line 3:\n\n source :rubygems\n gemspec\n unknown\n"
lambda { dsl.unknown }.should raise_error(Bundler::GemfileError, error_msg)
end
end
end

0 comments on commit 7b03d84

Please sign in to comment.