Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
87 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
require 'rubygems' | ||
require 'spec/rake/spectask' | ||
|
||
Spec::Rake::SpecTask.new do |t| | ||
t.spec_opts = ['--color'] | ||
t.spec_files = FileList['spec/**/*_spec.rb'] | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
require "sample_app" | ||
run SampleApp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
require "rubygems" | ||
require "sinatra/base" | ||
|
||
class SampleApp < Sinatra::Default | ||
get "/" do | ||
"Hello World" | ||
end | ||
|
||
get "/internal_redirect" do | ||
redirect URI.join(request.url, "redirected").to_s | ||
end | ||
|
||
get "/external_redirect" do | ||
redirect "http://example.tst/" | ||
end | ||
|
||
get "/redirected" do | ||
"Redirected" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
require File.dirname(__FILE__) + "/spec_helper" | ||
|
||
describe "Webrat's Mechanize mode" do | ||
it "should work" do | ||
response = visit("http://localhost:9292/") | ||
response.should contain("Hello World") | ||
end | ||
|
||
it "should follow redirects" do | ||
response = visit("http://localhost:9292/internal_redirect") | ||
response.should contain("Redirected") | ||
end | ||
|
||
it "should follow links" | ||
it "should submit forms" | ||
it "should not follow external redirects" do | ||
pending do | ||
response = visit("http://localhost:9292/external_redirect") | ||
response.should contain("Foo") | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
require "rubygems" | ||
require "spec" | ||
|
||
$LOAD_PATH.unshift File.dirname(__FILE__) + "/../../../../lib" | ||
require "webrat" | ||
|
||
Webrat.configure do |config| | ||
config.mode = :mechanize | ||
end | ||
|
||
Spec::Runner.configure do |config| | ||
config.include Webrat::Methods | ||
config.include Webrat::Matchers | ||
|
||
config.before :suite do | ||
if File.exists?("rack.pid") | ||
Process.kill("TERM", File.read("rack.pid").to_i) | ||
end | ||
|
||
system "rackup --daemonize --pid rack.pid config.ru" | ||
end | ||
|
||
config.after :suite do | ||
Process.kill("TERM", File.read("rack.pid").to_i) | ||
end | ||
end | ||
|