Sha256: 3554c9cf712661d8622f6e843290fd75dd0da7bf0428c1ea0286a140e9323c20

Contents?: true

Size: 1.91 KB

Versions: 12

Compression:

Stored size: 1.91 KB

Contents

require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")

module Webrat
  describe Field do
    it "should have nice inspect output" do
      html = <<-HTML
        <html>
        <input type='checkbox' checked='checked' />
        </html>
      HTML
      
      element = Webrat::XML.css_search(Webrat::XML.document(html), "input").first
      checkbox = CheckboxField.new(nil, element)
      checkbox.inspect.should =~ /#<Webrat::CheckboxField @element=<input type=['"]checkbox['"] checked(=['"]checked['"])?\/?>>/
    end
  end
  
  describe CheckboxField do
    it "should say it is checked if it is" do
      html = <<-HTML
        <html>
        <input type='checkbox' checked='checked' />
        </html>
      HTML
      
      element = Webrat::XML.css_search(Webrat::XML.document(html), "input").first
      checkbox = CheckboxField.new(nil, element)
      checkbox.should be_checked
    end

    it "should say it is not checked if it is not" do
      html = <<-HTML
        <html>
        <input type='checkbox' />
        </html>
      HTML
      
      element = Webrat::XML.css_search(Webrat::XML.document(html), "input").first
      checkbox = CheckboxField.new(nil, element)
      checkbox.should_not be_checked
    end
  end
  
  describe RadioField do
    it "should say it is checked if it is" do
      html = <<-HTML
        <html>
        <input type='radio' checked='checked' />
        </html>
      HTML
      
      element = Webrat::XML.css_search(Webrat::XML.document(html), "input").first
      radio_button = RadioField.new(nil, element)
      radio_button.should be_checked
    end

    it "should say it is not checked if it is not" do
      html = <<-HTML
        <html><input type='radio' /></html>
      HTML
      
      element = Webrat::XML.css_search(Webrat::XML.document(html), "input").first 
      radio_button = RadioField.new(nil, element)
      radio_button.should_not be_checked
    end
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
adva-0.2.4 test/webrat/spec/private/core/field_spec.rb
adva-0.2.3 test/webrat/spec/private/core/field_spec.rb
adva-0.2.2 test/webrat/spec/private/core/field_spec.rb
adva-0.2.1 test/webrat/spec/private/core/field_spec.rb
adva-0.2.0 test/webrat/spec/private/core/field_spec.rb
adva-0.1.4 test/webrat/spec/private/core/field_spec.rb
adva-0.1.3 test/webrat/spec/private/core/field_spec.rb
adva-0.1.2 test/webrat/spec/private/core/field_spec.rb
adva-0.1.1 test/webrat/spec/private/core/field_spec.rb
adva-0.1.0 test/webrat/spec/private/core/field_spec.rb
adva-0.0.1 test/webrat/spec/private/core/field_spec.rb
integrity-0.1.9 vendor/webrat/spec/private/core/field_spec.rb