Sha256: ca58e385b4f905b4c80fa17549354cffb55625c2e0f1b48cab4265123746cde0
Contents?: true
Size: 1.91 KB
Versions: 2
Compression:
Stored size: 1.91 KB
Contents
module Spreeference describe Spreeference::Preference, type: :model do it "should require a key" do @preference = Spreeference::Preference.new @preference.key = :test @preference.value = true expect(@preference).to be_valid end describe "type coversion for values" do def round_trip_preference(key, value) p = Spreeference::Preference.new p.value = value p.key = key p.save Spreeference::Preference.find_by_key(key) end it ":boolean" do value = true key = "boolean_key" pref = round_trip_preference(key, value) expect(pref.value).to eq value end it "false :boolean" do value = false key = "boolean_key" pref = round_trip_preference(key, value) expect(pref.value).to eq value end it ":integer" do value = 10 key = "integer_key" pref = round_trip_preference(key, value) expect(pref.value).to eq value end it ":decimal" do value = 1.5 key = "decimal_key" pref = round_trip_preference(key, value) expect(pref.value).to eq value end it ":string" do value = "This is a string" key = "string_key" pref = round_trip_preference(key, value) expect(pref.value).to eq value end it ":text" do value = "This is a string stored as text" key = "text_key" pref = round_trip_preference(key, value) expect(pref.value).to eq value end it ":password" do value = "This is a password" key = "password_key" pref = round_trip_preference(key, value) expect(pref.value).to eq value end it ":any" do value = [1, 2] key = "any_key" pref = round_trip_preference(key, value) expect(pref.value).to eq value end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
spreeference-0.1.1 | spec/models/spreeference/preference_spec.rb |
spreeference-0.1.0 | spec/models/spreeference/preference_spec.rb |