Sha256: 3373d053eb3e0f4f9da3e29153d7210422b66ee060e1163c6d7bcbcca97f1e00

Contents?: true

Size: 1.5 KB

Versions: 5

Compression:

Stored size: 1.5 KB

Contents

# Setup Rails Envinronment
ENV["RAILS_ENV"] = "test"
require File.expand_path("../../test/dummy/config/environment.rb",  __FILE__)
require File.expand_path("../../lib/image_factory/image_factory.rb",  __FILE__)

require 'rspec/rails'
require 'factory_girl'

ENGINE_RAILS_ROOT=File.join(File.dirname(__FILE__), '../')

# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.

Dir[File.join(ENGINE_RAILS_ROOT, "spec/support/**/*.rb")].each {|f| require f }
Dir.glob(File.join(File.dirname(__FILE__) + "/factories/", "**", "*.rb")).each do |file|
  require file
end

RSpec.configure do |config|
  config.color_enabled = true
  config.formatter     = 'documentation'
end

# Override to_xml to use underscore rather than dash
ActiveRecord::Base.class_eval do
  def to_xml(options={})
    options[:dasherize] ||= false
    super({ :root => self.class.name.split("::").last.underscore }.merge(options))
  end
end

module RequestContentTypeHelper
  def accept_all
    @request.env["HTTP_ACCEPT"] = "*/*"
  end

  def accept_json
    @request.env["HTTP_ACCEPT"] = "application/json"
  end

  def accept_xml
    @request.env["HTTP_ACCEPT"] = "application/xml"
  end

  def send_and_accept_xml
    @request.env["HTTP_ACCEPT"] = "application/xml"
    @request.env["CONTENT_TYPE"] = "application/xml"
  end

  def send_and_accept_json
    @request.env["HTTP_ACCEPT"] = "application/json"
    @request.env["CONTENT_TYPE"] = "application/json"
  end
end

include RequestContentTypeHelper

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
tim-0.3.0 spec/spec_helper.rb
tim-0.2.0 spec/spec_helper.rb
tim-0.1.2 spec/spec_helper.rb
tim-0.1.1 spec/spec_helper.rb
tim-0.0.1 spec/spec_helper.rb