1
0
Fork 0
mirror of https://github.com/capistrano/capistrano synced 2023-03-27 23:21:18 -04:00

move to rspec 3

This commit is contained in:
Rustam Zagirov 2014-08-12 22:52:37 +04:00
parent b372e58ffc
commit 2c14957bf4
8 changed files with 41 additions and 40 deletions

View file

@ -5,7 +5,7 @@ gemspec
group :cucumber do group :cucumber do
gem 'cucumber' gem 'cucumber'
gem 'rspec', '~>2.14.1' gem 'rspec', '~> 3.0.0'
end end
platforms :rbx do platforms :rbx do

View file

@ -57,26 +57,26 @@ end
Then(/^the deploy\.rb file is created$/) do Then(/^the deploy\.rb file is created$/) do
file = TestApp.test_app_path.join('config/deploy.rb') file = TestApp.test_app_path.join('config/deploy.rb')
expect(File.exists?(file)).to be_true expect(File.exists?(file)).to be true
end end
Then(/^the default stage files are created$/) do Then(/^the default stage files are created$/) do
staging = TestApp.test_app_path.join('config/deploy/staging.rb') staging = TestApp.test_app_path.join('config/deploy/staging.rb')
production = TestApp.test_app_path.join('config/deploy/production.rb') production = TestApp.test_app_path.join('config/deploy/production.rb')
expect(File.exists?(staging)).to be_true expect(File.exists?(staging)).to be true
expect(File.exists?(production)).to be_true expect(File.exists?(production)).to be true
end end
Then(/^the tasks folder is created$/) do Then(/^the tasks folder is created$/) do
path = TestApp.test_app_path.join('lib/capistrano/tasks') path = TestApp.test_app_path.join('lib/capistrano/tasks')
expect(Dir.exists?(path)).to be_true expect(Dir.exists?(path)).to be true
end end
Then(/^the specified stage files are created$/) do Then(/^the specified stage files are created$/) do
qa = TestApp.test_app_path.join('config/deploy/qa.rb') qa = TestApp.test_app_path.join('config/deploy/qa.rb')
production = TestApp.test_app_path.join('config/deploy/production.rb') production = TestApp.test_app_path.join('config/deploy/production.rb')
expect(File.exists?(qa)).to be_true expect(File.exists?(qa)).to be true
expect(File.exists?(production)).to be_true expect(File.exists?(production)).to be true
end end
Then(/^it creates the file with the remote_task prerequisite$/) do Then(/^it creates the file with the remote_task prerequisite$/) do
@ -90,7 +90,7 @@ Then(/^it will not recreate the file$/) do
end end
Then(/^the task is successful$/) do Then(/^the task is successful$/) do
expect(@success).to be_true expect(@success).to be true
end end
Then(/^the failure task will run$/) do Then(/^the failure task will run$/) do

View file

@ -317,22 +317,22 @@ describe Capistrano::DSL do
context 'variable is an non-empty array' do context 'variable is an non-empty array' do
let(:linked_files) { %w{1} } let(:linked_files) { %w{1} }
it { should be_true } it { expect(subject).to be_truthy }
end end
context 'variable is an empty array' do context 'variable is an empty array' do
let(:linked_files) { [] } let(:linked_files) { [] }
it { should be_false } it { expect(subject).to be_falsey }
end end
context 'variable exists, is not an array' do context 'variable exists, is not an array' do
let(:linked_files) { stub } let(:linked_files) { stub }
it { should be_true } it { expect(subject).to be_truthy }
end end
context 'variable is nil' do context 'variable is nil' do
let(:linked_files) { nil } let(:linked_files) { nil }
it { should be_false } it { expect(subject).to be_falsey }
end end
end end
@ -368,7 +368,7 @@ describe Capistrano::DSL do
end end
it 'sets the backend pty' do it 'sets the backend pty' do
expect(backend.pty).to be_true expect(backend.pty).to be_truthy
end end
it 'sets the backend connection timeout' do it 'sets the backend connection timeout' do

