Sha256: 8d60960bf039ee7372b31537587782fbc7e4ed243d088a2e1da9d46e3739991b
Contents?: true
Size: 962 Bytes
Versions: 5
Compression:
Stored size: 962 Bytes
Contents
require 'deas' require 'ostruct' class FakeApp # Mimic's the context that is accessible in a Sinatra' route. Should provide # any methods needed to replace using an actual Sinatra app. attr_accessor :request, :response, :params, :settings, :session def initialize @request = FakeRequest.new('GET','/something', {}, OpenStruct.new) @params = @request.params @session = @request.session @response = FakeResponse.new @settings = OpenStruct.new({ }) end def halt(*args) throw :halt, args end def erb(*args, &block) if block [ args, block.call ].flatten else args end end def to(relative_path) File.join("http://test.local", relative_path) end def redirect(*args) halt 302, { 'Location' => args[0] } end end class FakeRequest < Struct.new(:http_method, :path, :params, :session) alias :request_method :http_method end FakeResponse = Struct.new(:status, :headers, :body)
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
deas-0.6.0 | test/support/fake_app.rb |
deas-0.5.0 | test/support/fake_app.rb |
deas-0.4.1 | test/support/fake_app.rb |
deas-0.4.0 | test/support/fake_app.rb |
deas-0.3.0 | test/support/fake_app.rb |