~ubuntu-branches/ubuntu/utopic/ruby-excon/utopic

« back to all changes in this revision

Viewing changes to tests/middlewares/canned_response_tests.rb

  • Committer: Package Import Robot
  • Author(s): Praveen Arimbrathodiyil
  • Date: 2014-01-14 18:44:24 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20140114184424-3nx5mqudhzjpcrjs
Tags: 0.31.0-1
* Team upload
* New upstream release
* Refresh patches
* Bump standards version to 3.9.5 (no changes)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Shindo.tests("Excon support for middlewares that return canned responses") do
 
2
  the_body = "canned"
 
3
 
 
4
  canned_response_middleware = Class.new(Excon::Middleware::Base) do
 
5
    define_method :request_call do |params|
 
6
      params[:response] = {
 
7
        :body     => the_body,
 
8
        :headers  => {},
 
9
        :status   => 200
 
10
      }
 
11
      super(params)
 
12
    end
 
13
  end
 
14
 
 
15
  tests('does not mutate the canned response body').returns("canned") do
 
16
    Excon.get(
 
17
      'http://some-host.com/some-path',
 
18
      :middlewares    => [canned_response_middleware] + Excon.defaults[:middlewares],
 
19
      :response_block => Proc.new { } # to force streaming
 
20
    )
 
21
    the_body
 
22
  end
 
23
end
 
24