Sha256: 3649887dde8e0a8c925eba6244acde9633b90b098dd11c34f2b2818299e6ec36
Contents?: true
Size: 1.64 KB
Versions: 5
Compression:
Stored size: 1.64 KB
Contents
ENV['PADRINO_ENV'] = 'test' PADRINO_ROOT = File.dirname(__FILE__) unless defined? PADRINO_ROOT $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) $LOAD_PATH.unshift(File.dirname(__FILE__)) require 'rubygems' require 'padrino-core' require 'test/unit' require 'rack/test' require 'rack' require 'shoulda' module Kernel # Silences the output by redirecting to stringIO # silence_logger { ...commands... } => "...output..." def silence_logger(&block) $stdout = log_buffer = StringIO.new block.call $stdout = STDOUT log_buffer.string end alias :silence_stdout :silence_logger end class Padrino::Application # Allow assertions in request context include Test::Unit::Assertions end class Test::Unit::TestCase include Rack::Test::Methods # Test App class PadrinoTestApp < Padrino::Application; end # Sets up a Sinatra::Base subclass defined with the block # given. Used in setup or individual spec methods to establish # the application. def mock_app(base=PadrinoTestApp, &block) @app = Sinatra.new(base, &block) end def app Rack::Lint.new(@app) end def stop_time_for_test time = Time.now Time.stubs(:now).returns(time) return time end # Asserts that a file matches the pattern def assert_match_in_file(pattern, file) assert File.exist?(file), "File '#{file}' does not exist!" assert_match pattern, File.read(file) end # Delegate other missing methods to response. def method_missing(name, *args, &block) if response && response.respond_to?(name) response.send(name, *args, &block) else super end end alias :response :last_response end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
padrino-core-0.2.9 | test/helper.rb |
padrino-core-0.2.6 | test/helper.rb |
padrino-core-0.2.5 | test/helper.rb |
padrino-core-0.2.2 | test/helper.rb |
padrino-core-0.2.1 | test/helper.rb |