Skip to content

Commit

Permalink
Basic test working
Browse files Browse the repository at this point in the history
  • Loading branch information
Gwyn Morfey committed Apr 18, 2008
1 parent 2e03051 commit a45d654
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 17 deletions.
41 changes: 30 additions & 11 deletions test/helper.rb
@@ -1,20 +1,39 @@
require "rubygems"
require "test/unit"
require "mocha"

# gem install redgreen for colored test output
begin require "redgreen" unless ENV['TM_CURRENT_LINE']; rescue LoadError; end
require "mocha"

require "active_support"
if ENV["TEST_MODE"] == "rails"
require "active_support"
silence_warnings do
require "action_controller"
require "action_controller/integration"
end

silence_warnings do
require "action_controller"
require "action_controller/integration"
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
21 changes: 15 additions & 6 deletions test/visits_test.rb
Expand Up @@ -5,12 +5,21 @@
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
Expand Down

0 comments on commit a45d654

Please sign in to comment.