From 11aab03161b88c6c4e82dd1dd02399acf58b7e12 Mon Sep 17 00:00:00 2001 From: Halimat Mercy Oseni Date: Mon, 29 Jul 2019 03:37:29 +0100 Subject: [PATCH] Add specs for home_partial_path --- spec/helpers/mushrooms_helper_spec.rb | 38 +++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/spec/helpers/mushrooms_helper_spec.rb b/spec/helpers/mushrooms_helper_spec.rb index 1efe1b2..2b1f33a 100644 --- a/spec/helpers/mushrooms_helper_spec.rb +++ b/spec/helpers/mushrooms_helper_spec.rb @@ -61,4 +61,42 @@ end end end + + describe '#home_partial_path' do + context 'when mushrooms is present' do + it "returns 'mushrooms'" do + mushrooms = double('mushrooms') + params = { } + + expect(home_partial_path(mushrooms, params)).to eq('mushrooms') + end + end + + context 'when filter params is present' do + it "returns 'no_results'" do + mushrooms = '' + params = { filter: 'mushroom_class' } + + expect(home_partial_path(mushrooms, params)).to eq('no_results') + end + end + + context 'when search params is present' do + it "returns 'no_results'" do + mushrooms = '' + params = { search: 'edible' } + + expect(home_partial_path(mushrooms, params)).to eq('no_results') + end + end + + context 'when mushrooms and params are NOT present' do + it "returns 'default'" do + mushrooms = '' + params = { } + + expect(home_partial_path(mushrooms, params)).to eq('default') + end + end + end end