Skip to content
This repository has been archived by the owner on Jun 8, 2019. It is now read-only.

Commit

Permalink
Cleanup and whitespace.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabe Berke-Williams committed Sep 9, 2011
1 parent afb29cf commit fda26ee
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 42 deletions.
2 changes: 1 addition & 1 deletion lib/kumade/cli.rb
Expand Up @@ -7,7 +7,7 @@ class << self
attr_reader :environment
end

def self.run(args=ARGV, out=StringIO.new)
def self.run(args = ARGV, out = StringIO.new)
@out = out
@options = parse_arguments!(args)
@environment = args.shift || 'staging'
Expand Down
34 changes: 18 additions & 16 deletions spec/kumade/cli_spec.rb
@@ -1,9 +1,10 @@
require 'spec_helper'

describe Kumade::CLI do
let(:out) { StringIO.new }
let(:environment) { 'my-environment' }

subject { Kumade::CLI }
let(:out){ StringIO.new }
let(:environment){ 'my-environment' }

%w(-p --pretend).each do |pretend_arg|
it "sets pretend mode when run with #{pretend_arg}" do
Expand All @@ -23,16 +24,16 @@
it "deploys" do
Kumade::Deployer.any_instance.should_receive(:deploy)

subject.run([environment], out)
subject.run
end

end

describe Kumade::CLI do
describe Kumade::CLI, ".swapping_stdout_for" do
let(:stdout) { $stdout }
let(:output) { StringIO.new }

it 'does not let anything get printed' do
stdout = $stdout
stdout.should_not_receive(:print)
output = StringIO.new

Kumade::CLI.swapping_stdout_for(output) do
$stdout.puts "Hello, you can't see me."
Expand All @@ -43,24 +44,25 @@
end

it 'dumps the output stash to real stdout when an error happens' do
stdout = $stdout
stdout.should_receive(:print)
output = StringIO.new

Kumade::CLI.swapping_stdout_for(output) do
$stdout.puts "Hello, you can see me!"
raise Kumade::DeploymentError.new("error")
end
end

it 'prints everything in pretend mode' do
stdout = $stdout
stdout.should_receive(:puts)
output = StringIO.new
Kumade::CLI.should_receive(:pretending?).and_return(true)
context "in pretend mode" do
before do
Kumade::CLI.should_receive(:pretending?).and_return(true)
end

Kumade::CLI.swapping_stdout_for(output) do
$stdout.puts "Hello, you can see me!"
it 'prints everything' do
stdout.should_receive(:puts)

Kumade::CLI.swapping_stdout_for(output) do
$stdout.puts "Hello, you can see me!"
end
end
end
end
5 changes: 2 additions & 3 deletions spec/kumade/deployer_spec.rb
Expand Up @@ -346,12 +346,12 @@ class More
Rake::Task.clear
end

it "returns true if it task found" do
it "returns true if the task exists" do
namespace :kumade do
task :before_asset_compilation do

end
end

Kumade::Deployer.new.custom_task?.should be_true
end

Expand Down Expand Up @@ -404,7 +404,6 @@ class More
end
end


context "when the remote does not exist" do
subject { Kumade::Deployer.new(environment) }
before { remove_remote(environment) }
Expand Down
43 changes: 21 additions & 22 deletions spec/kumade/git_spec.rb
Expand Up @@ -27,7 +27,6 @@
it "returns false when the remote is not a heroku repository" do
Kumade::Git.new(false, 'kumade').heroku_remote?.should be_false
end

end

describe Kumade::Git, ".environments" do
Expand All @@ -51,39 +50,39 @@
end

describe Kumade::Git, "#branch_exist?" do
let(:comand_line_mock) { mock("Cocaine::CommandLine") }
let(:branch) { "branch" }
let(:environment) { "staging" }
let(:command_line_mock) { mock("Cocaine::CommandLine") }
let(:branch) { "branch" }
let(:environment) { "staging" }

subject { Kumade::Git.new(false, environment) }

before(:each) do
Cocaine::CommandLine.should_receive(:new).with("git show-ref #{branch}").and_return(comand_line_mock)
before do
Cocaine::CommandLine.should_receive(:new).with("git show-ref #{branch}").and_return(command_line_mock)
end
it "should return true when branch exist" do
comand_line_mock.should_receive(:run)

it "returns true when the branch exists" do
command_line_mock.should_receive(:run)
subject.branch_exist?("branch").should be_true
end
it "should return false if branch doesn't exist" do
comand_line_mock.should_receive(:run).and_raise(Cocaine::ExitStatusError)

it "returns false if the branch doesn't exist" do
command_line_mock.should_receive(:run).and_raise(Cocaine::ExitStatusError)
subject.branch_exist?("branch").should be_false
end
end

describe Kumade::Git, "#dirty?" do
let(:environment) { "staging" }

subject { Kumade::Git.new(false, environment) }
subject { Kumade::Git.new(false, "staging") }

it "should return true when dirty" do
it "returns true when dirty" do
subject.should_receive(:run).with("git diff --exit-code").and_return(false)
subject.dirty?.should be_true

subject.should be_dirty
end
it "should return false when not dirty" do

it "returns false when not dirty" do
subject.should_receive(:run).with("git diff --exit-code").and_return(true)
subject.dirty?.should be_false

subject.should_not be_dirty
end
end
end

0 comments on commit fda26ee

Please sign in to comment.