Files
openfoodnetwork/spec/models/spree/preferences/configuration_spec.rb
2024-05-09 12:24:41 +10:00

27 lines
614 B
Ruby

# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Spree::Preferences::Configuration do
let(:config) do
Class.new(Spree::Preferences::Configuration) do
preference :color, :string, default: :blue
end.new
end
it "has named methods to access preferences" do
config.color = 'orange'
expect(config.color).to eq 'orange'
end
it "uses [ ] to access preferences" do
config[:color] = 'red'
expect(config[:color]).to eq 'red'
end
it "uses set/get to access preferences" do
config.set :color, 'green'
expect(config.get(:color)).to eq 'green'
end
end