diff options
author | Andre Arko <andre@arko.net> | 2012-12-08 15:36:08 -0800 |
---|---|---|
committer | Andre Arko <andre@arko.net> | 2012-12-08 15:37:38 -0800 |
commit | f97db8dd2d56396498671293089694ec65c0f175 (patch) | |
tree | c3e7df8e8d7b779e557890ba1afbcf02654c4531 | |
parent | b7308a8e74f27b6f4a023163d99454bf9de4621e (diff) | |
parent | a3a3efabc00253be86beb3024600bc66d75c81e4 (diff) | |
download | bundler-f97db8dd2d56396498671293089694ec65c0f175.tar.gz |
Merge pull request #1958 from jgaskins/dsl-gist
Add :gist option for gems embedded in gists
Update specs to use expect() – @indirect
-rw-r--r-- | lib/bundler/dsl.rb | 6 | ||||
-rw-r--r-- | spec/bundler/dsl_spec.rb | 22 |
2 files changed, 22 insertions, 6 deletions
diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb index 0ac7036340..a865a7e57a 100644 --- a/lib/bundler/dsl.rb +++ b/lib/bundler/dsl.rb @@ -201,7 +201,7 @@ module Bundler def _normalize_options(name, version, opts) _normalize_hash(opts) - valid_keys = %w(group groups git github path name branch ref tag require submodules platform platforms type) + valid_keys = %w(group groups git gist github path name branch ref tag require submodules platform platforms type) invalid_keys = opts.keys - valid_keys if invalid_keys.any? plural = invalid_keys.size > 1 @@ -235,6 +235,10 @@ module Bundler opts["git"] = "git://github.com/#{github}.git" end + if gist = opts.delete("gist") + opts["git"] = "git://gist.github.com/#{gist}.git" + end + ["git", "path"].each do |type| if param = opts[type] if version.first && version.first =~ /^\s*=?\s*(\d[^\s]*)\s*$/ diff --git a/spec/bundler/dsl_spec.rb b/spec/bundler/dsl_spec.rb index 334fe6001c..8287e7439f 100644 --- a/spec/bundler/dsl_spec.rb +++ b/spec/bundler/dsl_spec.rb @@ -7,19 +7,31 @@ describe Bundler::Dsl do end describe '#_normalize_options' do - it "should convert :github to :git" do + it "converts :github to :git" do subject.gem("sparks", :github => "indirect/sparks") github_uri = "git://github.com/indirect/sparks.git" expect(subject.dependencies.first.source.uri).to eq(github_uri) end - it "should convert 'rails' to 'rails/rails'" do + it "converts numeric :gist to :git" do + subject.gem("not-really-a-gem", :gist => 2859988) + github_uri = "git://gist.github.com/2859988.git" + expect(subject.dependencies.first.source.uri).to eq(github_uri) + end + + it "converts :gist to :git" do + subject.gem("not-really-a-gem", :gist => "2859988") + github_uri = "git://gist.github.com/2859988.git" + expect(subject.dependencies.first.source.uri).to eq(github_uri) + end + + it "converts 'rails' to 'rails/rails'" do subject.gem("rails", :github => "rails") github_uri = "git://github.com/rails/rails.git" expect(subject.dependencies.first.source.uri).to eq(github_uri) end - it "should interpret slashless 'github:' value as account name" do + it "interprets slashless 'github:' value as account name" do subject.gem("bundler", :github => "carlhuda") github_uri = "git://github.com/carlhuda/bundler.git" expect(subject.dependencies.first.source.uri).to eq(github_uri) @@ -28,7 +40,7 @@ describe Bundler::Dsl do end describe '#method_missing' do - it 'should raise an error for unknown DSL methods' do + it 'raises an error for unknown DSL methods' do Bundler.should_receive(:read_file).with("Gemfile").and_return("unknown") error_msg = "Undefined local variable or method `unknown'" \ " for Gemfile\\s+from Gemfile:1" @@ -46,7 +58,7 @@ describe Bundler::Dsl do end describe "syntax errors" do - it "should raise a Bundler::GemfileError" do + it "raise a Bundler::GemfileError" do gemfile "gem 'foo', :path => /unquoted/string/syntax/error" expect { Bundler::Dsl.evaluate(bundled_app("Gemfile"), nil, true) }. to raise_error(Bundler::GemfileError) |