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 "test/unit"
# gem install redgreen for colored test output
begin require "redgreen" unless ENV['TM_CURRENT_LINE']; rescue LoadError; end
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
require "action_controller"
require "action_controller/integration"
if ENV["TEST_MODE"] == "rails"
require "active_support"
silence_warnings do
require "action_controller"
require "action_controller/integration"
end
class ActionController::Integration::Session
def flunk(message)
raise message
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
require File.expand_path(File.dirname(__FILE__) + "/../lib/webrat")
class ActionController::Integration::Session
def flunk(message)
raise message
end
end

View File

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