From 6610f83335662093ed0eec78d0c2fb04c731ced9 Mon Sep 17 00:00:00 2001 From: Dmitrii Golub Date: Wed, 16 Jul 2014 18:52:56 +0400 Subject: [PATCH] update rspec to version 3 --- spec/controllers/two_factor_auth_spec.rb | 8 +++----- spec/features/two_factor_authenticatable_spec.rb | 4 ++-- .../models/two_factor_authenticatable_spec.rb | 12 ++++++------ spec/spec_helper.rb | 3 ++- two_factor_authentication.gemspec | 4 ++-- 5 files changed, 15 insertions(+), 16 deletions(-) diff --git a/spec/controllers/two_factor_auth_spec.rb b/spec/controllers/two_factor_auth_spec.rb index 7c331f5..b8d91ff 100644 --- a/spec/controllers/two_factor_auth_spec.rb +++ b/spec/controllers/two_factor_auth_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' include Warden::Test::Helpers -describe HomeController do +describe HomeController, :type => :controller do context "passed only 1st factor auth" do let(:user) { create_user } @@ -11,10 +11,8 @@ describe HomeController do login_as user, scope: :user visit user_two_factor_authentication_path - - controller.is_fully_authenticated?.should be_true + expect(controller.is_fully_authenticated?).to be_truthy end end - end -end \ No newline at end of file +end diff --git a/spec/features/two_factor_authenticatable_spec.rb b/spec/features/two_factor_authenticatable_spec.rb index ee45c0d..9b3ef7d 100644 --- a/spec/features/two_factor_authenticatable_spec.rb +++ b/spec/features/two_factor_authenticatable_spec.rb @@ -11,14 +11,14 @@ feature "User of two factor authentication" do end scenario "sends two factor authentication code after sign in" do - SMSProvider.messages.should be_empty + expect(SMSProvider.messages).to be_empty visit new_user_session_path complete_sign_in_form_for(user) expect(page).to have_content "Enter your personal code" - SMSProvider.messages.size.should eq(1) + expect(SMSProvider.messages.size).to eq(1) message = SMSProvider.last_message expect(message.to).to eq(user.phone_number) expect(message.body).to eq(user.otp_code) diff --git a/spec/lib/two_factor_authentication/models/two_factor_authenticatable_spec.rb b/spec/lib/two_factor_authentication/models/two_factor_authenticatable_spec.rb index 014a432..c5f1154 100644 --- a/spec/lib/two_factor_authentication/models/two_factor_authenticatable_spec.rb +++ b/spec/lib/two_factor_authentication/models/two_factor_authenticatable_spec.rb @@ -146,19 +146,19 @@ describe Devise::Models::TwoFactorAuthenticatable, '#max_login_attempts' do it "returns false as boolean" do instance.second_factor_attempts_count = nil - expect(instance.max_login_attempts?).to be_false + expect(instance.max_login_attempts?).to be_falsey instance.second_factor_attempts_count = 0 - expect(instance.max_login_attempts?).to be_false + expect(instance.max_login_attempts?).to be_falsey instance.second_factor_attempts_count = 1 - expect(instance.max_login_attempts?).to be_false + expect(instance.max_login_attempts?).to be_falsey instance.second_factor_attempts_count = 2 - expect(instance.max_login_attempts?).to be_false + expect(instance.max_login_attempts?).to be_falsey end it "returns true as boolean after too many attempts" do instance.second_factor_attempts_count = 3 - expect(instance.max_login_attempts?).to be_true + expect(instance.max_login_attempts?).to be_truthy instance.second_factor_attempts_count = 4 - expect(instance.max_login_attempts?).to be_true + expect(instance.max_login_attempts?).to be_truthy end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 07f08df..bed93aa 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -5,12 +5,13 @@ require 'rspec/rails' # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration RSpec.configure do |config| - config.treat_symbols_as_metadata_keys_with_true_values = true config.run_all_when_everything_filtered = true config.filter_run :focus config.use_transactional_examples = true + config.include Capybara::DSL + # Run specs in random order to surface order dependencies. If you find an # order dependency and want to debug it, you can fix the order by providing # the seed, which is printed after each run. diff --git a/two_factor_authentication.gemspec b/two_factor_authentication.gemspec index 55e89d0..32bbba3 100644 --- a/two_factor_authentication.gemspec +++ b/two_factor_authentication.gemspec @@ -31,7 +31,7 @@ Gem::Specification.new do |s| s.add_development_dependency 'bundler' s.add_development_dependency 'rake' - s.add_development_dependency 'rspec-rails' - s.add_development_dependency 'capybara' + s.add_development_dependency 'rspec-rails', '>= 3.0.1' + s.add_development_dependency 'capybara', '2.4.1' s.add_development_dependency 'pry' end