Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert specs to RSpec expect syntax with transpec #194

Merged
merged 1 commit into from
Jul 7, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion spec/command_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def mina(*args)
puts stderr
end

exitstatus.should == 0
expect(exitstatus).to eq(0)
end

def stdout
Expand Down
2 changes: 1 addition & 1 deletion spec/commands/cleanup_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@

mina 'deploy:cleanup'

Dir["deploy/releases/*"].length.should == 2
expect(Dir["deploy/releases/*"].length).to eq(2)
end
end
36 changes: 18 additions & 18 deletions spec/commands/command_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,24 @@

it "should think it's 'mina', not 'rake' (1)" do
run_command 'pinkledills'
exitstatus.should_not == 0
stderr.should include 'mina aborted'
expect(exitstatus).not_to eq(0)
expect(stderr).to include 'mina aborted'
end

it "should think it's 'mina', not 'rake' (1)" do
mina '-T'
stdout.should include 'mina help'
stdout.should include 'mina git:clone'
expect(stdout).to include 'mina help'
expect(stdout).to include 'mina git:clone'
end

it 'with --version should print the version' do
mina '--version'
stdout.should include Mina.version
expect(stdout).to include Mina.version
end

it 'with -V should print the version' do
mina '-V'
stdout.should include Mina.version
expect(stdout).to include Mina.version
end

describe 'without arguments' do
Expand All @@ -35,37 +35,37 @@

it 'should print standard help tasks' do
mina
stdout.should include 'mina help'
stdout.should include 'mina init'
stdout.should include 'mina tasks'
expect(stdout).to include 'mina help'
expect(stdout).to include 'mina init'
expect(stdout).to include 'mina tasks'
end

it 'should print project-specific tasks' do
mina
stdout.should include 'mina deploy'
stdout.should include 'mina restart'
stdout.should include 'mina setup'
expect(stdout).to include 'mina deploy'
expect(stdout).to include 'mina restart'
expect(stdout).to include 'mina setup'
end

it "should be the same as running 'help'" do
previous_out = stdout

mina 'help'
stdout.should == previous_out
expect(stdout).to eq(previous_out)
end
end

it "with 'mina -f' on a non-existing file should fail" do
run_command '-f', 'foobar'
stderr.should include 'mina aborted'
stderr.should include 'No Rakefile found'
expect(stderr).to include 'mina aborted'
expect(stderr).to include 'No Rakefile found'
end

it "with 'mina tasks' should print tasks" do
mina 'tasks'

stdout.should include('bundle:install')
stdout.should include('Install gem dependencies using Bundler')
stdout.should include('passenger:restart')
expect(stdout).to include('bundle:install')
expect(stdout).to include('Install gem dependencies using Bundler')
expect(stdout).to include('passenger:restart')
end
end
4 changes: 2 additions & 2 deletions spec/commands/custom_config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@

it 'should fail' do
run_command 'deploy', '--simulate'
exitstatus.should be > 0
expect(exitstatus).to be > 0
end

it 'should pass if you provide a new rakefile' do
mina 'deploy', '--simulate', '-f', 'custom_deploy.rb'
stdout.should include 'Creating a temporary build path'
expect(stdout).to include 'Creating a temporary build path'
end
end

14 changes: 7 additions & 7 deletions spec/commands/deploy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,25 @@
end

it "should take care of the lockfile" do
stdout.should =~ /ERROR: another deployment is ongoing/
stdout.should =~ /touch ".*deploy\.lock"/
stdout.should =~ /rm -f ".*deploy\.lock"/
expect(stdout).to match(/ERROR: another deployment is ongoing/)
expect(stdout).to match(/touch ".*deploy\.lock"/)
expect(stdout).to match(/rm -f ".*deploy\.lock"/)
end

it "should honor releases_path" do
stdout.should include "releases/"
expect(stdout).to include "releases/"
end

it "should symlink the current_path" do
stdout.should =~ /ln .*current/
expect(stdout).to match(/ln .*current/)
end

it "should include deploy directives" do
stdout.should include "bundle exec rake db:migrate"
expect(stdout).to include "bundle exec rake db:migrate"
end

