Sha256: 6b6e481e364e6856f078144ab6ff3edc18bf9ebafb01e7097e8e2f6258600fb3

Contents?: true

Size: 975 Bytes

Versions: 8

Compression:

Stored size: 975 Bytes

Contents

require 'spec_helper'

module ApiTaster
  describe FormBuilder do
    context "empty params" do
      it "has empty buffer" do
        builder = FormBuilder.new({})
        builder.instance_variable_get(:@_buffer).length.should == 0
      end
    end

    let(:builder) do
      FormBuilder.new({
        :hello => 'world',
        :nested => {
          :foo => 'bar',
          :integer => 1,
          :array => [1, 2, 3]
        }
      })
    end

    it "inserts data into the buffer" do
      builder.instance_variable_get(:@_buffer).length.should > 0
    end

    it "outputs html" do
      builder.html.should match('bar')
    end

    context "data types" do
      it "does strings" do
        builder.html.should match('value="world"')
      end

      it "does numbers" do
        builder.html.should match('value="1"')
      end

      it "does arrays" do
        builder.html.should match(/name="\[nested\]\[array\]\[\]" value="2"/)
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
api_taster-0.4.7 spec/form_builder_spec.rb
api_taster-0.4.6 spec/form_builder_spec.rb
api_taster-0.4.5 spec/form_builder_spec.rb
api_taster-0.4.4 spec/form_builder_spec.rb
api_taster-0.4.3 spec/form_builder_spec.rb
api_taster-0.4.2 spec/form_builder_spec.rb
api_taster-0.4.1 spec/form_builder_spec.rb
api_taster-0.4.0 spec/form_builder_spec.rb