From 2c14957bf4ee6e99ec4069b3c70c6400135cdec8 Mon Sep 17 00:00:00 2001 From: Rustam Zagirov Date: Tue, 12 Aug 2014 22:52:37 +0400 Subject: [PATCH] move to rspec 3 --- Gemfile | 2 +- features/step_definitions/assertions.rb | 14 +++---- spec/integration/dsl_spec.rb | 10 ++--- .../capistrano/configuration/server_spec.rb | 38 +++++++++---------- spec/lib/capistrano/configuration_spec.rb | 2 +- spec/lib/capistrano/dsl_spec.rb | 4 +- spec/lib/capistrano/version_validator_spec.rb | 8 ++-- spec/spec_helper.rb | 3 +- 8 files changed, 41 insertions(+), 40 deletions(-) diff --git a/Gemfile b/Gemfile index f0faa798..f9e2dab8 100644 --- a/Gemfile +++ b/Gemfile @@ -5,7 +5,7 @@ gemspec group :cucumber do gem 'cucumber' - gem 'rspec', '~>2.14.1' + gem 'rspec', '~> 3.0.0' end platforms :rbx do diff --git a/features/step_definitions/assertions.rb b/features/step_definitions/assertions.rb index b16ba2e5..a8323da4 100644 --- a/features/step_definitions/assertions.rb +++ b/features/step_definitions/assertions.rb @@ -57,26 +57,26 @@ end Then(/^the deploy\.rb file is created$/) do file = TestApp.test_app_path.join('config/deploy.rb') - expect(File.exists?(file)).to be_true + expect(File.exists?(file)).to be true end Then(/^the default stage files are created$/) do staging = TestApp.test_app_path.join('config/deploy/staging.rb') production = TestApp.test_app_path.join('config/deploy/production.rb') - expect(File.exists?(staging)).to be_true - expect(File.exists?(production)).to be_true + expect(File.exists?(staging)).to be true + expect(File.exists?(production)).to be true end Then(/^the tasks folder is created$/) do path = TestApp.test_app_path.join('lib/capistrano/tasks') - expect(Dir.exists?(path)).to be_true + expect(Dir.exists?(path)).to be true end Then(/^the specified stage files are created$/) do qa = TestApp.test_app_path.join('config/deploy/qa.rb') production = TestApp.test_app_path.join('config/deploy/production.rb') - expect(File.exists?(qa)).to be_true - expect(File.exists?(production)).to be_true + expect(File.exists?(qa)).to be true + expect(File.exists?(production)).to be true end Then(/^it creates the file with the remote_task prerequisite$/) do @@ -90,7 +90,7 @@ Then(/^it will not recreate the file$/) do end Then(/^the task is successful$/) do - expect(@success).to be_true + expect(@success).to be true end Then(/^the failure task will run$/) do diff --git a/spec/integration/dsl_spec.rb b/spec/integration/dsl_spec.rb index ca21f13d..741a3a86 100644 --- a/spec/integration/dsl_spec.rb +++ b/spec/integration/dsl_spec.rb @@ -317,22 +317,22 @@ describe Capistrano::DSL do context 'variable is an non-empty array' do let(:linked_files) { %w{1} } - it { should be_true } + it { expect(subject).to be_truthy } end context 'variable is an empty array' do let(:linked_files) { [] } - it { should be_false } + it { expect(subject).to be_falsey } end context 'variable exists, is not an array' do let(:linked_files) { stub } - it { should be_true } + it { expect(subject).to be_truthy } end context 'variable is nil' do let(:linked_files) { nil } - it { should be_false } + it { expect(subject).to be_falsey } end end @@ -368,7 +368,7 @@ describe Capistrano::DSL do end it 'sets the backend pty' do - expect(backend.pty).to be_true + expect(backend.pty).to be_truthy end it 'sets the backend connection timeout' do diff --git a/spec/lib/capistrano/configuration/server_spec.rb b/spec/lib/capistrano/configuration/server_spec.rb index 0d7a719f..09ceb4fd 100644 --- a/spec/lib/capistrano/configuration/server_spec.rb +++ b/spec/lib/capistrano/configuration/server_spec.rb @@ -28,7 +28,7 @@ module Capistrano end it 'adds the role' do - expect{subject}.to be_true + expect(subject).to be_truthy end end @@ -37,22 +37,22 @@ module Capistrano context 'with the same user, hostname and port' do let(:hostname) { 'root@hostname:1234' } - it { should be_true } + it { expect(subject).to be_truthy } end context 'with a different user' do let(:hostname) { 'deployer@hostname:1234' } - it { should be_false } + it { expect(subject).to be_falsey } end context 'with a different port' do let(:hostname) { 'root@hostname:5678' } - it { should be_false } + it { expect(subject).to be_falsey } end context 'with a different hostname' do let(:hostname) { 'root@otherserver:1234' } - it { should be_false } + it { expect(subject).to be_falsey } end end @@ -69,7 +69,7 @@ module Capistrano context 'server is not primary' do it 'is falesy' do - expect(subject).to be_false + expect(subject).to be_falsey end end end @@ -149,7 +149,7 @@ module Capistrano end context 'options are empty' do - it { should be_true } + it { expect(subject).to be_truthy } end context 'value is a symbol' do @@ -157,34 +157,34 @@ module Capistrano context 'with :filter' do let(:options) { { filter: :active }} - it { should be_true } + it { expect(subject).to be_truthy } end context 'with :select' do let(:options) { { select: :active }} - it { should be_true } + it { expect(subject).to be_truthy } end context 'with :exclude' do let(:options) { { exclude: :active }} - it { should be_false } + it { expect(subject).to be_falsey } end end context 'value does not match server properly' do context 'with :filter' do let(:options) { { filter: :inactive }} - it { should be_false } + it { expect(subject).to be_falsey } end context 'with :select' do let(:options) { { select: :inactive }} - it { should be_false } + it { expect(subject).to be_falsey } end context 'with :exclude' do let(:options) { { exclude: :inactive }} - it { should be_true } + it { expect(subject).to be_truthy } end end end @@ -194,17 +194,17 @@ module Capistrano context 'with :filter' do let(:options) { { filter: ->(s) { s.properties.active } } } - it { should be_true } + it { expect(subject).to be_truthy } end context 'with :select' do let(:options) { { select: ->(s) { s.properties.active } } } - it { should be_true } + it { expect(subject).to be_truthy } end context 'with :exclude' do let(:options) { { exclude: ->(s) { s.properties.active } } } - it { should be_false } + it { expect(subject).to be_falsey } end end @@ -212,17 +212,17 @@ module Capistrano context 'value does not match server properly' do context 'with :filter' do let(:options) { { filter: ->(s) { s.properties.inactive } } } - it { should be_false } + it { expect(subject).to be_falsey } end context 'with :select' do let(:options) { { select: ->(s) { s.properties.inactive } } } - it { should be_false } + it { expect(subject).to be_falsey } end context 'with :exclude' do let(:options) { { exclude: ->(s) { s.properties.inactive } } } - it { should be_true } + it { expect(subject).to be_truthy } end end diff --git a/spec/lib/capistrano/configuration_spec.rb b/spec/lib/capistrano/configuration_spec.rb index 718f6046..4b03fe7b 100644 --- a/spec/lib/capistrano/configuration_spec.rb +++ b/spec/lib/capistrano/configuration_spec.rb @@ -8,7 +8,7 @@ module Capistrano describe '.env' do it 'is a global accessor to a single instance' do Configuration.env.set(:test, true) - expect(Configuration.env.fetch(:test)).to be_true + expect(Configuration.env.fetch(:test)).to be_truthy end end diff --git a/spec/lib/capistrano/dsl_spec.rb b/spec/lib/capistrano/dsl_spec.rb index 9d244218..12e4391e 100644 --- a/spec/lib/capistrano/dsl_spec.rb +++ b/spec/lib/capistrano/dsl_spec.rb @@ -27,14 +27,14 @@ module Capistrano before do dsl.set(:stage, :sandbox) end - it { should be_true } + it { expect(subject).to be_truthy } end context 'stage is not set' do before do dsl.set(:stage, nil) end - it { should be_false } + it { expect(subject).to be_falsey } end end diff --git a/spec/lib/capistrano/version_validator_spec.rb b/spec/lib/capistrano/version_validator_spec.rb index 64385815..a0a42c09 100644 --- a/spec/lib/capistrano/version_validator_spec.rb +++ b/spec/lib/capistrano/version_validator_spec.rb @@ -24,7 +24,7 @@ module Capistrano context 'with exact version' do context 'valid' do let(:version) { '3.0.1' } - it { should be_true } + it { expect(subject).to be_truthy } end context 'invalid - lower' do @@ -48,7 +48,7 @@ module Capistrano context 'with optimistic versioning' do context 'valid' do let(:version) { '>= 3.0.0' } - it { should be_true } + it { expect(subject).to be_truthy } end context 'invalid - lower' do @@ -66,7 +66,7 @@ module Capistrano context '2 decimal places' do context 'valid' do let(:version) { '~> 3.0.0' } - it { should be_true } + it { expect(subject).to be_truthy } end context 'invalid' do @@ -83,7 +83,7 @@ module Capistrano context 'valid' do let(:version) { '~> 3.1' } - it { should be_true } + it { expect(subject).to be_truthy } end context 'invalid' do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index dab66ed6..9e4e1b3b 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -3,13 +3,14 @@ $LOAD_PATH.unshift(File.dirname(__FILE__)) require 'capistrano/all' require 'rspec' require 'mocha/api' +require 'time' # Requires supporting files with custom matchers and macros, etc, # in ./support/ and its subdirectories. Dir['#{File.dirname(__FILE__)}/support/**/*.rb'].each {|f| require f} RSpec.configure do |config| - config.treat_symbols_as_metadata_keys_with_true_values = true + config.raise_errors_for_deprecations! config.mock_framework = :mocha config.order = 'random' end