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'
|
||||
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
|
||||
|
||||
remove_task "default"
|
||||
|
@ -19,12 +19,12 @@ module Webrat
|
||||
|
||||
def find_select_option(option_text)
|
||||
select_fields = fields_by_type([SelectField])
|
||||
|
||||
|
||||
select_fields.each do |select_field|
|
||||
result = select_field.find_option(option_text)
|
||||
return result if result
|
||||
end
|
||||
|
||||
|
||||
nil
|
||||
end
|
||||
|
||||
|
@ -3,7 +3,7 @@ module Webrat
|
||||
|
||||
def debug_log(message) # :nodoc:
|
||||
return unless logger
|
||||
logger.debug
|
||||
logger.debug(message)
|
||||
end
|
||||
|
||||
def logger # :nodoc:
|
||||
|
@ -131,6 +131,26 @@ describe "clicks_link" do
|
||||
@session.clicks_link "Put"
|
||||
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
|
||||
@session.response_body = <<-EOS
|
||||
<a href="/page">Link text</a>
|
||||
@ -139,6 +159,16 @@ describe "clicks_link" do
|
||||
lambda { @session.clicks_link "Link text" }.should raise_error
|
||||
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
|
||||
@session.response_body = <<-EOS
|
||||
<a href="/page">Link text</a>
|
||||
|
@ -134,6 +134,19 @@ describe "selects" do
|
||||
@session.selects(/jan/i)
|
||||
@session.clicks_button
|
||||
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
|
||||
@session.response_body = <<-EOS
|
||||
|
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