Sha256: 171f5aa1d2ef901621c1b36aae146cc352d435956e6645aa61bd81ee4dabc346

Contents?: true

Size: 645 Bytes

Versions: 1

Compression:

Stored size: 645 Bytes

Contents

require_relative 'spec_helper'

describe ActiveModel::Form do
  # Boolean params generated by the Rails form helpers look like this
  let(:params) do
    { "form"=>
      {"not_checked"=>"0",
       "checked"=>"1"}
    }
  end

  it "parses the Rails form helper boolean params" do
    class FormWithBooleans < ActiveModel::Form
      attribute :not_checked, :boolean
      attribute :checked, :boolean
      attribute :not_set, :boolean
    end

    form = FormWithBooleans.new(params['form'])
    form.not_checked.must_equal false
    form.checked.must_equal true
    form.not_set.must_equal nil # TODO: Should this be nil or false?
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
activemodel-form-0.0.1 spec/boolean_attribute_form_spec.rb