-
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.
- Loading branch information
1 parent
869c1a1
commit 7b8a0d3
Showing
1 changed file
with
28 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,28 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe MushroomsController, type: :controller do | ||
describe '#index' do | ||
context 'when filter params is present' do | ||
it 'runs the FilterMushroom service and returns results' do | ||
get :index, params: { filter: { odor: 'almond' } } | ||
|
||
allow(FilterMushroom.new(response.request.params[:filter], 1)) | ||
.to receive(:run) | ||
|
||
expect(response).to have_http_status(200) | ||
expect(response).to render_template(:index) | ||
end | ||
end | ||
|
||
context 'when filter params is NOT present' do | ||
it 'renders the index template' do | ||
get :index | ||
|
||
expect(FilterMushroom).not_to receive(:new) | ||
|
||
expect(response).to have_http_status(200) | ||
expect(response).to render_template(:index) | ||
end | ||
end | ||
end | ||
end |