Switch from Mocha to RSpec mocks

This commit is contained in:
Bryan Helmkamp 2008-07-25 19:11:56 -04:00
parent af0ac0933a
commit 2e20267c90
13 changed files with 112 additions and 141 deletions

View File

@ -258,8 +258,17 @@ module Webrat
if @value.nil?
super
else
file = content_type ? ActionController::TestUploadedFile.new(@value, content_type) : ActionController::TestUploadedFile.new(@value)
replace_param_value(super, @value, file)
replace_param_value(super, @value, test_uploaded_file)
end
end
protected
def test_uploaded_file
if content_type
ActionController::TestUploadedFile.new(@value, content_type)
else
ActionController::TestUploadedFile.new(@value)
end
end

View File

@ -5,8 +5,8 @@ describe "attaches_file" do
@session = Webrat::TestSession.new
@filename = __FILE__
@uploaded_file = mock
ActionController::TestUploadedFile.stubs(:new).returns(@uploaded_file)
@uploaded_file = mock("uploaded file")
ActionController::TestUploadedFile.stub!(:new).and_return(@uploaded_file)
end
it "should fail if no file field found" do
@ -24,7 +24,7 @@ describe "attaches_file" do
<input type="submit" />
</form>
EOS
@session.expects(:post).with("/widgets", { "widget" => { "file" => "" } })
@session.should_receive(:post).with("/widgets", { "widget" => { "file" => "" } })
@session.clicks_button
end
@ -36,7 +36,7 @@ describe "attaches_file" do
<input type="submit" />
</form>
EOS
@session.expects(:post).with("/widgets", { "widget" => { "file" => @uploaded_file } })
@session.should_receive(:post).with("/widgets", { "widget" => { "file" => @uploaded_file } })
@session.attaches_file "Document", @filename
@session.clicks_button
end
@ -51,7 +51,7 @@ describe "attaches_file" do
<input type="submit" />
</form>
EOS
@session.expects(:post).with("/widgets", { "widget" => { "files" => [@uploaded_file, @uploaded_file] } })
@session.should_receive(:post).with("/widgets", { "widget" => { "files" => [@uploaded_file, @uploaded_file] } })
@session.attaches_file "Document", @filename
@session.attaches_file "Spreadsheet", @filename
@session.clicks_button
@ -65,7 +65,7 @@ describe "attaches_file" do
<input type="submit" />
</form>
EOS
ActionController::TestUploadedFile.expects(:new).with(@filename, "image/png").returns(@uploaded_file)
ActionController::TestUploadedFile.should_receive(:new).with(@filename, "image/png").any_number_of_times
@session.attaches_file "Picture", @filename, "image/png"
@session.clicks_button
end

View File

@ -33,7 +33,7 @@ describe "checks" do
<input type="submit" />
</form>
EOS
@session.expects(:get).with("/login", "user" => {"tos" => "1"})
@session.should_receive(:get).with("/login", "user" => {"tos" => "1"})
@session.checks "TOS"
@session.clicks_button
end
@ -45,7 +45,7 @@ describe "checks" do
<input type="submit" />
</form>
EOS
@session.expects(:post).with("/login", "remember_me" => "on")
@session.should_receive(:post).with("/login", "remember_me" => "on")
@session.checks "remember_me"
@session.clicks_button
end
@ -57,7 +57,7 @@ describe "checks" do
<input type="submit" />
</form>
EOS
@session.expects(:post).with("/login", "remember_me" => "yes")
@session.should_receive(:post).with("/login", "remember_me" => "yes")
@session.checks "remember_me"
@session.clicks_button
end
@ -96,7 +96,7 @@ describe "unchecks" do
<input type="submit" />
</form>
EOS
@session.expects(:get).with("/login", "user" => {"tos" => "0"})
@session.should_receive(:get).with("/login", "user" => {"tos" => "0"})
@session.checks "TOS"
@session.unchecks "TOS"
@session.clicks_button
@ -109,7 +109,7 @@ describe "unchecks" do
<input type="submit" />
</form>
EOS
@session.expects(:post).with("/login", {})
@session.should_receive(:post).with("/login", {})
@session.unchecks "remember_me"
@session.clicks_button
end

View File

@ -34,24 +34,7 @@ describe "chooses" do
<input type="submit" />
</form>
EOS
@session.expects(:get).with("/login", "user" => {"gender" => "M"})
@session.chooses "Male"
@session.clicks_button
end
it "should use any of the button's labels" do
@session.response_body = <<-EOS
<form method="get" action="/login">
<label for="user_gender_male"><img src="male.jpg" /></label>
<input id="user_gender_male" name="user[gender]" type="radio" value="M" />
<label for="user_gender_male">Male</label>
<label for="user_gender_female"><img src="female.jpg" /></label>
<input id="user_gender_female" name="user[gender]" type="radio" value="F" />
<label for="user_gender_female">Female</label>
<input type="submit" />
</form>
EOS
@session.expects(:get).with("/login", "user" => {"gender" => "M"})
@session.should_receive(:get).with("/login", "user" => {"gender" => "M"})
@session.chooses "Male"
@session.clicks_button
end
@ -66,7 +49,7 @@ describe "chooses" do
<input type="submit" />
</form>
EOS
@session.expects(:get).with("/login", "user" => {"gender" => "M"})
@session.should_receive(:get).with("/login", "user" => {"gender" => "M"})
@session.chooses "Female"
@session.chooses "Male"
@session.clicks_button
@ -79,7 +62,7 @@ describe "chooses" do
<input type="submit" />
</form>
EOS
@session.expects(:post).with("/login", "first_option" => "on")
@session.should_receive(:post).with("/login", "first_option" => "on")
@session.chooses "first_option"
@session.clicks_button
end
@ -91,7 +74,7 @@ describe "chooses" do
<input type="submit" />
</form>
EOS
@session.expects(:post).with("/login", "first_option" => "on")
@session.should_receive(:post).with("/login", "first_option" => "on")
@session.clicks_button
end
end

View File

