Skip to content

Instantly share code, notes, and snippets.

@jordancrawfordnz
Last active April 1, 2017 01:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jordancrawfordnz/2a7db59b0337c8e3c290f933a9391a3f to your computer and use it in GitHub Desktop.
Save jordancrawfordnz/2a7db59b0337c8e3c290f933a9391a3f to your computer and use it in GitHub Desktop.
Mocking in RSpec.
context "on ClaimRoute failure" do
let(:service_double) { instance_double(ClaimRoute, call: service_result, errors: service_expected_errors) }
let(:service_result) { false }
let(:service_expected_errors) { [ClaimRoute::REQUIRED_PARAMETERS_NOT_PROVIDED] }
before do
post_claim_route
end
it "redirects to the game page" do
expect(response).to redirect_to game
end
it "has the expected errors in the flash with error prefix" do
expect(flash[:errors]).to eq service_expected_errors_prefixed
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment