Sha256: bc69395f163e2e08c734b8de45174f40325d18a774b56ff3336b9ffe50322157

Contents?: true

Size: 842 Bytes

Versions: 2

Compression:

Stored size: 842 Bytes

Contents

require 'spec_helper'

describe RailsSettingsUi::ValueTypes::Hash do
  describe "#cast" do
    it "should cast string to hash" do
      param = "{\"border_color\"=>\"e0e0e0\", \"block_color\"=>\"ffffff\", \"title\"=>{\"font\"=>\"Tahoma\", \"size\"=>\"12\", \"color\"=>\"107821\"}}"
      fixnum_type = RailsSettingsUi::ValueTypes::Hash.new(param)
      expect(fixnum_type.cast).to eq({
        "border_color" => "e0e0e0",
        "block_color" => "ffffff",
        "title" => {
          "font" => "Tahoma",
          "size" => "12",
          "color" => "107821"
        }
      })
    end
  end

  describe "if value not valid hash" do
    it "should be not valid" do
      fixnum_type = RailsSettingsUi::ValueTypes::Hash.new("{\"border_color\"=>, \"block_color\"=>\"ffffff\"")
      expect(fixnum_type.valid?).to be_false
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rails-settings-ui-0.1.1 spec/lib/rails-settings-ui/value_types/hash_spec.rb
rails-settings-ui-0.1.0 spec/lib/rails-settings-ui/value_types/hash_spec.rb