spec/input_spec.rb in watir-webdriver-0.0.7 vs spec/input_spec.rb in watir-webdriver-0.0.8

- old
+ new

@@ -1,6 +1,6 @@ -require File.expand_path 'watirspec/spec_helper', File.dirname(__FILE__) +require File.expand_path('watirspec/spec_helper', File.dirname(__FILE__)) describe Watir::Input do before do browser.goto(WatirSpec.files + "/forms_with_input_elements.html") @@ -25,11 +25,11 @@ e.should be_kind_of(Watir::Radio) end it "raises an error if the element is not a radio button" do lambda { - browser.input(:xpath => "//input[@type='text']").to_checkbox + browser.input(:xpath => "//input[@type='text']").to_radio }.should raise_error(TypeError) end end describe "#to_button" do @@ -60,6 +60,18 @@ browser.input(:xpath => "//input[@type='radio']").to_text_field }.should raise_error(TypeError) end end + describe "#to_file_field" do + it "returns a TextField instance" do + e = browser.input(:xpath => "//input[@type='file']").to_file_field + e.should be_kind_of(Watir::FileField) + end + + it "raises an error if the element is not a text field" do + lambda { + browser.input(:xpath => "//input[@type='radio']").to_file_field + }.should raise_error(TypeError) + end + end end