hello, world!
- -
-
- First -
- Second -
diff --git a/spec/api/basic_auth_spec.rb b/spec/api/basic_auth_spec.rb index 16f908d..02156cf 100644 --- a/spec/api/basic_auth_spec.rb +++ b/spec/api/basic_auth_spec.rb @@ -12,9 +12,11 @@ describe "Basic Auth HTTP headers" do it "should be present in form submits" do with_html <<-HTML +
+ HTML webrat_session.should_receive(:post).with("/form1", {}, {'HTTP_AUTHORIZATION' => "Basic dXNlcjpzZWNyZXQ=\n"}) click_button diff --git a/spec/api/check_spec.rb b/spec/api/check_spec.rb index 8e9bcd4..9254960 100644 --- a/spec/api/check_spec.rb +++ b/spec/api/check_spec.rb @@ -26,12 +26,14 @@ describe "check" do it "should check rails style checkboxes" do with_html <<-HTML + + HTML webrat_session.should_receive(:get).with("/login", "user" => {"tos" => "1"}) @@ -86,8 +88,10 @@ end describe "uncheck" do it "should fail if no checkbox found" do with_html <<-HTML + + HTML lambda { uncheck "remember_me" }.should raise_error(Webrat::NotFoundError) @@ -95,9 +99,11 @@ describe "uncheck" do it "should fail if input is not a checkbox" do with_html <<-HTML + + HTML lambda { uncheck "remember_me" }.should raise_error(Webrat::NotFoundError) @@ -105,22 +111,26 @@ describe "uncheck" do it "should fail if the checkbox is disabled" do with_html <<-HTML + + HTML lambda { uncheck "remember_me" }.should raise_error(Webrat::DisabledFieldError) end it "should uncheck rails style checkboxes" do with_html <<-HTML + + HTML webrat_session.should_receive(:get).with("/login", "user" => {"tos" => "0"}) check "TOS" @@ -130,10 +140,12 @@ describe "uncheck" do it "should result in value not being posted" do with_html <<-HTML + + HTML webrat_session.should_receive(:post).with("/login", {}) uncheck "remember_me" diff --git a/spec/api/choose_spec.rb b/spec/api/choose_spec.rb index 9137388..31df4ae 100644 --- a/spec/api/choose_spec.rb +++ b/spec/api/choose_spec.rb @@ -3,8 +3,10 @@ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper") describe "choose" do it "should fail if no radio buttons found" do with_html <<-HTML + + HTML lambda { choose "first option" }.should raise_error(Webrat::NotFoundError) @@ -12,9 +14,11 @@ describe "choose" do it "should fail if input is not a radio button" do with_html <<-HTML + + HTML lambda { choose "first_option" }.should raise_error(Webrat::NotFoundError) @@ -22,6 +26,7 @@ describe "choose" do it "should check rails style radio buttons" do with_html <<-HTML + + HTML webrat_session.should_receive(:get).with("/login", "user" => {"gender" => "M"}) choose "Male" @@ -37,6 +43,7 @@ describe "choose" do it "should only submit last chosen value" do with_html <<-HTML + + HTML webrat_session.should_receive(:get).with("/login", "user" => {"gender" => "M"}) choose "Female" @@ -53,10 +61,12 @@ describe "choose" do it "should fail if the radio button is disabled" do with_html <<-HTML + + HTML lambda { choose "first_option" }.should raise_error(Webrat::DisabledFieldError) @@ -64,10 +74,12 @@ describe "choose" do it "should result in the value on being posted if not specified" do with_html <<-HTML + + HTML webrat_session.should_receive(:post).with("/login", "first_option" => "on") choose "first_option" @@ -76,10 +88,12 @@ describe "choose" do it "should result in the value on being posted if not specified and checked by default" do with_html <<-HTML + + HTML webrat_session.should_receive(:post).with("/login", "first_option" => "on") click_button @@ -87,6 +101,7 @@ describe "choose" do it "should result in the value of the selected radio button being posted when a subsequent one is checked by default" do with_html <<-HTML + + HTML webrat_session.should_receive(:post).with("/login", "user" => {"gender" => "M"}) choose "Male" diff --git a/spec/api/click_area_spec.rb b/spec/api/click_area_spec.rb index 791817f..65bfbbe 100644 --- a/spec/api/click_area_spec.rb +++ b/spec/api/click_area_spec.rb @@ -3,9 +3,11 @@ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper") describe "click_area" do it "should use get by default" do with_html <<-HTML + + HTML webrat_session.should_receive(:get).with("/page", {}) click_area "Berlin" @@ -13,9 +15,11 @@ describe "click_area" do it "should assert valid response" do with_html <<-HTML + + HTML webrat_session.response_code = 501 lambda { click_area "Berlin" }.should raise_error(Webrat::PageLoadError) @@ -24,9 +28,11 @@ describe "click_area" do [200, 300, 400, 499].each do |status| it "should consider the #{status} status code as success" do with_html <<-HTML + + HTML webrat_session.response_code = status lambda { click_area "Berlin" }.should_not raise_error @@ -35,9 +41,11 @@ describe "click_area" do it "should fail if the area doesn't exist" do with_html <<-HTML + + HTML lambda { @@ -47,9 +55,11 @@ describe "click_area" do it "should not be case sensitive" do with_html <<-HTML + + HTML webrat_session.should_receive(:get).with("/page", {}) click_area "berlin" @@ -59,9 +69,11 @@ describe "click_area" do it "should follow relative links" do webrat_session.stub!(:current_url => "/page") with_html <<-HTML + + HTML webrat_session.should_receive(:get).with("/page/sub", {}) click_area "Berlin" @@ -69,9 +81,11 @@ describe "click_area" do it "should follow fully qualified local links" do with_html <<-HTML + + HTML webrat_session.should_receive(:get).with("http://www.example.com/page", {}) click_area "Berlin" @@ -79,9 +93,11 @@ describe "click_area" do it "should follow query parameters" do with_html <<-HTML + + HTML webrat_session.should_receive(:get).with("/page?foo=bar", {}) click_area "Berlin" diff --git a/spec/api/click_button_spec.rb b/spec/api/click_button_spec.rb index 5e55ad1..ab6913d 100644 --- a/spec/api/click_button_spec.rb +++ b/spec/api/click_button_spec.rb @@ -3,7 +3,9 @@ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper") describe "click_button" do it "should fail if no buttons" do with_html <<-HTML + + HTML lambda { click_button }.should raise_error(Webrat::NotFoundError) @@ -11,9 +13,11 @@ describe "click_button" do it "should fail if input is not a submit button" do with_html <<-HTML + + HTML lambda { click_button }.should raise_error(Webrat::NotFoundError) @@ -22,9 +26,11 @@ describe "click_button" do it "should fail if button is disabled" do with_html <<-HTML + + HTML lambda { click_button }.should raise_error(Webrat::DisabledFieldError) @@ -32,9 +38,11 @@ describe "click_button" do it "should default to get method" do with_html <<-HTML + + HTML webrat_session.should_receive(:get) click_button @@ -42,9 +50,11 @@ describe "click_button" do it "should assert valid response" do with_html <<-HTML + + HTML webrat_session.response_code = 501 lambda { click_button }.should raise_error(Webrat::PageLoadError) @@ -53,9 +63,11 @@ describe "click_button" do [200, 300, 400, 499].each do |status| it "should consider the #{status} status code as success" do with_html <<-HTML + + HTML webrat_session.response_code = status lambda { click_button }.should_not raise_error @@ -64,12 +76,14 @@ describe "click_button" do it "should submit the first form by default" do with_html <<-HTML + + HTML webrat_session.should_receive(:get).with("/form1", {}) click_button @@ -77,10 +91,12 @@ describe "click_button" do it "should not explode on file fields" do with_html <<-HTML + + HTML click_button end @@ -102,9 +118,11 @@ describe "click_button" do it "should use action from form" do with_html <<-HTML + + HTML webrat_session.should_receive(:get).with("/login", {}) click_button @@ -112,9 +130,11 @@ describe "click_button" do it "should use method from form" do with_html <<-HTML + + HTML webrat_session.should_receive(:post) click_button @@ -122,10 +142,12 @@ describe "click_button" do it "should send button as param if it has a name" do with_html <<-HTML + + HTML webrat_session.should_receive(:post).with("/login", "login" => "Login") click_button("Login") @@ -133,10 +155,12 @@ describe "click_button" do it "should not send button as param if it has no name" do with_html <<-HTML + + HTML webrat_session.should_receive(:post).with("/login", {}) click_button("Login") @@ -144,10 +168,12 @@ describe "click_button" do it "should send default password field values" do with_html <<-HTML + + HTML webrat_session.should_receive(:get).with("/login", "user" => {"password" => "mypass"}) click_button @@ -155,10 +181,12 @@ describe "click_button" do it "should send default hidden field values" do with_html <<-HTML + + HTML webrat_session.should_receive(:get).with("/login", "user" => {"email" => "test@example.com"}) click_button @@ -166,10 +194,12 @@ describe "click_button" do it "should send default text field values" do with_html <<-HTML + + HTML webrat_session.should_receive(:get).with("/login", "user" => {"email" => "test@example.com"}) click_button @@ -177,6 +207,7 @@ describe "click_button" do it "should not send disabled field values" do with_html <<-HTML + + HTML webrat_session.should_receive(:get).with("/login", {}) click_button @@ -192,10 +224,12 @@ describe "click_button" do it "should send default checked fields" do with_html <<-HTML + + HTML webrat_session.should_receive(:get).with("/login", "user" => {"tos" => "1"}) click_button @@ -203,6 +237,7 @@ describe "click_button" do it "should send default radio options" do with_html <<-HTML + + HTML webrat_session.should_receive(:get).with("/login", "user" => {"gender" => "F"}) click_button @@ -217,11 +253,13 @@ describe "click_button" do it "should send correct data for rails style unchecked fields" do with_html <<-HTML + + HTML webrat_session.should_receive(:get).with("/login", "user" => {"tos" => "0"}) click_button @@ -229,11 +267,13 @@ describe "click_button" do it "should send correct data for rails style checked fields" do with_html <<-HTML + + HTML webrat_session.should_receive(:get).with("/login", "user" => {"tos" => "1"}) click_button @@ -241,6 +281,7 @@ describe "click_button" do it "should send default collection fields" do with_html <<-HTML + + HTML webrat_session.should_receive(:post).with("/login", "options" => ["burger", "fries", "soda", "soda", "dessert"], @@ -263,10 +305,12 @@ describe "click_button" do it "should not send default unchecked fields" do with_html <<-HTML + + HTML webrat_session.should_receive(:get).with("/login", {}) click_button @@ -274,10 +318,12 @@ describe "click_button" do it "should send default textarea values" do with_html <<-HTML + + HTML webrat_session.should_receive(:post).with("/posts", "post" => {"body" => "Post body here!"}) click_button @@ -285,6 +331,7 @@ describe "click_button" do it "should send default selected option value from select" do with_html <<-HTML + + HTML webrat_session.should_receive(:get).with("/login", "month" => "2") click_button @@ -299,6 +347,7 @@ describe "click_button" do it "should send default selected option inner html from select when no value attribute" do with_html <<-HTML + + HTML webrat_session.should_receive(:get).with("/login", "month" => "February") click_button @@ -313,6 +363,7 @@ describe "click_button" do it "should send first select option value when no option selected" do with_html <<-HTML + + HTML webrat_session.should_receive(:get).with("/login", "month" => "1") click_button @@ -327,11 +379,13 @@ describe "click_button" do it "should handle nested properties" do with_html <<-HTML + + HTML webrat_session.should_receive(:post).with("/login", "contestant" => {"scores" => {'1' => '2', '3' => '4'}}) click_button @@ -339,10 +393,12 @@ describe "click_button" do it "should send default empty text field values" do with_html <<-HTML + + HTML webrat_session.should_receive(:get).with("/login", "user" => {"email" => ""}) click_button @@ -350,10 +406,12 @@ describe "click_button" do it "should recognize button tags" do with_html <<-HTML + + HTML webrat_session.should_receive(:get).with("/login", "user" => {"email" => ""}) click_button @@ -361,9 +419,11 @@ describe "click_button" do it "should recognize image button tags" do with_html <<-HTML + + HTML webrat_session.should_receive(:get) click_button @@ -371,9 +431,11 @@ describe "click_button" do it "should find buttons by their IDs" do with_html <<-HTML + + HTML webrat_session.should_receive(:get) click_button "my_button" @@ -381,9 +443,11 @@ describe "click_button" do it "should find image buttons by their alt text" do with_html <<-HTML + + HTML webrat_session.should_receive(:get) click_button "Go" @@ -391,10 +455,12 @@ describe "click_button" do it "should recognize button tags by content" do with_html <<-HTML + + HTML webrat_session.should_receive(:get).with("/login", "user" => {"email" => ""}) click_button "Login" diff --git a/spec/api/click_link_spec.rb b/spec/api/click_link_spec.rb index a7aace4..f602d94 100644 --- a/spec/api/click_link_spec.rb +++ b/spec/api/click_link_spec.rb @@ -3,7 +3,9 @@ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper") describe "click_link" do it "should click links with ampertands" do with_html <<-HTML + Save & go back + HTML webrat_session.should_receive(:get).with("/page", {}) click_link "Save & go back" @@ -11,7 +13,9 @@ describe "click_link" do it "should use get by default" do with_html <<-HTML + Link text + HTML webrat_session.should_receive(:get).with("/page", {}) click_link "Link text" @@ -19,7 +23,9 @@ describe "click_link" do it "should click get links" do with_html <<-HTML + Link text + HTML webrat_session.should_receive(:get).with("/page", {}) click_link "Link text", :method => :get @@ -27,7 +33,9 @@ describe "click_link" do it "should click link on substring" do with_html <<-HTML + Link text + HTML webrat_session.should_receive(:get).with("/page", {}) click_link "ink tex", :method => :get @@ -35,7 +43,9 @@ describe "click_link" do it "should click delete links" do with_html <<-HTML + Link text + HTML webrat_session.should_receive(:delete).with("/page", {}) click_link "Link text", :method => :delete @@ -44,7 +54,9 @@ describe "click_link" do it "should click post links" do with_html <<-HTML + Link text + HTML webrat_session.should_receive(:post).with("/page", {}) click_link "Link text", :method => :post @@ -52,7 +64,9 @@ describe "click_link" do it "should click put links" do with_html <<-HTML + Link text + HTML webrat_session.should_receive(:put).with("/page", {}) click_link "Link text", :method => :put @@ -60,7 +74,9 @@ describe "click_link" do it "should click links by regexp" do with_html <<-HTML + Link text + HTML webrat_session.should_receive(:get).with("/page", {}) click_link /link [a-z]/i @@ -68,7 +84,9 @@ describe "click_link" do it "should click links by id" do with_html <<-HTML + Link text + HTML webrat_session.should_receive(:get).with("/page", {}) click_link "link_text_link" @@ -76,7 +94,9 @@ describe "click_link" do it "should click links by id regexp" do with_html <<-HTML + Link text + HTML webrat_session.should_receive(:get).with("/page", {}) click_link /_text_/ @@ -84,6 +104,7 @@ describe "click_link" do it "should click rails javascript links with authenticity tokens" do with_html <<-HTML + Posts + HTML webrat_session.should_receive(:post).with("/posts", "authenticity_token" => "aa79cb354597a60a3786e7e291ed4f74d77d3a62") click_link "Posts" @@ -103,6 +125,7 @@ describe "click_link" do it "should click rails javascript delete links" do with_html <<-HTML + Delete + HTML webrat_session.should_receive(:delete).with("/posts/1", {}) click_link "Delete" @@ -122,6 +146,7 @@ describe "click_link" do it "should click rails javascript post links" do with_html <<-HTML + Posts + HTML webrat_session.should_receive(:post).with("/posts", {}) click_link "Posts" @@ -136,6 +162,7 @@ describe "click_link" do it "should click rails javascript post links without javascript" do with_html <<-HTML + Posts + HTML webrat_session.should_receive(:get).with("/posts", {}) click_link "Posts", :javascript => false @@ -150,6 +178,7 @@ describe "click_link" do it "should click rails javascript put links" do with_html <<-HTML + Put + HTML webrat_session.should_receive(:put).with("/posts", {}) click_link "Put" @@ -169,6 +199,7 @@ describe "click_link" do it "should fail if the javascript link doesn't have a value for the _method input" do with_html <<-HTML + Link + HTML lambda { @@ -189,7 +221,9 @@ describe "click_link" do it "should assert valid response" do with_html <<-HTML + Link text + HTML webrat_session.response_code = 501 lambda { click_link "Link text" }.should raise_error(Webrat::PageLoadError) @@ -198,7 +232,9 @@ describe "click_link" do [200, 300, 400, 499].each do |status| it "should consider the #{status} status code as success" do with_html <<-HTML + Link text + HTML webrat_session.response_code = status lambda { click_link "Link text" }.should_not raise_error @@ -207,7 +243,9 @@ describe "click_link" do it "should fail is the link doesn't exist" do with_html <<-HTML + Link text + HTML lambda { @@ -217,7 +255,9 @@ describe "click_link" do it "should not be case sensitive" do with_html <<-HTML + Link text + HTML webrat_session.should_receive(:get).with("/page", {}) click_link "LINK TEXT" @@ -225,7 +265,9 @@ describe "click_link" do it "should match link substrings" do with_html <<-HTML + This is some cool link text, isn't it? + HTML webrat_session.should_receive(:get).with("/page", {}) click_link "Link text" @@ -233,7 +275,9 @@ describe "click_link" do it "should work with elements in the link" do with_html <<-HTML + Link text + HTML webrat_session.should_receive(:get).with("/page", {}) click_link "Link text" @@ -241,8 +285,10 @@ describe "click_link" do it "should match the first matching link" do with_html <<-HTML + Link text Link text + HTML webrat_session.should_receive(:get).with("/page1", {}) click_link "Link text" @@ -250,10 +296,10 @@ describe "click_link" do it "should choose the shortest link text match" do with_html <<-HTML - - Linkerama - Link - + + Linkerama + Link + HTML webrat_session.should_receive(:get).with("/page2", {}) @@ -262,9 +308,9 @@ describe "click_link" do it "should treat non-breaking spaces as spaces" do with_html <<-HTML - - This is a link - + + This is a link + HTML webrat_session.should_receive(:get).with("/page1", {}) @@ -274,8 +320,10 @@ describe "click_link" do it "should not match on non-text contents" do pending "needs fix" do with_html <<-HTML - My house - Location + + My house + Location + HTML webrat_session.should_receive(:get).with("/page2", {}) @@ -286,10 +334,10 @@ describe "click_link" do it "should click link within a selector" do with_html <<-HTML - Link -