-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from npauzenga/tasks/interactor-specs
Tasks/interactor specs
- Loading branch information
Showing
5 changed files
with
209 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe CreateUserSession do | ||
subject { described_class } | ||
|
||
let(:authenticate_user) { double("authenticate_user") } | ||
let(:login_user) { double("login_user") } | ||
|
||
before(:example) do | ||
allow(AuthenticateUser).to receive(:new).and_return(authenticate_user) | ||
allow(authenticate_user).to receive(:run!) | ||
allow(authenticate_user).to receive(:run) | ||
allow(authenticate_user).to receive(:context) | ||
|
||
allow(LoginUser).to receive(:new).and_return(login_user) | ||
allow(login_user).to receive(:run!) | ||
allow(login_user).to receive(:run) | ||
allow(login_user).to receive(:context) | ||
end | ||
|
||
describe ".call" do | ||
it "calls the AuthenticateUser interactor" do | ||
expect(authenticate_user).to receive(:run!) | ||
subject.call | ||
end | ||
|
||
it "calls the LoginUser interactor" do | ||
expect(login_user).to receive(:run!) | ||
subject.call | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe CreateUser do | ||
subject { described_class } | ||
|
||
let(:user) { create(:unconfirmed_user) } | ||
|
||
let(:interactor_context) do | ||
Interactor::Context.new(errors: :val, user: user) | ||
end | ||
|
||
let(:make_new_user) { double("make_new_user") } | ||
let(:encrypt_password) { double("encrypt_password") } | ||
let(:create_confirmation_token) { double("create_confirmation_token") } | ||
let(:send_new_user_confirmation) { double("send_new_user_confirmation") } | ||
|
||
before(:example) do | ||
allow(MakeNewUser).to receive(:new).and_return(make_new_user) | ||
allow(make_new_user).to receive(:run!) | ||
allow(make_new_user).to receive(:run) | ||
allow(make_new_user).to receive(:context) | ||
|
||
allow(EncryptPassword).to receive(:new).and_return(encrypt_password) | ||
allow(encrypt_password).to receive(:run!) | ||
allow(encrypt_password).to receive(:run) | ||
allow(encrypt_password).to receive(:context) | ||
|
||
allow(CreateConfirmationToken).to receive(:new). | ||
and_return(create_confirmation_token) | ||
allow(create_confirmation_token).to receive(:run!) | ||
allow(create_confirmation_token).to receive(:run) | ||
allow(create_confirmation_token).to receive(:context) | ||
|
||
allow(SendNewUserConfirmation).to receive(:new). | ||
and_return(send_new_user_confirmation) | ||
allow(send_new_user_confirmation).to receive(:run!) | ||
allow(send_new_user_confirmation).to receive(:run) | ||
allow(send_new_user_confirmation).to receive(:context) | ||
end | ||
|
||
describe ".call" do | ||
it "calls the MakeNewUser interactor" do | ||
expect(make_new_user).to receive(:run!) | ||
subject.call(interactor_context) | ||
end | ||
|
||
it "calls the EncryptPassword interactor" do | ||
expect(encrypt_password).to receive(:run!) | ||
subject.call(interactor_context) | ||
end | ||
|
||
it "calls the CreateConfirmationToken interactor" do | ||
expect(create_confirmation_token).to receive(:run!) | ||
subject.call(interactor_context) | ||
end | ||
|
||
it "calls the SendNewUserConfirmation interactor" do | ||
expect(send_new_user_confirmation).to receive(:run!) | ||
subject.call(interactor_context) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe RequestPasswordResetToken do | ||
subject { described_class } | ||
|
||
let(:find_password_reset_user) { double("find_password_reset_user") } | ||
let(:create_password_reset_token) { double("create_password_reset_token") } | ||
let(:send_password_reset_email) { double("send_password_reset_email") } | ||
|
||
before(:example) do | ||
allow(FindPasswordResetUser).to receive(:new). | ||
and_return(find_password_reset_user) | ||
allow(find_password_reset_user).to receive(:run!) | ||
allow(find_password_reset_user).to receive(:run) | ||
allow(find_password_reset_user).to receive(:context) | ||
|
||
allow(CreatePasswordResetToken).to receive(:new). | ||
and_return(create_password_reset_token) | ||
allow(create_password_reset_token).to receive(:run!) | ||
allow(create_password_reset_token).to receive(:run) | ||
allow(create_password_reset_token).to receive(:context) | ||
|
||
allow(SendPasswordResetEmail).to receive(:new). | ||
and_return(send_password_reset_email) | ||
allow(send_password_reset_email).to receive(:run!) | ||
allow(send_password_reset_email).to receive(:run) | ||
allow(send_password_reset_email).to receive(:context) | ||
end | ||
|
||
describe ".call" do | ||
it "calls the FindPasswordResetUser interactor" do | ||
expect(find_password_reset_user).to receive(:run!) | ||
subject.call | ||
end | ||
|
||
it "calls the CreatePasswordResetToken interactor" do | ||
expect(create_password_reset_token).to receive(:run!) | ||
subject.call | ||
end | ||
|
||
it "calls the SendPasswordResetEmail interactor" do | ||
expect(send_password_reset_email).to receive(:run!) | ||
subject.call | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe ResetPassword do | ||
subject { described_class } | ||
|
||
let(:update_password) { double("update_password") } | ||
let(:login_user) { double("login_user") } | ||
|
||
before(:example) do | ||
allow(UpdatePassword).to receive(:new).and_return(update_password) | ||
allow(update_password).to receive(:run!) | ||
allow(update_password).to receive(:run) | ||
allow(update_password).to receive(:context) | ||
|
||
allow(LoginUser).to receive(:new).and_return(login_user) | ||
allow(login_user).to receive(:run!) | ||
allow(login_user).to receive(:run) | ||
allow(login_user).to receive(:context) | ||
end | ||
|
||
describe ".call" do | ||
it "calls the UpdatePassword interactor" do | ||
expect(update_password).to receive(:run!) | ||
subject.call | ||
end | ||
|
||
it "calls the LoginUser interactor" do | ||
expect(login_user).to receive(:run!) | ||
subject.call | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe VerifyPasswordResetUser do | ||
subject { described_class } | ||
|
||
let(:find_password_reset_token) { double("find_password_reset_token") } | ||
|
||
let(:check_password_reset_expiration) do | ||
double("check_password_reset_expiration") | ||
end | ||
|
||
before(:example) do | ||
allow(FindPasswordResetToken).to receive(:new). | ||
and_return(find_password_reset_token) | ||
allow(find_password_reset_token).to receive(:run!) | ||
allow(find_password_reset_token).to receive(:run) | ||
allow(find_password_reset_token).to receive(:context) | ||
|
||
allow(CheckPasswordResetExpiration).to receive(:new). | ||
and_return(check_password_reset_expiration) | ||
allow(check_password_reset_expiration).to receive(:run!) | ||
allow(check_password_reset_expiration).to receive(:run) | ||
allow(check_password_reset_expiration).to receive(:context) | ||
end | ||
|
||
describe ".call" do | ||
it "calls the FindPasswordResetToken interactor" do | ||
expect(find_password_reset_token).to receive(:run!) | ||
subject.call | ||
end | ||
|
||
it "calls the CheckPasswordResetExpiration interactor" do | ||
expect(check_password_reset_expiration).to receive(:run!) | ||
subject.call | ||
end | ||
end | ||
end |