Sha256: 26b0338f66e822b8d43711f4741d032ac640d444b97cf8673b89e02ca16c374f

Contents?: true

Size: 765 Bytes

Versions: 3

Compression:

Stored size: 765 Bytes

Contents

require 'spec_helper'

describe RailsSettingsUi::ValueTypes::Array do
  describe "#cast" do
    it "should cast hash as array of keys as symbols" do
      array_type = RailsSettingsUi::ValueTypes::Array.new({auto: "on", manual: "on"})
      expect(array_type.cast).to eq([:auto, :manual])
    end

    it "if setting presented as select should cast select value as symbol" do
      array_type = RailsSettingsUi::ValueTypes::Array.new("auto")
      expect(array_type.cast).to eq(:auto)
    end

    it "should accept ActionController::Parameters" do
      parameter = ActionController::Parameters.new('stuff' => 'on', 'other'=> 'off')
      array_type = RailsSettingsUi::ValueTypes::Array.new parameter
      expect(array_type.cast).to eq([:stuff])
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rails-settings-ui-0.5.0 spec/lib/rails-settings-ui/value_types/array_spec.rb
rails-settings-ui-0.4.0 spec/lib/rails-settings-ui/value_types/array_spec.rb
rails-settings-ui-0.3.2 spec/lib/rails-settings-ui/value_types/array_spec.rb