Browse Source

SmsProvider class naming

get_specs_running
baarkerlounger 3 years ago
parent
commit
d415a7c8c3
  1. 14
      spec/features/two_factor_authenticatable_spec.rb
  2. 2
      spec/rails_app/app/models/user.rb
  3. 2
      spec/rails_app/lib/sms_provider.rb
  4. 2
      spec/support/sms_provider.rb

14
spec/features/two_factor_authenticatable_spec.rb

@ -12,7 +12,7 @@ feature "User of two factor authentication" do
end
it 'does not send an SMS before the user has signed in' do
expect(SMSProvider.messages).to be_empty
expect(SmsProvider.messages).to be_empty
end
it 'sends code via SMS after sign in' do
@ -21,8 +21,8 @@ feature "User of two factor authentication" do
expect(page).to have_content 'Enter the code that was sent to you'
expect(SMSProvider.messages.size).to eq(1)
message = SMSProvider.last_message
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.reload.direct_otp)
end
@ -33,7 +33,7 @@ feature "User of two factor authentication" do
expect(page).to have_content('You are signed in as Marissa')
fill_in 'code', with: SMSProvider.last_message.body
fill_in 'code', with: SmsProvider.last_message.body
click_button 'Submit'
within('.flash.notice') do
@ -67,7 +67,7 @@ feature "User of two factor authentication" do
expect(page).to_not have_content("Your Personal Dashboard")
fill_in "code", with: SMSProvider.last_message.body
fill_in "code", with: SmsProvider.last_message.body
click_button "Submit"
expect(page).to have_content("Your Personal Dashboard")
@ -154,9 +154,9 @@ feature "User of two factor authentication" do
end
def sms_sign_in
SMSProvider.messages.clear()
SmsProvider.messages.clear()
visit user_two_factor_authentication_path
fill_in 'code', with: SMSProvider.last_message.body
fill_in 'code', with: SmsProvider.last_message.body
click_button 'Submit'
end

2
spec/rails_app/app/models/user.rb

@ -5,7 +5,7 @@ class User < ActiveRecord::Base
has_one_time_password
def send_two_factor_authentication_code(code)
SMSProvider.send_message(to: phone_number, body: code)
SmsProvider.send_message(to: phone_number, body: code)
end
def phone_number

2
spec/rails_app/lib/sms_provider.rb

@ -1,6 +1,6 @@
require 'ostruct'
class SMSProvider
class SmsProvider
Message = Class.new(OpenStruct)
class_attribute :messages

2
spec/support/sms_provider.rb

@ -1,5 +1,5 @@
RSpec.configure do |c|
c.before(:each) do
SMSProvider.messages.clear
SmsProvider.messages.clear
end
end

Loading…
Cancel
Save