Sha256: 1b63f3dc4b8a0d83628b0ba2787c8a7ead139d972087035c1f7e6e51f01a7f08

Contents?: true

Size: 1.31 KB

Versions: 1

Compression:

Stored size: 1.31 KB

Contents

require 'horseman/hidden_fields'

describe Horseman::HiddenFields do
  
  it "parses a single simple hidden input field" do
    html = %{<input type="hidden" name="test" value="test_data" />}
    cut = described_class.new(html)
    
    cut.tokens.size.should == 1
    cut.tokens['test'].should == 'test_data'
  end
  
  it "parses a single complex hidden input field" do
    html = %{<input attr0="value0" type="hidden" attr1="value1" name="test" attr2="value2" value="test_data" attr3="value3" />}
    cut = described_class.new(html)
    
    cut.tokens.size.should == 1
    cut.tokens['test'].should == 'test_data'
  end

  it "parses multiple hidden input fields" do
    html = %{
        <input type="hidden" name="test" value="test_data" />
        <input type="hidden" name="foo" value="bar" />
        <some other="tag"></some>
        <input type="hidden" name="dee" value="dum" />
            }
    cut = described_class.new(html)
    
    cut.tokens.size.should == 3
    cut.tokens['test'].should == 'test_data'
    cut.tokens['foo'].should == 'bar'
    cut.tokens['dee'].should == 'dum'
  end
    
  it "handles single quotes, too" do
    html = %{<input type='hidden' name='test' value='test_data' />}
    cut = described_class.new(html)
    
    cut.tokens.size.should == 1
    cut.tokens['test'].should == 'test_data'
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
horseman-0.0.1 spec/horseman/hidden_fields_spec.rb