Skip to content

Commit

Permalink
fix git user.name mocking to work on travis
Browse files Browse the repository at this point in the history
  • Loading branch information
ronen committed Feb 11, 2015
1 parent 6c250c4 commit 7d3d78c
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions spec/gem_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,15 @@
end
end

context "builds" do
Given(:user_name) { "My Name" }
Given(:user_email) { "my_name@example.com" }

Given {
allow_any_instance_of(SchemaDev::Gem).to receive(:`).with("git config user.name").and_return user_name
allow_any_instance_of(SchemaDev::Gem).to receive(:`).with("git config user.email").and_return user_email
}

Given(:user_name) { "My Name" }
Given(:user_email) { "my_name@example.com" }
context "builds" do

Given {
stub_request(:get, 'https://rubygems.org/api/v1/versions/schema_plus_core.json').to_return body: JSON.generate([
Expand All @@ -24,8 +29,6 @@
{ number: "0.1.2"},
{ number: "0.1.1" },
])
allow_any_instance_of(SchemaDev::Gem).to receive(:`).with("git config user.name").and_return user_name
allow_any_instance_of(SchemaDev::Gem).to receive(:`).with("git config user.email").and_return user_email
}

When { SchemaDev::Gem.build gem_name }
Expand Down Expand Up @@ -53,7 +56,7 @@
context "complains" do

context "when no git user.name" do
Given { allow_any_instance_of(SchemaDev::Gem).to receive(:`).with("git config user.name").and_return "" }
Given(:user_name) { "" }
Then { expect{SchemaDev::Gem.build("NewGem")}.to raise_error SystemExit, /who are you/i }
end

Expand Down

0 comments on commit 7d3d78c

Please sign in to comment.