Skip to content

Commit

Permalink
Add controller specs
Browse files Browse the repository at this point in the history
  • Loading branch information
mercyoseni committed Jul 28, 2019
1 parent 869c1a1 commit 7b8a0d3
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions spec/controllers/mushrooms_controller_spec.rb
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

0 comments on commit 7b8a0d3

Please sign in to comment.