Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of git@github.com:brynary/webrat
- Loading branch information
Showing
38 changed files
with
749 additions
and
373 deletions.
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
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 |
---|---|---|
@@ -1,47 +1,9 @@ | ||
Dir[File.join(File.dirname(__FILE__), "webrat", "*.rb")].each do |file| | ||
require File.expand_path(file) | ||
end | ||
|
||
module Webrat | ||
VERSION = '0.2.1' | ||
end | ||
|
||
module ActionController | ||
module Integration | ||
class Session | ||
|
||
unless instance_methods.include?("put_via_redirect") | ||
include Webrat::RedirectActions | ||
end | ||
|
||
def current_page | ||
@current_page ||= Webrat::Page.new(self) | ||
end | ||
|
||
def current_page=(new_page) | ||
@current_page = new_page | ||
end | ||
|
||
# Issues a GET request for a page, follows any redirects, and verifies the final page | ||
# load was successful. | ||
# | ||
# Example: | ||
# visits "/" | ||
def visits(*args) | ||
@current_page = Webrat::Page.new(self, *args) | ||
end | ||
|
||
def save_and_open_page | ||
current_page.save_and_open | ||
end | ||
|
||
[:reloads, :fills_in, :clicks_button, :selects, :attaches_file, :chooses, :checks, :unchecks, :clicks_link, :clicks_link_within, :clicks_put_link, :clicks_get_link, :clicks_post_link, :clicks_delete_link].each do |method_name| | ||
define_method(method_name) do |*args| | ||
current_page.send(method_name, *args) | ||
end | ||
end | ||
|
||
end | ||
end | ||
end | ||
require "rubygems" | ||
require "active_support" | ||
|
||
require File.dirname(__FILE__) + "/webrat/core" | ||
require File.dirname(__FILE__) + "/webrat/rails" if defined?(RAILS_ENV) |
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,3 @@ | ||
Dir[File.join(File.dirname(__FILE__), "core", "*.rb")].each do |file| | ||
require File.expand_path(file) | ||
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
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
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
File renamed without changes.
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,41 @@ | ||
module Webrat | ||
class Session | ||
|
||
def doc_root | ||
nil | ||
end | ||
|
||
def saved_page_dir | ||
File.expand_path(".") | ||
end | ||
|
||
def current_page | ||
@current_page ||= Page.new(self) | ||
end | ||
|
||
def current_page=(new_page) | ||
@current_page = new_page | ||
end | ||
|
||
def visits(*args) | ||
Page.new(self, *args) | ||
end | ||
|
||
def respond_to?(name) | ||
super || current_page.respond_to?(name) | ||
end | ||
|
||
def save_and_open_page | ||
current_page.save_and_open | ||
end | ||
|
||
def method_missing(name, *args) | ||
if current_page.respond_to?(name) | ||
current_page.send(name, *args) | ||
else | ||
super | ||
end | ||
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,5 @@ | ||
require "rubygems" | ||
require "mechanize" | ||
|
||
require File.dirname(__FILE__) + "/mechanize/mechanize_session" | ||
|
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,25 @@ | ||
module Webrat | ||
class MechanizeSession < Session | ||
|
||
def initialize(mechanize = WWW::Mechanize.new) | ||
@mechanize = mechanize | ||
end | ||
|
||
def get(url, data) | ||
@mechanize_page = @mechanize.get(url, data) | ||
end | ||
|
||
def post(url, data) | ||
@mechanize_page = @mechanize.post(url, data) | ||
end | ||
|
||
def response_body | ||
@mechanize_page.content | ||
end | ||
|
||
def response_code | ||
@mechanize_page.code.to_i | ||
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,3 @@ | ||
require File.dirname(__FILE__) + "/rails/redirect_actions" | ||
require File.dirname(__FILE__) + "/rails/rails_session" | ||
require File.dirname(__FILE__) + "/rails/session" |
Oops, something went wrong.