Basic test working

This commit is contained in:
Gwyn Morfey 2008-04-18 13:19:13 +01:00
parent 2e03051735
commit a45d654bb8
2 changed files with 46 additions and 18 deletions

View File

@ -1,20 +1,39 @@
require "rubygems" require "rubygems"
require "test/unit" require "test/unit"
# gem install redgreen for colored test output
begin require "redgreen" unless ENV['TM_CURRENT_LINE']; rescue LoadError; end
require "mocha" require "mocha"
require "active_support" # gem install redgreen for colored test output
begin require "redgreen" unless ENV['TM_CURRENT_LINE']; rescue LoadError; end
silence_warnings do if ENV["TEST_MODE"] == "rails"
require "active_support"
silence_warnings do
require "action_controller" require "action_controller"
require "action_controller/integration" require "action_controller/integration"
end end
require File.expand_path(File.dirname(__FILE__) + "/../lib/webrat") class ActionController::Integration::Session
class ActionController::Integration::Session
def flunk(message) def flunk(message)
raise message raise message
end end
end
elsif ENV["TEST_MODE"] == "merb"
require 'merb-core'
require 'merb_stories'
#require 'spec' #makes mocha cry
module Merb
module Test
class RspecStory
include Merb::Test::ControllerHelper
include Merb::Test::RouteHelper
include Merb::Test::ViewHelper
end
end
end
else
raise "Please set the environment variable TEST_MODE to either 'rails' or 'merb'."
end end
require File.expand_path(File.dirname(__FILE__) + "/../lib/webrat")

View File

@ -5,12 +5,21 @@ RAILS_ROOT = "." unless defined?(RAILS_ROOT)
class VisitsTest < Test::Unit::TestCase class VisitsTest < Test::Unit::TestCase
def setup def setup
if ENV["TEST_MODE"] == "rails"
@session = ActionController::Integration::Session.new @session = ActionController::Integration::Session.new
@session.stubs(:assert_response) @session.stubs(:assert_response)
@session.stubs(:get_via_redirect) @session.stubs(:get_via_redirect)
@response = mock @response = mock
@session.stubs(:response).returns(@response) @session.stubs(:response).returns(@response)
@response.stubs(:body).returns("") @response.stubs(:body).returns("")
elsif ENV["TEST_MODE"] == "merb"
@session = Merb::Test::RspecStory.new
@session.stubs(:assert_response)
@session.stubs(:get_via_redirect)
@response = mock
@session.stubs(:response).returns(@response)
@response.stubs(:body).returns("")
end
end end
def test_should_use_get def test_should_use_get