Sha256: 167a8b07fda47f25289e979d6bc433dd82df2c08d9437b969dfc8624fa452392

Contents?: true

Size: 973 Bytes

Versions: 10

Compression:

Stored size: 973 Bytes

Contents

$LOAD_PATH.unshift(File.dirname(__FILE__))
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
require 'em-net-http'
require 'time'
require 'rspec'

require 'mimic'

RSpec.configure do |config|
  config.before(:all) do
    Mimic.mimic do
      Net::HTTPResponse::CODE_TO_OBJ.each do |code, klass|
        get("/code/#{code}").returning("#{code} #{klass.name}", code.to_i, {})
      end
      
      get('/hello').returning('Hello World!', 200, {'Content-Type'=>'text/plain'})
      
      class BigImageResponse
        def each
          ::File.open('spec/image.jpg', "rb") { |file|
            while part = file.read(8192)
              yield part
            end
          }
        end
      end
      resp = BigImageResponse.new
      get('/image').returning(resp, 200, {"Content-Type" => 'image/jpeg'})

      post('/testpost') do
        "You said #{request.body.read}."
      end
    end
  end
  
  config.after(:all) do
    Mimic.cleanup!
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
em-net-http-0.3.9 spec/spec_helper.rb
em-net-http-0.3.8 spec/spec_helper.rb
em-net-http-npn47-0.1.1 spec/spec_helper.rb
em-net-http-npn47-0.1.0 spec/spec_helper.rb
em-net-http-0.3.7 spec/spec_helper.rb
em-net-http-0.3.6 spec/spec_helper.rb
em-net-http-0.3.5 spec/spec_helper.rb
em-net-http-0.3.2 spec/spec_helper.rb
em-net-http-0.3.1 spec/spec_helper.rb
em-net-http-0.3.0 spec/spec_helper.rb