Sha256: 6a7e494b50c50359dd0d1ffacb3d1d67b1885b4c9b8ed00039de3decb5135194
Contents?: true
Size: 1.12 KB
Versions: 4
Compression:
Stored size: 1.12 KB
Contents
# -*- encoding : utf-8 -*- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe HashAsHiddenFields do include HashAsHiddenFields before(:each) do @hash = {:q => "query", :search_field => "search_field", :per_page=>10, :page=>5, :extra_arbitrary_key=>"arbitrary_value", :f=> {:field1 => ["a", "b"], :field2=> ["z"]}} end it "should convert a hash with nested complex data to Rails-style hidden form fields" do generated = hash_as_hidden_fields(@hash) generated.should have_selector("input[type='hidden'][name='q'][value='query']") generated.should have_selector("input[type='hidden'][name='per_page'][value='10']") generated.should have_selector("input[type='hidden'][name='page'][value='5']") generated.should have_selector("input[type='hidden'][name='extra_arbitrary_key'][value='arbitrary_value']") generated.should have_selector("input[type='hidden'][name='f[field2][]'][value='z']") generated.should have_selector("input[type='hidden'][name='f[field1][]'][value='a']") generated.should have_selector("input[type='hidden'][name='f[field1][]'][value='b']") end end
Version data entries
4 entries across 4 versions & 1 rubygems