View file

@ -28,7 +28,7 @@ module Capistrano
end end
it 'adds the role' do it 'adds the role' do
expect{subject}.to be_true expect(subject).to be_truthy
end end
end end
@ -37,22 +37,22 @@ module Capistrano
context 'with the same user, hostname and port' do context 'with the same user, hostname and port' do
let(:hostname) { 'root@hostname:1234' } let(:hostname) { 'root@hostname:1234' }
it { should be_true } it { expect(subject).to be_truthy }
end end
context 'with a different user' do context 'with a different user' do
let(:hostname) { 'deployer@hostname:1234' } let(:hostname) { 'deployer@hostname:1234' }
it { should be_false } it { expect(subject).to be_falsey }
end end
context 'with a different port' do context 'with a different port' do
let(:hostname) { 'root@hostname:5678' } let(:hostname) { 'root@hostname:5678' }
it { should be_false } it { expect(subject).to be_falsey }
end end
context 'with a different hostname' do context 'with a different hostname' do
let(:hostname) { 'root@otherserver:1234' } let(:hostname) { 'root@otherserver:1234' }
it { should be_false } it { expect(subject).to be_falsey }
end end
end end
@ -69,7 +69,7 @@ module Capistrano
context 'server is not primary' do context 'server is not primary' do
it 'is falesy' do it 'is falesy' do
expect(subject).to be_false expect(subject).to be_falsey
end end
end end
end end
@ -149,7 +149,7 @@ module Capistrano
end end
context 'options are empty' do context 'options are empty' do
it { should be_true } it { expect(subject).to be_truthy }
end end
context 'value is a symbol' do context 'value is a symbol' do
@ -157,34 +157,34 @@ module Capistrano
context 'with :filter' do context 'with :filter' do
let(:options) { { filter: :active }} let(:options) { { filter: :active }}
it { should be_true } it { expect(subject).to be_truthy }
end end
context 'with :select' do context 'with :select' do
let(:options) { { select: :active }} let(:options) { { select: :active }}
it { should be_true } it { expect(subject).to be_truthy }
end end
context 'with :exclude' do context 'with :exclude' do
let(:options) { { exclude: :active }} let(:options) { { exclude: :active }}
it { should be_false } it { expect(subject).to be_falsey }
end end
end end
context 'value does not match server properly' do context 'value does not match server properly' do
context 'with :filter' do context 'with :filter' do
let(:options) { { filter: :inactive }} let(:options) { { filter: :inactive }}
it { should be_false } it { expect(subject).to be_falsey }
end end
context 'with :select' do context 'with :select' do
let(:options) { { select: :inactive }} let(:options) { { select: :inactive }}
it { should be_false } it { expect(subject).to be_falsey }
end end
context 'with :exclude' do context 'with :exclude' do
let(:options) { { exclude: :inactive }} let(:options) { { exclude: :inactive }}
it { should be_true } it { expect(subject).to be_truthy }
end end
end end
end end
@ -194,17 +194,17 @@ module Capistrano
context 'with :filter' do context 'with :filter' do
let(:options) { { filter: ->(s) { s.properties.active } } } let(:options) { { filter: ->(s) { s.properties.active } } }
it { should be_true } it { expect(subject).to be_truthy }
end end
context 'with :select' do context 'with :select' do
let(:options) { { select: ->(s) { s.properties.active } } } let(:options) { { select: ->(s) { s.properties.active } } }
it { should be_true } it { expect(subject).to be_truthy }
end end
context 'with :exclude' do context 'with :exclude' do
let(:options) { { exclude: ->(s) { s.properties.active } } } let(:options) { { exclude: ->(s) { s.properties.active } } }
it { should be_false } it { expect(subject).to be_falsey }
end end
end end
@ -212,17 +212,17 @@ module Capistrano
context 'value does not match server properly' do context 'value does not match server properly' do
context 'with :filter' do context 'with :filter' do
let(:options) { { filter: ->(s) { s.properties.inactive } } } let(:options) { { filter: ->(s) { s.properties.inactive } } }
it { should be_false } it { expect(subject).to be_falsey }
end end
context 'with :select' do context 'with :select' do
let(:options) { { select: ->(s) { s.properties.inactive } } } let(:options) { { select: ->(s) { s.properties.inactive } } }
it { should be_false } it { expect(subject).to be_falsey }
end end
context 'with :exclude' do context 'with :exclude' do
let(:options) { { exclude: ->(s) { s.properties.inactive } } } let(:options) { { exclude: ->(s) { s.properties.inactive } } }
it { should be_true } it { expect(subject).to be_truthy }
end end
end end

