File: test_missing_pathname.rb

package info (click to toggle)
ruby-fakeweb 1.3.0%2Bgit20170806%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 436 kB
  • sloc: ruby: 2,057; sh: 24; makefile: 3
file content (37 lines) | stat: -rw-r--r-- 1,152 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
require 'test_helper'

class TestMissingPathname < Test::Unit::TestCase

  def setup
    super
    @saved_pathname = Pathname
    Object.send(:remove_const, :Pathname)
  end

  def teardown
    super
    Object.const_set(:Pathname, @saved_pathname)
  end

  # FakeWeb supports using Pathname objects where filenames are expected, but
  # Pathname isn't required to use FakeWeb. Make sure everything still works
  # when Pathname isn't in use.

  def test_register_using_body_without_pathname
    FakeWeb.register_uri(:get, "http://example.com/", :body => fixture_path("test_example.txt"))
    Net::HTTP.start("example.com") { |http| http.get("/") }
  end

  def _test_register_using_response_without_pathname
    FakeWeb.register_uri(:get, "http://example.com/", :response => fixture_path("google_response_without_transfer_encoding"))
    Net::HTTP.start("example.com") { |http| http.get("/") }
  end

  def test_register_using_unsupported_response_without_pathname
    FakeWeb.register_uri(:get, "http://example.com/", :response => 1)
    assert_raises ArgumentError do
      Net::HTTP.start("example.com") { |http| http.get("/") }
    end
  end

end