Last active
April 1, 2017 01:19
-
-
Save jordancrawfordnz/2a7db59b0337c8e3c290f933a9391a3f to your computer and use it in GitHub Desktop.
Mocking in RSpec.
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
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
Snippets taken from: https://github.com/jordancrawfordnz/ticket-to-ride/blob/master/spec/controllers/claim_route_controller_spec.rb