Sha256: 3353c9e6374f44cb0aadeef3b2d5dcbc82db2c4a853540473ab7f01c856b58e5

Contents?: true

Size: 921 Bytes

Versions: 13

Compression:

Stored size: 921 Bytes

Contents

require 'spec_helper'

RSpec.describe ActionView::Helpers::FormBuilder do
  let(:employee){ Employee.create section: 'SE1' }
  subject{ described_class.new :collection, Employee::Collection.new([employee]), @template, {}}
  before do
    # http://pivotallabs.com/testing-custom-form-builder/
    @template = Object.new
    @template.extend ActionView::Helpers::FormTagHelper
    @template.extend ActionView::Helpers::FormOptionsHelper
    @template.extend ActionView::Helpers::FormHelper
  end

  describe '.collection_ids' do
    it 'returns the collection ids as hidden fields' do
      subject.collection_ids.should eq %{<input type="hidden" name="ids[]" value="#{employee.id}" />}
    end

    it "does not raise when the object is not a collection object" do
      form_builder = described_class.new :employee, employee, @template, {}
      expect{ form_builder.collection_ids }.not_to raise_error
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
record_collection-0.7.4 spec/rails/form_builder_spec.rb
record_collection-0.7.3 spec/rails/form_builder_spec.rb
record_collection-0.7.2 spec/rails/form_builder_spec.rb
record_collection-0.7.1 spec/rails/form_builder_spec.rb
record_collection-0.7.0 spec/rails/form_builder_spec.rb
record_collection-0.6.1 spec/rails/form_builder_spec.rb
record_collection-0.6.0 spec/rails/form_builder_spec.rb
record_collection-0.5.3 spec/rails/form_builder_spec.rb
record_collection-0.5.2 spec/rails/form_builder_spec.rb
record_collection-0.5.1 spec/rails/form_builder_spec.rb
record_collection-0.5.0 spec/rails/form_builder_spec.rb
record_collection-0.4.6 spec/rails/form_builder_spec.rb
record_collection-0.4.5 spec/rails/form_builder_spec.rb