Skip to content

Commit

Permalink
Add stub request
Browse files Browse the repository at this point in the history
Error gets built automagically by rspec,
no need to { error: <string> }.to_json
  • Loading branch information
jesusbv authored and ngetahun committed Nov 5, 2024
1 parent e51bea5 commit 7d84d7a
Showing 1 changed file with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,15 @@

context 'when verification provider returns false' do
before do
expect(InstanceVerification::Providers::Example).to receive(:new)
.with(be_a(ActiveSupport::Logger), be_a(ActionDispatch::Request), payload, instance_data).and_return(plugin_double)
expect(plugin_double).to receive(:instance_valid?).and_return(false)
stub_request(:post, scc_activate_url)
.to_return(
status: 200,
body: { error: 'Unexpected instance verification error has occurred' }.to_json,
headers: {}
)
# expect(InstanceVerification::Providers::Example).to receive(:new)
# .with(be_a(ActiveSupport::Logger), be_a(ActionDispatch::Request), payload, instance_data).and_return(plugin_double)
# expect(plugin_double).to receive(:instance_valid?).and_return(false)
post url, params: payload, headers: headers
end

Expand All @@ -86,9 +92,16 @@

context 'when verification provider raises an unhandled exception' do
before do
expect(InstanceVerification::Providers::Example).to receive(:new)
.with(be_a(ActiveSupport::Logger), be_a(ActionDispatch::Request), payload, instance_data).and_return(plugin_double)
expect(plugin_double).to receive(:instance_valid?).and_raise('Custom plugin error')
stub_request(:post, scc_activate_url)
.to_return(
status: 422,
body: { error: 'Unexpected instance verification error has occurred' }.to_json,
headers: {}
)

# expect(InstanceVerification::Providers::Example).to receive(:new)
# .with(be_a(ActiveSupport::Logger), be_a(ActionDispatch::Request), payload, instance_data).and_return(plugin_double)
# expect(plugin_double).to receive(:instance_valid?).and_raise('Custom plugin error')
post url, params: payload, headers: headers
end

Expand Down Expand Up @@ -623,7 +636,7 @@
.with({ headers: scc_headers, body: payload.merge({ byos_mode: 'byos' }) })
.and_return(
status: 401,
body: { error: 'error_message' }.to_json,
body: 'Migration target not allowed on this instance type',
headers: {}
)
request
Expand Down

0 comments on commit 7d84d7a

Please sign in to comment.