it "should include 'to :launch' directives" do
stdout.should include "touch tmp/restart.txt"
expect(stdout).to include "touch tmp/restart.txt"
end
end
end
14 changes: 7 additions & 7 deletions spec/commands/outside_project_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@
end

it 'should print standard help tasks' do
stdout.should include('mina help')
stdout.should include('mina init')
stdout.should include('mina tasks')
expect(stdout).to include('mina help')
expect(stdout).to include('mina init')
expect(stdout).to include('mina tasks')
end

it "should not print project-specific tasks" do
stdout.should_not include('mina deploy')
stdout.should_not include('mina restart')
stdout.should_not include('mina setup')
expect(stdout).not_to include('mina deploy')
expect(stdout).not_to include('mina restart')
expect(stdout).not_to include('mina setup')
end

%w[-h --help].each do |arg|
it "should have the same output as 'mina #{arg}'" do
@previous_output = stdout
mina arg
stdout.should == @previous_output
expect(stdout).to eq(@previous_output)
end
end
end
Expand Down
42 changes: 21 additions & 21 deletions spec/commands/real_deploy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,33 +21,33 @@
it 'should set up and deploy fine' do
print "[setup]" if ENV['verbose']
mina 'setup', '--verbose'
File.directory?('deploy').should be_true
File.directory?('deploy/releases').should be_true
File.directory?('deploy/shared').should be_true
File.exists?('deploy/last_version').should be_false
File.exists?('deploy/deploy.lock').should be_false
expect(File.directory?('deploy')).to be_true
expect(File.directory?('deploy/releases')).to be_true
expect(File.directory?('deploy/shared')).to be_true
expect(File.exists?('deploy/last_version')).to be_false
expect(File.exists?('deploy/deploy.lock')).to be_false

print "[deploy 1]" if ENV['verbose']
mina 'deploy', '--verbose'
stdout.should include "-----> Creating a temporary build path"
stdout.should include "rm -rf .git"
stdout.should include "mkdir -p"
File.exists?('deploy/last_version').should be_true
File.exists?('deploy/deploy.lock').should be_false
File.directory?('deploy/releases').should be_true
File.directory?('deploy/releases/1').should be_true
File.exists?('deploy/releases/1/README.md').should be_true
File.directory?('deploy/releases/2').should be_false
File.exists?('deploy/current').should be_true
File.read('deploy/last_version').strip.should == '1'
File.exists?('deploy/current/tmp/restart.txt').should be_true
expect(stdout).to include "-----> Creating a temporary build path"
expect(stdout).to include "rm -rf .git"
expect(stdout).to include "mkdir -p"
expect(File.exists?('deploy/last_version')).to be_true
expect(File.exists?('deploy/deploy.lock')).to be_false
expect(File.directory?('deploy/releases')).to be_true
expect(File.directory?('deploy/releases/1')).to be_true
expect(File.exists?('deploy/releases/1/README.md')).to be_true
expect(File.directory?('deploy/releases/2')).to be_false
expect(File.exists?('deploy/current')).to be_true
expect(File.read('deploy/last_version').strip).to eq('1')
expect(File.exists?('deploy/current/tmp/restart.txt')).to be_true

# And again, to test out sequential versions and stuff
print "[deploy 2]" if ENV['verbose']
mina 'deploy'
stdout.should_not include "rm -rf .git"
stdout.should_not include "mkdir -p"
File.directory?('deploy/releases/2').should be_true
File.read('deploy/last_version').strip.should == '2'
expect(stdout).not_to include "rm -rf .git"
expect(stdout).not_to include "mkdir -p"
expect(File.directory?('deploy/releases/2')).to be_true
expect(File.read('deploy/last_version').strip).to eq('2')
end
end
4 changes: 2 additions & 2 deletions spec/commands/verbose_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
it 'should echo commands in verbose mode' do
mina 'deploy', '--verbose', '--simulate'

