mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
OptionValueNamer spec refactor
This commit is contained in:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user