Sha256: 8bead05b7b72a8057ce40c14c48d63b11570928a5b61d31736093f919bdfb362

Contents?: true

Size: 843 Bytes

Versions: 7

Compression:

Stored size: 843 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_falsey
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rails-settings-ui-0.5.0 spec/lib/rails-settings-ui/value_types/hash_spec.rb
rails-settings-ui-0.4.0 spec/lib/rails-settings-ui/value_types/hash_spec.rb
rails-settings-ui-0.3.2 spec/lib/rails-settings-ui/value_types/hash_spec.rb
rails-settings-ui-0.3.1 spec/lib/rails-settings-ui/value_types/hash_spec.rb
rails-settings-ui-0.2.1 spec/lib/rails-settings-ui/value_types/hash_spec.rb
rails-settings-ui-0.3.0 spec/lib/rails-settings-ui/value_types/hash_spec.rb
rails-settings-ui-0.2.0 spec/lib/rails-settings-ui/value_types/hash_spec.rb