Commit 22ccc1d7 authored by jejacks0n's avatar jejacks0n

Improves the expect_next spec implementation

parent 65836d5f
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe "User registration", :js, :saas do RSpec.describe "User registration", :js, :saas do
include AfterNextHelpers
let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
before do before do
...@@ -155,8 +157,7 @@ RSpec.describe "User registration", :js, :saas do ...@@ -155,8 +157,7 @@ RSpec.describe "User registration", :js, :saas do
before do before do
click_button class: 'gl-toggle' click_button class: 'gl-toggle'
expect_next_instance_of(GitlabSubscriptions::CreateLeadService) do |service| expect_next(GitlabSubscriptions::CreateLeadService).to receive(:execute).with(
expect(service).to receive(:execute).with(
trial_user: ActionController::Parameters.new( trial_user: ActionController::Parameters.new(
company_name: '', company_name: '',
company_size: '', company_size: '',
...@@ -172,7 +173,6 @@ RSpec.describe "User registration", :js, :saas do ...@@ -172,7 +173,6 @@ RSpec.describe "User registration", :js, :saas do
newsletter_segment: true newsletter_segment: true
).permit! ).permit!
).and_return(success: true) ).and_return(success: true)
end
click_on 'Continue' click_on 'Continue'
end end
...@@ -183,8 +183,7 @@ RSpec.describe "User registration", :js, :saas do ...@@ -183,8 +183,7 @@ RSpec.describe "User registration", :js, :saas do
fill_in 'group_name', with: 'Test Group' fill_in 'group_name', with: 'Test Group'
fill_in 'blank_project_name', with: 'Test Project' fill_in 'blank_project_name', with: 'Test Project'
expect_next_instance_of(GitlabSubscriptions::CreateLeadService) do |service| expect_next(GitlabSubscriptions::CreateLeadService).to receive(:execute).with(
expect(service).to receive(:execute).with(
uid: user.id, uid: user.id,
trial_user: trial_user:
ActionController::Parameters.new( ActionController::Parameters.new(
...@@ -194,7 +193,6 @@ RSpec.describe "User registration", :js, :saas do ...@@ -194,7 +193,6 @@ RSpec.describe "User registration", :js, :saas do
sync_to_gl: true sync_to_gl: true
).permit! ).permit!
).and_return(success: true) ).and_return(success: true)
end
click_on 'Create project' click_on 'Create project'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment