Add some missing spec coverage. Bump coverage theshold
This commit is contained in:
parent
87b8e71c94
commit
399a3852a1
2
Rakefile
2
Rakefile
@ -56,7 +56,7 @@ end
|
|||||||
|
|
||||||
require 'spec/rake/verify_rcov'
|
require 'spec/rake/verify_rcov'
|
||||||
RCov::VerifyTask.new(:verify_rcov => :rcov) do |t|
|
RCov::VerifyTask.new(:verify_rcov => :rcov) do |t|
|
||||||
t.threshold = 97.5 # Make sure you have rcov 0.7 or higher!
|
t.threshold = 99.9 # Make sure you have rcov 0.7 or higher!
|
||||||
end
|
end
|
||||||
|
|
||||||
remove_task "default"
|
remove_task "default"
|
||||||
|
@ -3,7 +3,7 @@ module Webrat
|
|||||||
|
|
||||||
def debug_log(message) # :nodoc:
|
def debug_log(message) # :nodoc:
|
||||||
return unless logger
|
return unless logger
|
||||||
logger.debug
|
logger.debug(message)
|
||||||
end
|
end
|
||||||
|
|
||||||
def logger # :nodoc:
|
def logger # :nodoc:
|
||||||
|
@ -131,6 +131,26 @@ describe "clicks_link" do
|
|||||||
@session.clicks_link "Put"
|
@session.clicks_link "Put"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should fail if the javascript link doesn't have a value for the _method input" do
|
||||||
|
@session.response_body = <<-EOS
|
||||||
|
<a href="/posts/1" onclick="var f = document.createElement('form');
|
||||||
|
f.style.display = 'none';
|
||||||
|
this.parentNode.appendChild(f);
|
||||||
|
f.method = 'POST';
|
||||||
|
f.action = this.href;
|
||||||
|
var m = document.createElement('input');
|
||||||
|
m.setAttribute('type', 'hidden');
|
||||||
|
m.setAttribute('name', '_method');
|
||||||
|
f.appendChild(m);
|
||||||
|
f.submit();
|
||||||
|
return false;">Link</a>
|
||||||
|
EOS
|
||||||
|
|
||||||
|
lambda {
|
||||||
|
@session.clicks_link "Link"
|
||||||
|
}.should raise_error
|
||||||
|
end
|
||||||
|
|
||||||
it "should assert valid response" do
|
it "should assert valid response" do
|
||||||
@session.response_body = <<-EOS
|
@session.response_body = <<-EOS
|
||||||
<a href="/page">Link text</a>
|
<a href="/page">Link text</a>
|
||||||
@ -139,6 +159,16 @@ describe "clicks_link" do
|
|||||||
lambda { @session.clicks_link "Link text" }.should raise_error
|
lambda { @session.clicks_link "Link text" }.should raise_error
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should fail is the link doesn't exist" do
|
||||||
|
@session.response_body = <<-EOS
|
||||||
|
<a href="/page">Link text</a>
|
||||||
|
EOS
|
||||||
|
|
||||||
|
lambda {
|
||||||
|
@session.clicks_link "Missing link"
|
||||||
|
}.should raise_error
|
||||||
|
end
|
||||||
|
|
||||||
it "should not be case sensitive" do
|
it "should not be case sensitive" do
|
||||||
@session.response_body = <<-EOS
|
@session.response_body = <<-EOS
|
||||||
<a href="/page">Link text</a>
|
<a href="/page">Link text</a>
|
||||||
|
@ -135,6 +135,19 @@ describe "selects" do
|
|||||||
@session.clicks_button
|
@session.clicks_button
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should fail if no option matching the regexp exists" do
|
||||||
|
@session.response_body = <<-EOS
|
||||||
|
<form method="post" action="/login">
|
||||||
|
<select name="month"><option>January</option></select>
|
||||||
|
<input type="submit" />
|
||||||
|
</form>
|
||||||
|
EOS
|
||||||
|
|
||||||
|
lambda {
|
||||||
|
@session.selects(/feb/i)
|
||||||
|
}.should raise_error
|
||||||
|
end
|
||||||
|
|
||||||
it "should find option by regexp in list specified by label" do
|
it "should find option by regexp in list specified by label" do
|
||||||
@session.response_body = <<-EOS
|
@session.response_body = <<-EOS
|
||||||
<form method="post" action="/login">
|
<form method="post" action="/login">
|
||||||
|
12
spec/webrat/core/logging_spec.rb
Normal file
12
spec/webrat/core/logging_spec.rb
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
|
||||||
|
|
||||||
|
describe Webrat::Logging do
|
||||||
|
include Webrat::Logging
|
||||||
|
|
||||||
|
it "should log to RAILS_DEFAULT_LOGGER" do
|
||||||
|
logger = mock("logger")
|
||||||
|
RAILS_DEFAULT_LOGGER = logger
|
||||||
|
logger.should_receive(:debug).with("Testing")
|
||||||
|
debug_log "Testing"
|
||||||
|
end
|
||||||
|
end
|
33
spec/webrat/core/session_spec.rb
Normal file
33
spec/webrat/core/session_spec.rb
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
|
||||||
|
|
||||||
|
describe Webrat::Session do
|
||||||
|
|
||||||
|
it "should not have a doc_root" do
|
||||||
|
session = Webrat::Session.new
|
||||||
|
session.doc_root.should be_nil
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should expose the current_dom" do
|
||||||
|
session = Webrat::Session.new
|
||||||
|
|
||||||
|
def session.response_body
|
||||||
|
"<html></html>"
|
||||||
|
end
|
||||||
|
|
||||||
|
session.current_dom.should be_an_instance_of(Hpricot::Doc)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should open the page in the browser" do
|
||||||
|
session = Webrat::Session.new
|
||||||
|
session.should_receive(:`).with("open path")
|
||||||
|
session.open_in_browser("path")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should provide a current_page for backwards compatibility" do
|
||||||
|
session = Webrat::Session.new
|
||||||
|
current_page = session.current_page
|
||||||
|
current_page.should_not be_nil
|
||||||
|
current_page.should respond_to(:url)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user