@ -29,7 +29,7 @@ describe "clicks_button" do
<input type="submit" />
</form>
EOS
@session.expects(:get)
@session.should_receive(:get)
@session.clicks_button
end
@ -52,7 +52,7 @@ describe "clicks_button" do
<input type="submit" />
</form>
EOS
@session.expects(:get).with("/form1", {})
@session.should_receive(:get).with("/form1", {})
@session.clicks_button
end
@ -75,7 +75,7 @@ describe "clicks_button" do
<input type="submit" value="Form2" />
</form>
EOS
@session.expects(:get).with("/form2", {})
@session.should_receive(:get).with("/form2", {})
@session.clicks_button "Form2"
end
@ -85,7 +85,7 @@ describe "clicks_button" do
<input type="submit" />
</form>
EOS
@session.expects(:get).with("/login", {})
@session.should_receive(:get).with("/login", {})
@session.clicks_button
end
@ -95,7 +95,7 @@ describe "clicks_button" do
<input type="submit" />
</form>
EOS
@session.expects(:post)
@session.should_receive(:post)
@session.clicks_button
end
@ -106,7 +106,7 @@ describe "clicks_button" do
<input type="submit" name="login" value="Login" />
</form>
EOS
@session.expects(:post).with("/login", "login" => "Login")
@session.should_receive(:post).with("/login", "login" => "Login")
@session.clicks_button("Login")
end
@ -117,7 +117,7 @@ describe "clicks_button" do
<input type="submit" value="Login" />
</form>
EOS
@session.expects(:post).with("/login", {})
@session.should_receive(:post).with("/login", {})
@session.clicks_button("Login")
end
@ -128,7 +128,7 @@ describe "clicks_button" do
<input type="submit" />
</form>
EOS
@session.expects(:get).with("/login", "user" => {"password" => "mypass"})
@session.should_receive(:get).with("/login", "user" => {"password" => "mypass"})
@session.clicks_button
end
@ -139,7 +139,7 @@ describe "clicks_button" do
<input type="submit" />
</form>
EOS
@session.expects(:get).with("/login", "user" => {"email" => "test@example.com"})
@session.should_receive(:get).with("/login", "user" => {"email" => "test@example.com"})
@session.clicks_button
end
@ -150,7 +150,7 @@ describe "clicks_button" do
<input type="submit" />
</form>
EOS
@session.expects(:get).with("/login", "user" => {"email" => "test@example.com"})
@session.should_receive(:get).with("/login", "user" => {"email" => "test@example.com"})
@session.clicks_button
end
@ -161,7 +161,7 @@ describe "clicks_button" do
<input type="submit" />
</form>
EOS
@session.expects(:get).with("/login", "user" => {"tos" => "1"})
@session.should_receive(:get).with("/login", "user" => {"tos" => "1"})
@session.clicks_button
end
@ -175,7 +175,7 @@ describe "clicks_button" do
<input type="submit" />
</form>
EOS
@session.expects(:get).with("/login", "user" => {"gender" => "F"})
@session.should_receive(:get).with("/login", "user" => {"gender" => "F"})
@session.clicks_button
end
@ -187,7 +187,7 @@ describe "clicks_button" do
<input type="submit" />
</form>
EOS
@session.expects(:get).with("/login", "user" => {"tos" => "0"})
@session.should_receive(:get).with("/login", "user" => {"tos" => "0"})
@session.clicks_button
end
@ -199,7 +199,7 @@ describe "clicks_button" do
<input type="submit" />
</form>
EOS
@session.expects(:get).with("/login", "user" => {"tos" => "1"})
@session.should_receive(:get).with("/login", "user" => {"tos" => "1"})
@session.clicks_button
end
@ -219,7 +219,7 @@ describe "clicks_button" do
<input type="submit" />
</form>
EOS
@session.expects(:post).with("/login",
@session.should_receive(:post).with("/login",
"options" => ["burger", "fries", "soda", "soda", "dessert"],
"response" => { "choices" => [{"selected" => "one"}, {"selected" => "two"}, {"selected" => "two"}]})
@session.clicks_button
@ -232,7 +232,7 @@ describe "clicks_button" do
<input type="submit" />
</form>
EOS
@session.expects(:get).with("/login", {})
@session.should_receive(:get).with("/login", {})
@session.clicks_button
end
@ -243,7 +243,7 @@ describe "clicks_button" do
<input type="submit" />
</form>
EOS
@session.expects(:post).with("/posts", "post" => {"body" => "Post body here!"})
@session.should_receive(:post).with("/posts", "post" => {"body" => "Post body here!"})
@session.clicks_button
end
@ -257,7 +257,7 @@ describe "clicks_button" do
<input type="submit" />
</form>
EOS
@session.expects(:get).with("/login", "month" => "2")
@session.should_receive(:get).with("/login", "month" => "2")
@session.clicks_button
end
@ -271,7 +271,7 @@ describe "clicks_button" do
<input type="submit" />
</form>
EOS
@session.expects(:get).with("/login", "month" => "February")
@session.should_receive(:get).with("/login", "month" => "February")
@session.clicks_button
end
@ -285,7 +285,7 @@ describe "clicks_button" do
<input type="submit" />
</form>
EOS
@session.expects(:get).with("/login", "month" => "1")
@session.should_receive(:get).with("/login", "month" => "1")
@session.clicks_button
end
@ -297,7 +297,7 @@ describe "clicks_button" do
<input type="submit" />
</form>
EOS
@session.expects(:post).with("/login", "contestant" => {"scores" => {'1' => '2', '3' => '4'}})
@session.should_receive(:post).with("/login", "contestant" => {"scores" => {'1' => '2', '3' => '4'}})
@session.clicks_button
end
@ -308,7 +308,7 @@ describe "clicks_button" do
<input type="submit" />
</form>
EOS
@session.expects(:get).with("/login", "user" => {"email" => ""})
@session.should_receive(:get).with("/login", "user" => {"email" => ""})
@session.clicks_button
end
@ -319,7 +319,7 @@ describe "clicks_button" do
<button type="submit" />
</form>
EOS
@session.expects(:get).with("/login", "user" => {"email" => ""})
@session.should_receive(:get).with("/login", "user" => {"email" => ""})
@session.clicks_button
end
@ -329,7 +329,7 @@ describe "clicks_button" do
<input type="image" />
</form>
EOS
@session.expects(:get)
@session.should_receive(:get)
@session.clicks_button
end
@ -339,7 +339,7 @@ describe "clicks_button" do
<input type="image" alt="Go" />
</form>
EOS
@session.expects(:get)
@session.should_receive(:get)
@session.clicks_button "Go"
end
@ -350,7 +350,7 @@ describe "clicks_button" do
<button type="submit">Login</button>
</form>
EOS
@session.expects(:get).with("/login", "user" => {"email" => ""})
@session.should_receive(:get).with("/login", "user" => {"email" => ""})
@session.clicks_button "Login"
end
end

View File

@ -9,7 +9,7 @@ describe "clicks_link" do
@session.response_body = <<-EOS
<a href="/page">Link text</a>
EOS
@session.expects(:get).with("/page", {})
@session.should_receive(:get).with("/page", {})
@session.clicks_link "Link text"
end
@ -17,7 +17,7 @@ describe "clicks_link" do
@session.response_body = <<-EOS
<a href="/page">Link text</a>
EOS
@session.expects(:get).with("/page", {})
@session.should_receive(:get).with("/page", {})
@session.clicks_get_link "Link text"
end
@ -25,7 +25,7 @@ describe "clicks_link" do
@session.response_body = <<-EOS
<a href="/page">Link text</a>
EOS
@session.expects(:delete).with("/page", {})
@session.should_receive(:delete).with("/page", {})
@session.clicks_delete_link "Link text"
end
@ -33,7 +33,7 @@ describe "clicks_link" do
@session.response_body = <<-EOS
<a href="/page">Link text</a>
EOS
@session.expects(:post).with("/page", {})
@session.should_receive(:post).with("/page", {})
@session.clicks_post_link "Link text"
end
@ -41,7 +41,7 @@ describe "clicks_link" do
@session.response_body = <<-EOS
<a href="/page">Link text</a>
EOS
@session.expects(:put).with("/page", {})
@session.should_receive(:put).with("/page", {})
@session.clicks_put_link "Link text"
end
@ -60,7 +60,7 @@ describe "clicks_link" do
f.submit();
return false;">Posts</a>
EOS
@session.expects(:post).with("/posts", "authenticity_token" => "aa79cb354597a60a3786e7e291ed4f74d77d3a62")
@session.should_receive(:post).with("/posts", "authenticity_token" => "aa79cb354597a60a3786e7e291ed4f74d77d3a62")
@session.clicks_link "Posts"
end
@ -79,7 +79,7 @@ describe "clicks_link" do
f.submit();
return false;">Delete</a>
EOS
@session.expects(:delete).with("/posts/1", {})
@session.should_receive(:delete).with("/posts/1", {})
@session.clicks_link "Delete"
end
@ -93,7 +93,7 @@ describe "clicks_link" do
f.submit();
return false;">Posts</a>
EOS
@session.expects(:post).with("/posts", {})
@session.should_receive(:post).with("/posts", {})
@session.clicks_link "Posts"
end
@ -107,7 +107,7 @@ describe "clicks_link" do
f.submit();
return false;">Posts</a>
EOS
@session.expects(:get).with("/posts", {})
@session.should_receive(:get).with("/posts", {})
@session.clicks_link "Posts", :javascript => false
end
@ -126,7 +126,7 @@ describe "clicks_link" do
f.submit();
return false;">Put</a></h2>
EOS
@session.expects(:put).with("/posts", {})
@session.should_receive(:put).with("/posts", {})
@session.clicks_link "Put"
end
@ -142,7 +142,7 @@ describe "clicks_link" do
@session.response_body = <<-EOS
<a href="/page">Link text</a>
EOS
@session.expects(:get).with("/page", {})
@session.should_receive(:get).with("/page", {})
@session.clicks_link "LINK TEXT"
end
@ -150,7 +150,7 @@ describe "clicks_link" do
@session.response_body = <<-EOS
<a href="/page">This is some cool link text, isn't it?</a>
EOS
@session.expects(:get).with("/page", {})
@session.should_receive(:get).with("/page", {})
@session.clicks_link "Link text"
end
@ -158,24 +158,16 @@ describe "clicks_link" do
@session.response_body = <<-EOS
<a href="/page"><span>Link text</span></a>
EOS
@session.expects(:get).with("/page", {})
@session.should_receive(:get).with("/page", {})
@session.clicks_link "Link text"
end
it "should work with anchor titles" do
@session.response_body = <<-EOS
<a href="/page" title="Link title">Link text</a>
EOS
@session.expects(:get).with("/page", {})
@session.clicks_link "Link title"
end
it "should match the first matching link" do
@session.response_body = <<-EOS
<a href="/page1">Link text</a>
<a href="/page2">Link text</a>
EOS
@session.expects(:get).with("/page1", {})
@session.should_receive(:get).with("/page1", {})
@session.clicks_link "Link text"
end
@ -185,7 +177,7 @@ describe "clicks_link" do
<a href="/page2">Link</a>
EOS
@session.expects(:get).with("/page2", {})
@session.should_receive(:get).with("/page2", {})
@session.clicks_link "Link"
end
@ -197,7 +189,7 @@ describe "clicks_link" do
</div>
EOS
@session.expects(:get).with("/page2", {})
@session.should_receive(:get).with("/page2", {})
@session.clicks_link_within "#container", "Link"
end
@ -205,17 +197,17 @@ describe "clicks_link" do
@session.response_body = <<-EOS
<a href="#section-1">Jump to Section 1</a>
EOS
# Don't know why @session.expects(:get).never doesn't work here
@session.expects(:send).with('get_via_redirect', '#section-1', {}).never
# Don't know why @session.should_receive(:get).never doesn't work here
@session.should_receive(:send).with('get_via_redirect', '#section-1', {}).never
@session.clicks_link "Jump to Section 1"
end
it "should follow relative links" do
@session.current_page.stubs(:url).returns("/page")
@session.current_page.stub!(:url).and_return("/page")
@session.response_body = <<-EOS
<a href="sub">Jump to sub page</a>
EOS
@session.expects(:get).with("/page/sub", {})
@session.should_receive(:get).with("/page/sub", {})
@session.clicks_link "Jump to sub page"
end
@ -223,16 +215,16 @@ describe "clicks_link" do
@session.response_body = <<-EOS
<a href="http://www.example.com/page/sub">Jump to sub page</a>
EOS
@session.expects(:get).with("/page/sub", {})
@session.should_receive(:get).with("/page/sub", {})
@session.clicks_link "Jump to sub page"
end
it "should follow query parameters" do
@session.current_page.stubs(:url).returns("/page")
@session.current_page.stub!(:url).and_return("/page")
@session.response_body = <<-EOS
<a href="?foo=bar">Jump to foo bar</a>
EOS
@session.expects(:get).with("/page?foo=bar", {})
@session.should_receive(:get).with("/page?foo=bar", {})
@session.clicks_link "Jump to foo bar"
end
end

View File

@ -13,7 +13,7 @@ describe "fills_in" do
<input type="submit" />
</form>
EOS
@session.expects(:post).with("/login", "user" => {"text" => "filling text area"})
@session.should_receive(:post).with("/login", "user" => {"text" => "filling text area"})
@session.fills_in "User Text", :with => "filling text area"
@session.clicks_button
end
@ -25,7 +25,7 @@ describe "fills_in" do
<input type="submit" />
</form>
EOS
@session.expects(:post).with("/login", "user" => {"text" => "pass"})
@session.should_receive(:post).with("/login", "user" => {"text" => "pass"})
@session.fills_in "user_text", :with => "pass"
@session.clicks_button
end
@ -47,7 +47,7 @@ describe "fills_in" do
<input type="submit" />
</form>
EOS
@session.expects(:post).with("/login", "user" => {"email" => "foo@example.com"})
@session.should_receive(:post).with("/login", "user" => {"email" => "foo@example.com"})
@session.fills_in "user[email]", :with => "foo@example.com"
@session.clicks_button
end
@ -63,7 +63,7 @@ describe "fills_in" do
</form>
EOS
@session.expects(:post).with("/login", "user" => {"mail1" => "", "mail2" => "value"})
@session.should_receive(:post).with("/login", "user" => {"mail1" => "", "mail2" => "value"})
@session.fills_in "Some", :with => "value"
@session.clicks_button
end
@ -79,24 +79,11 @@ describe "fills_in" do
</form>
EOS
@session.expects(:post).with("/login", "user" => {"mail1" => "value", "mail2" => ""})
@session.should_receive(:post).with("/login", "user" => {"mail1" => "value", "mail2" => ""})
@session.fills_in "Some mail", :with => "value"
@session.clicks_button
end
it "should support unlabelled inputs" do # regression test
@session.response_body = <<-EOS
<form method="post" action="/login">
<input id="user_name" name="user[name]" value="test person" type="text" />
<label for="user_email">email</label>
<input id="user_email" name="user[email]" value="test@example.com" type="text" />
<input id="user_address" name="user[address]" value="123 some street" type="text" />
</form>
EOS
lambda { @session.fills_in "email", :with => "value" }.should_not raise_error
end
it "should anchor label matches to start of label" do
@session.response_body = <<-EOS
<form method="post" action="/login">
@ -129,7 +116,7 @@ describe "fills_in" do
<input type="submit" />
</form>
EOS
@session.expects(:post).with("/login", "user" => {"email" => "foo@example.com"})
@session.should_receive(:post).with("/login", "user" => {"email" => "foo@example.com"})
@session.fills_in "Email", :with => "foo@example.com"
@session.clicks_button
end
@ -141,7 +128,7 @@ describe "fills_in" do
<input type="submit" />
</form>
EOS
@session.expects(:post).with("/login", "user" => {"email" => "foo@example.com"})
@session.should_receive(:post).with("/login", "user" => {"email" => "foo@example.com"})
@session.fills_in "user[email]", :with => "foo@example.com"
@session.clicks_button
end
@ -154,7 +141,7 @@ describe "fills_in" do
<input type="submit" />
</form>
EOS
@session.expects(:post).with("/login", "user" => {"email" => "foo@example.com"})
@session.should_receive(:post).with("/login", "user" => {"email" => "foo@example.com"})
@session.fills_in :email, :with => "foo@example.com"
@session.clicks_button
end

View File

@ -7,7 +7,7 @@ describe "reloads" do
end
it "should reload the page" do
@session.expects(:get).with("/", {}).times(2)
@session.should_receive(:get).with("/", {}).twice
@session.visits("/")
@session.reloads
end

View File

@ -16,33 +16,33 @@ describe "save_and_open_page" do
</html>
HTML
File.stubs(:exist?).returns(true)
Time.stubs(:now).returns(1234)
Webrat::Page.any_instance.stubs(:open_in_browser)
File.stub!(:exist?).and_return(true)
Time.stub!(:now).and_return(1234)
@session.current_page.stub!(:open_in_browser)
@file_handle = mock()
File.stubs(:open).with(filename, 'w').yields(@file_handle)
@file_handle.stubs(:write)
@file_handle = mock("file handle")
File.stub!(:open).with(filename, 'w').and_yield(@file_handle)
@file_handle.stub!(:write)
end
it "should rewrite css rules" do
@file_handle.expects(:write).with do |html|
html =~ %r|#{@session.doc_root}/stylesheets/foo.css|s
@file_handle.should_receive(:write) do |html|
html.should =~ %r|#{@session.doc_root}/stylesheets/foo.css|s
end
@session.save_and_open_page
end
it "should rewrite image paths" do
@file_handle.expects(:write).with do |html|
html =~ %r|#{@session.doc_root}/images/bar.png|s
@file_handle.should_receive(:write) do |html|
html.should =~ %r|#{@session.doc_root}/images/bar.png|s
end
@session.save_and_open_page
end
it "should open the temp file in a browser" do
Webrat::Page.any_instance.expects(:open_in_browser).with(filename)
@session.current_page.should_receive(:open_in_browser).with(filename)
@session.save_and_open_page
end

View File

@ -43,7 +43,7 @@ describe "selects" do
<input type="submit" />
</form>
EOS
@session.expects(:post).with("/login", "month" => "1")
@session.should_receive(:post).with("/login", "month" => "1")
@session.selects "January", :from => "month"
@session.clicks_button
end
@ -55,7 +55,7 @@ describe "selects" do
<input type="submit" />
</form>
EOS
@session.expects(:post).with("/login", "encoded" => "A & B")
@session.should_receive(:post).with("/login", "encoded" => "A & B")
@session.selects "Encoded", :from => "encoded"
@session.clicks_button
end
@ -67,7 +67,7 @@ describe "selects" do
<input type="submit" />
</form>
EOS
@session.expects(:post).with("/login", 'month' => '')
@session.should_receive(:post).with("/login", 'month' => '')
@session.clicks_button
end
@ -78,7 +78,7 @@ describe "selects" do
<input type="submit" />
</form>
EOS
@session.expects(:post).with("/login", "month" => "1")
@session.should_receive(:post).with("/login", "month" => "1")
@session.selects "January"
@session.clicks_button
end
@ -91,7 +91,7 @@ describe "selects" do
<input type="submit" />
</form>
EOS
@session.expects(:post).with("/login", "start_month" => "s1", "end_month" => "e1")
@session.should_receive(:post).with("/login", "start_month" => "s1", "end_month" => "e1")
@session.selects "January", :from => "end_month"
@session.clicks_button
end
@ -106,7 +106,7 @@ describe "selects" do
<input type="submit" />
</form>
EOS
@session.expects(:post).with("/login", "start_month" => "s1", "end_month" => "e1")
@session.should_receive(:post).with("/login", "start_month" => "s1", "end_month" => "e1")
@session.selects "January", :from => "End Month"
@session.clicks_button
end
@ -118,7 +118,7 @@ describe "selects" do
<input type="submit" />
</form>
EOS
@session.expects(:post).with("/login", "month" => "January")
@session.should_receive(:post).with("/login", "month" => "January")
@session.selects "January", :from => "month"
@session.clicks_button
end
@ -130,7 +130,7 @@ describe "selects" do
<input type="submit" />
</form>
EOS
@session.expects(:post).with("/login", "month" => "January")
@session.should_receive(:post).with("/login", "month" => "January")
@session.selects(/jan/i)
@session.clicks_button
end
@ -145,7 +145,7 @@ describe "selects" do
<input type="submit" />
</form>
EOS
@session.expects(:post).with("/login", "start_month" => "s1", "end_month" => "e1")
@session.should_receive(:post).with("/login", "start_month" => "s1", "end_month" => "e1")
@session.selects(/jan/i, :from => "End Month")
@session.clicks_button
end

View File

@ -7,7 +7,7 @@ describe "visits" do
end
it "should use get" do
@session.expects(:get).with("/", {})
@session.should_receive(:get).with("/", {})
@session.visits("/")
end

View File

@ -1,12 +1,12 @@
# it "should default to current url" do
# # @session.current_page.stubs(:url).returns("/page")
# # @session.current_page.stub!(:url).and_return("/page")
# @session.response_body = <<-EOS
# <form method="get">
# <input type="submit" />
# </form>
# EOS
# @page.stubs(:url).returns("/current")
# @session.expects(:get).with("/current", {})
# @page.stub!(:url).and_return("/current")
# @session.should_receive(:get).with("/current", {})
# @session.clicks_button
# end
#
@ -14,7 +14,7 @@
# @session.response_body = <<-EOS
# <a href="https://www.example.com/page/sub">Jump to sub page</a>
# EOS
# @session.expects(:https!).with(true)
# @session.expects(:get).with("/page/sub", {})
# @session.should_receive(:https!).with(true)
# @session.should_receive(:get).with("/page/sub", {})
# @session.clicks_link "Jump to sub page"
# end

View File

@ -1,8 +1,8 @@
require "rubygems"
require "spec"
# gem install redgreen for colored test output
begin require "redgreen" unless ENV['TM_CURRENT_LINE']; rescue LoadError; end
require "mocha"
require "active_support"
@ -15,5 +15,5 @@ require File.expand_path(File.dirname(__FILE__) + "/../lib/webrat")
require File.dirname(__FILE__) + "/fakes/test_session"
Spec::Runner.configure do |config|
config.mock_with :mocha
# Nothing to configure yet
end