From 227c10288dbb7c01bdc338d4c01e31c2804a8fc2 Mon Sep 17 00:00:00 2001 From: Rob H Date: Wed, 4 Jun 2014 15:39:04 +1000 Subject: [PATCH] OptionValueNamer spec refactor --- .../open_food_network/option_value_namer_spec.rb | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/spec/lib/open_food_network/option_value_namer_spec.rb b/spec/lib/open_food_network/option_value_namer_spec.rb index 22f9c54c3c..c0758d2a37 100644 --- a/spec/lib/open_food_network/option_value_namer_spec.rb +++ b/spec/lib/open_food_network/option_value_namer_spec.rb @@ -3,33 +3,32 @@ require 'spec_helper' module OpenFoodNetwork describe OptionValueNamer do describe "generating option value name" do + let(:v) { Spree::Variant.new } + let(:subject) { OptionValueNamer.new v } + it "when description is blank" do - v = Spree::Variant.new unit_description: nil - subject = OptionValueNamer.new v + v.stub(:unit_description) { nil } subject.stub(:value_scaled?) { true } subject.stub(:option_value_value_unit) { %w(value unit) } subject.name.should == "valueunit" end it "when description is present" do - v = Spree::Variant.new unit_description: 'desc' - subject = OptionValueNamer.new v + v.stub(:unit_description) { 'desc' } subject.stub(:option_value_value_unit) { %w(value unit) } subject.stub(:value_scaled?) { true } subject.name.should == "valueunit desc" end it "when value is blank and description is present" do - v = Spree::Variant.new unit_description: 'desc' - subject = OptionValueNamer.new v + v.stub(:unit_description) { 'desc' } subject.stub(:option_value_value_unit) { [nil, nil] } subject.stub(:value_scaled?) { true } subject.name.should == "desc" end it "spaces value and unit when value is unscaled" do - v = Spree::Variant.new unit_description: nil - subject = OptionValueNamer.new v + v.stub(:unit_description) { nil } subject.stub(:option_value_value_unit) { %w(value unit) } subject.stub(:value_scaled?) { false } subject.name.should == "value unit"