Sha256: c97ee1fcc751cfe7b6a1f0b52e4bb73a353f2679938dd327bac6f4d7436ba7ec

Contents?: true

Size: 1.64 KB

Versions: 11

Compression:

Stored size: 1.64 KB

Contents

$:.reject! { |e| e.include? 'TextMate' }
ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
require 'test_help'
gem 'thoughtbot-factory_girl' # from github
require 'factory_girl'
require 'mocha'
require 'authlogic/test_case'
require 'redgreen' rescue LoadError
require File.expand_path(File.dirname(__FILE__) + '/factories')
require File.join(File.dirname(__FILE__), 'shoulda_macros', 'controller')
require File.join(File.dirname(__FILE__), 'shoulda_macros', 'models')

class ActiveSupport::TestCase 
  self.use_transactional_fixtures = true
  self.use_instantiated_fixtures  = false

  include Authlogic::TestCase
  
  def login_as(user)
    success = UserSession.create(user)
    if !success
      errors = user.errors.full_messages.to_sentence
      message = 'User has not been activated' if !user.active?
      raise "could not login as #{user.to_param}.  Please make sure the user is valid. #{message} #{errors}"
    end
    UserSession.find
  end
  
  def assure_logout
    user_session = UserSession.find
    user_session.destroy if user_session
  end
  
  def ensure_flash(val)
    assert_contains flash.values, val, ", Flash: #{flash.inspect}"
  end

  # Add more helper methods to be used for testing xml
  def assert_xml_tag(xml, conditions)
    doc = HTML::Document.new(xml)
    assert doc.find(conditions), 
      "expected tag, but no tag found matching #{conditions.inspect} in:\n#{xml.inspect}"
  end

  def assert_no_xml_tag(xml, conditions)
    doc = HTML::Document.new(xml)
    assert !doc.find(conditions), 
      "expected no tag, but found tag matching #{conditions.inspect} in:\n#{xml.inspect}"
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
muck-users-0.2.16 test/rails_root/test/test_helper.rb
muck-users-0.2.15 test/rails_root/test/test_helper.rb
muck-users-0.2.14 test/rails_root/test/test_helper.rb
muck-users-0.2.13 test/rails_root/test/test_helper.rb
muck-users-0.2.12 test/rails_root/test/test_helper.rb
muck-users-0.2.11 test/rails_root/test/test_helper.rb
muck-users-0.2.10 test/rails_root/test/test_helper.rb
muck-users-0.2.9 test/rails_root/test/test_helper.rb
muck-users-0.2.6 test/rails_root/test/test_helper.rb
muck-users-0.2.7 test/rails_root/test/test_helper.rb
muck-users-0.2.8 test/rails_root/test/test_helper.rb