Sha256: b0caad365f18e144f6b46bcff47d4ab7efdcaf3ab35624b05e32ecb42c2395a8

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 KB

Contents

# encoding: utf-8
#
# Copyright (C) 2011-2012  AdMaster, Inc.

ENV['RACK_ENV'] ||= "test"

require "minitest/autorun"
require "rack/test"
require "./config/boot"

class BaseFactory

  def self.define name, value = nil
    self.attrs[name] = value
  end

  def self.attrs
    @attrs ||= {}
  end

  def self.attr key
    @attrs ||= {}
    @attrs[key]
  end

  def self.register name
    @klass = name
  end

  def self.post data = {}
    raise "Please register class first.`" unless @klass
    @klass.post attrs.merge(data)
  end

end

class TestCase < MiniTest::Unit::TestCase

end

class FunctionalTestCase < TestCase

  include Rack::Test::Methods

  def app
    @app ||= Sinatra.new(<%= module_name %>::Application) {}
  end

  def body
    last_response.body
  end

  def patch(uri, params = {}, env = {}, &block)
    env = env.merge(:method => "PATCH", :params => params)
    request(uri, env, &block)
  end

end

Dir.glob "./test/factory/**/*_factory.rb" do |f| require f end
Dir.glob "./test/mock/**/*_mock.rb" do |f| require f end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
apimaster-0.0.3 lib/apimaster/generators/templates/test/test_helper.rb.erb