Sha256: b87250c175f424af6d74621cc6eec13517c56483e2e1fdb655dc85d70dcdab68

Contents?: true

Size: 669 Bytes

Versions: 1

Compression:

Stored size: 669 Bytes

Contents

# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Granite::Form::Types::HashWithActionControllerParameters do
  describe 'typecasting' do
    include_context 'type setup', 'Hash'

    before(:all) do
      require 'action_controller'
      Class.new(ActionController::Base)
    end

    let(:to_h) { { 'x' => { 'foo' => 'bar' }, 'y' => 2 } }
    let(:parameters) { ActionController::Parameters.new(to_h) }

    specify { expect(typecast(nil)).to be_nil }
    specify { expect(typecast(to_h)).to eq(to_h) }
    specify { expect(typecast(parameters)).to be_nil }
    specify { expect(typecast(parameters.permit(:y, x: [:foo]))).to eq(to_h) }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
granite-form-0.6.0 spec/granite/form/types/hash_with_action_controller_parameters_spec.rb