Browse Source

update rspec to version 3

master
Dmitrii Golub 11 years ago
parent
commit
6610f83335
  1. 8
      spec/controllers/two_factor_auth_spec.rb
  2. 4
      spec/features/two_factor_authenticatable_spec.rb
  3. 12
      spec/lib/two_factor_authentication/models/two_factor_authenticatable_spec.rb
  4. 3
      spec/spec_helper.rb
  5. 4
      two_factor_authentication.gemspec

8
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
end

4
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)

12
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

3
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.

4
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

Loading…
Cancel
Save