Sha256: 500f06f1b404bb6f8c069766aff889b1d54e2c84b3d024e618523ab5de60bf3c
Contents?: true
Size: 1.5 KB
Versions: 1
Compression:
Stored size: 1.5 KB
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', :user => { :name => 'Fred', :comment => { :title => [1, 2, 3] } }, :items => [ { :name => 'flower', :price => '4.95' }, { :name => 'pot', :price => '2.45' }, { :nested_items => [ { :name => 'apple' }, { :name => 'orange'}, { :nested_numbers => [3, 4, 5] } ]} ] }) 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('world') 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="\[user\]\[comment\]\[title\]\[\]" value="1"/) end it "does nested arrays" do builder.html.should match(/name="\[items\]\[\]\[nested_items\]\[\]\[nested_numbers\]\[\]" value="5"/) builder.html.should match(/name="\[items\]\[\]\[nested_items\]\[\]\[name\]" value="apple"/) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
api_taster-0.4.8 | spec/form_builder_spec.rb |