stdout.should include %[echo #{Shellwords.escape('$ git')}]
expect(stdout).to include %[echo #{Shellwords.escape('$ git')}]
end

it 'should not echo commands when not in verbose mode' do
mina 'deploy', '--simulate'

stdout.should_not include %[echo #{Shellwords.escape('$ git')}]
expect(stdout).not_to include %[echo #{Shellwords.escape('$ git')}]
end
end
4 changes: 2 additions & 2 deletions spec/dsl/invoke_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
rake { invoke :clone }
}

rake.commands.should == ['git clone']
expect(rake.commands).to eq(['git clone'])
end

it '#invoke should work with :reenable option' do
Expand All @@ -28,6 +28,6 @@
rake { invoke :pull, :reenable => true }
}

rake.commands.should == ['git pull', 'git pull']
expect(rake.commands).to eq(['git pull', 'git pull'])
end
end
8 changes: 4 additions & 4 deletions spec/dsl/queue_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
end
invoke :hello
}
rake.instance_variable_get(:@hello).should == 'world'
expect(rake.instance_variable_get(:@hello)).to eq('world')
end

it '#queue should work' do
rake {
queue 'sudo service nginx restart'
}

rake.commands.should == ['sudo service nginx restart']
expect(rake.commands).to eq(['sudo service nginx restart'])
end

it '#queue should work with multiple commands' do
Expand All @@ -25,7 +25,7 @@
queue 'sudo service nginx restart'
}

rake.commands.should == ['echo Restarting', 'sudo service nginx restart']
expect(rake.commands).to eq(['echo Restarting', 'sudo service nginx restart'])
end

it '#queue should work inside tasks' do
Expand All @@ -44,6 +44,6 @@

rake { invoke :restart }

rake.commands.should == ['echo Restarting', 'touch tmp/restart.txt']
expect(rake.commands).to eq(['echo Restarting', 'touch tmp/restart.txt'])
end
end
12 changes: 6 additions & 6 deletions spec/dsl/settings_in_rake_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
it '#set should work' do
rake { set :domain, 'localhost' }

rake.domain.should == 'localhost'
rake.settings.domain.should == 'localhost'
expect(rake.domain).to eq('localhost')
expect(rake.settings.domain).to eq('localhost')
end

it '#settings ||= should work' do
Expand All @@ -14,8 +14,8 @@
settings.version ||= '3'
}

rake.settings.version.should == '2'
rake.version.should == '2'
expect(rake.settings.version).to eq('2')
expect(rake.version).to eq('2')
end

it '#settings with lambdas should work' do
Expand All @@ -24,8 +24,8 @@
set :path, lambda { "/var/www/#{version}" }
}

rake.path.should == "/var/www/42"
rake.path?.should be_true
expect(rake.path).to eq("/var/www/42")
expect(rake.path?).to be_true
end

it '#settings with a bang should work' do
Expand Down
20 changes: 10 additions & 10 deletions spec/dsl/settings_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,38 +8,38 @@

it 'setting/getting should work' do
@settings.domain = '192.168.1.1'
@settings.domain.should == '192.168.1.1'
expect(@settings.domain).to eq('192.168.1.1')
end

it 'question mark should work' do
@settings.deploy_to = '/var/www/there'
@settings.deploy_to?.should be_true
@settings.foobar?.should be_false
expect(@settings.deploy_to?).to be_true
expect(@settings.foobar?).to be_false
end

it 'question mark should work with nils' do
@settings.deploy_to = nil
@settings.deploy_to?.should be_true
@settings.foobar?.should be_false
expect(@settings.deploy_to?).to be_true
expect(@settings.foobar?).to be_false
end

it '||= should work (1)' do
@settings.x = 2
@settings.x ||= 3
@settings.x.should == 2
expect(@settings.x).to eq(2)
end

it '||= should work (2)' do
@settings.x ||= 3
@settings.x.should == 3
expect(@settings.x).to eq(3)
end

it 'lambdas should work' do
@settings.path = lambda { "/var/www/#{@settings.version}" }
@settings.version = '3'

@settings.path?.should be_true
@settings.path.should == "/var/www/3"
expect(@settings.path?).to be_true
expect(@settings.path).to eq("/var/www/3")
end

it 'bangs should check for settings' do
Expand All @@ -48,7 +48,7 @@

it 'bangs should return settings' do
@settings.version = 4
@settings.version!.should == 4
expect(@settings.version!).to eq(4)
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/dsl/to_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

rake { invoke :deploy }

rake.commands.should == ['git clone']
rake.commands(:restart).should == ['touch tmp/restart.txt']
expect(rake.commands).to eq(['git clone'])
expect(rake.commands(:restart)).to eq(['touch tmp/restart.txt'])
end
end