2008-03-02 20:14:52 +00:00
|
|
|
require "rubygems"
|
2009-01-17 21:34:00 +00:00
|
|
|
require "test/unit"
|
2008-04-23 14:54:07 +00:00
|
|
|
require "spec"
|
2008-07-25 23:11:56 +00:00
|
|
|
|
2008-03-02 20:14:52 +00:00
|
|
|
# gem install redgreen for colored test output
|
|
|
|
begin require "redgreen" unless ENV['TM_CURRENT_LINE']; rescue LoadError; end
|
|
|
|
|
2008-11-17 02:25:29 +00:00
|
|
|
webrat_path = File.expand_path(File.dirname(__FILE__) + "/../lib/")
|
|
|
|
$LOAD_PATH.unshift(webrat_path) unless $LOAD_PATH.include?(webrat_path)
|
|
|
|
|
|
|
|
require "webrat"
|
2008-10-25 16:42:38 +00:00
|
|
|
require File.expand_path(File.dirname(__FILE__) + "/fakes/test_session")
|
2008-04-23 14:54:07 +00:00
|
|
|
|
2008-12-26 04:25:27 +00:00
|
|
|
module Webrat
|
|
|
|
@@previous_config = nil
|
|
|
|
|
|
|
|
def self.cache_config_for_test
|
|
|
|
@@previous_config = Webrat.configuration.clone
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.reset_for_test
|
|
|
|
@@configuration = @@previous_config if @@previous_config
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2008-04-23 14:54:07 +00:00
|
|
|
Spec::Runner.configure do |config|
|
2008-11-23 05:22:49 +00:00
|
|
|
include Webrat::Methods
|
2009-04-08 00:30:12 +00:00
|
|
|
|
2008-11-23 05:22:49 +00:00
|
|
|
def with_html(html)
|
2008-11-28 05:34:35 +00:00
|
|
|
raise "This doesn't look like HTML. Wrap it in a <html> tag" unless html =~ /^\s*<[^Hh>]*html/i
|
2008-11-23 05:22:49 +00:00
|
|
|
webrat_session.response_body = html
|
|
|
|
end
|
2009-04-08 00:30:12 +00:00
|
|
|
|
2008-11-28 05:34:35 +00:00
|
|
|
def with_xml(xml)
|
|
|
|
raise "This looks like HTML" if xml =~ /^\s*<[^Hh>]*html/i
|
|
|
|
webrat_session.response_body = xml
|
|
|
|
end
|
2009-04-08 00:30:12 +00:00
|
|
|
|
2008-12-26 04:25:27 +00:00
|
|
|
config.before :each do
|
|
|
|
Webrat.cache_config_for_test
|
2008-11-14 05:58:52 +00:00
|
|
|
end
|
2009-04-08 00:30:12 +00:00
|
|
|
|
2008-12-26 04:25:27 +00:00
|
|
|
config.after :each do
|
|
|
|
Webrat.reset_for_test
|
2008-12-26 04:04:41 +00:00
|
|
|
end
|
2008-12-26 04:25:27 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
Webrat.configure do |config|
|
|
|
|
config.mode = :merb
|
|
|
|
end
|