From 9052b1c3db40256ed9d87bd836ec5626fa42e824 Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Wed, 22 Feb 2017 19:03:04 +1100 Subject: [PATCH] A few updates to spec where 'be true' and 'be false' didn't cut it --- app/models/spree/preference_decorator.rb | 2 +- lib/open_food_network/feature_toggle.rb | 2 +- spec/controllers/spree/admin/search_controller_spec.rb | 6 +++--- spec/features/admin/products_spec.rb | 2 +- spec/features/consumer/registration_spec.rb | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/models/spree/preference_decorator.rb b/app/models/spree/preference_decorator.rb index adb2194f2d..4a42a7dea7 100644 --- a/app/models/spree/preference_decorator.rb +++ b/app/models/spree/preference_decorator.rb @@ -16,7 +16,7 @@ module Spree private def product_selection_from_inventory_only_changed? - key =~ product_selection_from_inventory_only_regex + !!(key =~ product_selection_from_inventory_only_regex) end def enterprise diff --git a/lib/open_food_network/feature_toggle.rb b/lib/open_food_network/feature_toggle.rb index be1a9b0065..23bcb00c8b 100644 --- a/lib/open_food_network/feature_toggle.rb +++ b/lib/open_food_network/feature_toggle.rb @@ -1,7 +1,7 @@ module OpenFoodNetwork class FeatureToggle def self.enabled? feature - features.with_indifferent_access[feature] + !!features.with_indifferent_access[feature] end private diff --git a/spec/controllers/spree/admin/search_controller_spec.rb b/spec/controllers/spree/admin/search_controller_spec.rb index e272625363..59490cec5b 100644 --- a/spec/controllers/spree/admin/search_controller_spec.rb +++ b/spec/controllers/spree/admin/search_controller_spec.rb @@ -47,12 +47,12 @@ describe Spree::Admin::SearchController, type: :controller do it 'returns a list of customers of the enterprise' do expect(@results.size).to eq 2 - expect(@results.find { |c| c['id'] == customer_1.id}).to be true - expect(@results.find { |c| c['id'] == customer_2.id}).to be true + expect(@results.find { |c| c['id'] == customer_1.id}).to be_truthy + expect(@results.find { |c| c['id'] == customer_2.id}).to be_truthy end it 'does not return the customer of other enterprises' do - expect(@results.find { |c| c['id'] == customer_3.id}).to be false + expect(@results.find { |c| c['id'] == customer_3.id}).to be_nil p customer_3 p enterprise end diff --git a/spec/features/admin/products_spec.rb b/spec/features/admin/products_spec.rb index 816fe28442..1c8bdc2603 100644 --- a/spec/features/admin/products_spec.rb +++ b/spec/features/admin/products_spec.rb @@ -54,7 +54,7 @@ feature %q{ product.tax_category_id.should == tax_category.id product.shipping_category.should == shipping_category product.description.should == "A description..." - product.group_buy.should be false + product.group_buy.should be_falsey product.master.option_values.map(&:name).should == ['5kg'] product.master.options_text.should == "5kg" end diff --git a/spec/features/consumer/registration_spec.rb b/spec/features/consumer/registration_spec.rb index 53a7b00f9e..a70510aa7c 100644 --- a/spec/features/consumer/registration_spec.rb +++ b/spec/features/consumer/registration_spec.rb @@ -144,7 +144,7 @@ feature "Registration", js: true do visit registration_path click_button "Let's get started!" - find("div#progress-bar").visible?.should be true + expect(find("div#progress-bar")).to be_visible end end @@ -160,7 +160,7 @@ feature "Registration", js: true do perform_and_ensure(:check, "accept_terms", lambda { page.has_no_selector? "input.button.primary[disabled]" }) click_button "Let's get started!" - find("div#progress-bar").visible?.should be true + expect(find("div#progress-bar")).to be_visible end end end