Skip to content

Commit

Permalink
Update specs
Browse files Browse the repository at this point in the history
  • Loading branch information
mercyoseni committed Jul 28, 2019
1 parent c25ce21 commit 5b3db35
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions spec/controllers/mushrooms_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,31 @@
get :index
end
end

context 'when search query is present' do
let(:params) do
{ search: { query: 'almond' }, page: '1' }
end

let(:search_mushroom) do
instance_double('SearchMushroom', run: Mushroom.none)
end

it 'runs the SearchMushroom service' do
expect(SearchMushroom).to receive(:new)
.with(params[:search][:query], params[:page])
.and_return(search_mushroom)

get :index, params: params
end
end

context 'when search query is NOT present' do
it 'does NOT run the SearchMushroom service' do
expect(SearchMushroom).not_to receive(:new)

get :index
end
end
end
end

0 comments on commit 5b3db35

Please sign in to comment.