View file

@ -8,7 +8,7 @@ module Capistrano
describe '.env' do describe '.env' do
it 'is a global accessor to a single instance' do it 'is a global accessor to a single instance' do
Configuration.env.set(:test, true) Configuration.env.set(:test, true)
expect(Configuration.env.fetch(:test)).to be_true expect(Configuration.env.fetch(:test)).to be_truthy
end end
end end

View file

@ -27,14 +27,14 @@ module Capistrano
before do before do
dsl.set(:stage, :sandbox) dsl.set(:stage, :sandbox)
end end
it { should be_true } it { expect(subject).to be_truthy }
end end
context 'stage is not set' do context 'stage is not set' do
before do before do
dsl.set(:stage, nil) dsl.set(:stage, nil)
end end
it { should be_false } it { expect(subject).to be_falsey }
end end
end end

View file

@ -24,7 +24,7 @@ module Capistrano
context 'with exact version' do context 'with exact version' do
context 'valid' do context 'valid' do
let(:version) { '3.0.1' } let(:version) { '3.0.1' }
it { should be_true } it { expect(subject).to be_truthy }
end end
context 'invalid - lower' do context 'invalid - lower' do
@ -48,7 +48,7 @@ module Capistrano
context 'with optimistic versioning' do context 'with optimistic versioning' do
context 'valid' do context 'valid' do
let(:version) { '>= 3.0.0' } let(:version) { '>= 3.0.0' }
it { should be_true } it { expect(subject).to be_truthy }
end end
context 'invalid - lower' do context 'invalid - lower' do
@ -66,7 +66,7 @@ module Capistrano
context '2 decimal places' do context '2 decimal places' do
context 'valid' do context 'valid' do
let(:version) { '~> 3.0.0' } let(:version) { '~> 3.0.0' }
it { should be_true } it { expect(subject).to be_truthy }
end end
context 'invalid' do context 'invalid' do
@ -83,7 +83,7 @@ module Capistrano
context 'valid' do context 'valid' do
let(:version) { '~> 3.1' } let(:version) { '~> 3.1' }
it { should be_true } it { expect(subject).to be_truthy }
end end
context 'invalid' do context 'invalid' do

View file

@ -3,13 +3,14 @@ $LOAD_PATH.unshift(File.dirname(__FILE__))
require 'capistrano/all' require 'capistrano/all'
require 'rspec' require 'rspec'
require 'mocha/api' require 'mocha/api'
require 'time'
# Requires supporting files with custom matchers and macros, etc, # Requires supporting files with custom matchers and macros, etc,
# in ./support/ and its subdirectories. # in ./support/ and its subdirectories.
Dir['#{File.dirname(__FILE__)}/support/**/*.rb'].each {|f| require f} Dir['#{File.dirname(__FILE__)}/support/**/*.rb'].each {|f| require f}
RSpec.configure do |config| RSpec.configure do |config|
config.treat_symbols_as_metadata_keys_with_true_values = true config.raise_errors_for_deprecations!
config.mock_framework = :mocha config.mock_framework = :mocha
config.order = 'random' config.order = 'random'
end end