Sha256: 35546cbf142836fe2ea0a4523b79712e607159e379eb0159a7ac25b2a2c8a3f4

Contents?: true

Size: 1.7 KB

Versions: 7

Compression:

Stored size: 1.7 KB

Contents

RAILS_ROOT = File.join(File.dirname(__FILE__), '..') unless defined? RAILS_ROOT

require 'rubygems'
require 'test/unit'

require 'active_support'
require 'active_support/test_case'
require 'active_record'
require 'active_record/fixtures'
require 'action_controller'
require 'action_controller/test_case'
require 'action_controller/test_process'
require 'action_controller/integration'
require 'sqlite3'
require File.join(File.dirname(__FILE__), '..', '..', '..', 'lib', 'restfulx')
require File.join(File.dirname(__FILE__), '..',  'models', 'note')
require File.join(File.dirname(__FILE__), '..', 'models', 'user')
require File.join(File.dirname(__FILE__), '..', 'models', 'project')
require File.join(File.dirname(__FILE__), '..', 'models', 'location')
require File.join(File.dirname(__FILE__), '..', 'models', 'task')
require File.join(File.dirname(__FILE__), '..', 'models', 'simple_property')

class MockResponse
  attr_reader :body, :content_type

  def initialize(body, content_type = 'xml')
    @body = body
    @content_type = content_type
  end

end

class ActiveRecord::TestCase #:nodoc:
  # Add more helper methods to be used by all tests here...

  # Use this to test xml or fxml responses in unit tests.  For example,
  # set_response_to user.to_fxml
  # assert_xml_select 'user name', 'quentin'
  def set_response_to(response, content_type = 'xml')
    @response = MockResponse.new(response, content_type)
  end

  # Make xml functional testing work.
  # From http://weblog.jamisbuck.org/2007/1/4/assert_xml_select
  def xml_document
    @xml_document ||= HTML::Document.new(@response.body, false, true)
  end  

  def assert_xml_select(*args, &block)
    @html_document = xml_document
    assert_select(*args, &block)
  end
  
end

Version data entries

7 entries across 7 versions & 4 rubygems

Version Path
captproton-restfulx-1.2.3 test/rails/helpers/test_helper.rb
dima-restfulx-1.2.3 test/rails/helpers/test_helper.rb
dima-restfulx-1.2.4 test/rails/helpers/test_helper.rb
rlmattax-restfulx-1.2.4.1 test/rails/helpers/test_helper.rb
restfulx-1.2.5 test/rails/helpers/test_helper.rb
restfulx-1.2.3 test/rails/helpers/test_helper.rb
restfulx-1.2.4 test/rails/helpers/test_helper.rb