Sha256: 50be6803d6a0f6fab30d0f0e957e4cce5d1930dbd2d9156d2f293455cca4f015

Contents?: true

Size: 1.2 KB

Versions: 27

Compression:

Stored size: 1.2 KB

Contents

require File.join(File.dirname(__FILE__), "test_helper")

class TestFakeWebAllowNetConnect < Test::Unit::TestCase

  def setup
    @original_allow_net_connect = FakeWeb.allow_net_connect?
  end

  def teardown
    FakeWeb.allow_net_connect = @original_allow_net_connect
  end


  def test_unregistered_requests_are_passed_through_when_allow_net_connect_is_true
    FakeWeb.allow_net_connect = true
    setup_expectations_for_real_apple_hot_news_request
    Net::HTTP.get(URI.parse("http://images.apple.com/main/rss/hotnews/hotnews.rss"))
  end

  def test_raises_for_unregistered_requests_when_allow_net_connect_is_false
    FakeWeb.allow_net_connect = false
    exception = assert_raise FakeWeb::NetConnectNotAllowedError do
      Net::HTTP.get(URI.parse('http://example.com/'))
    end
  end

  def test_question_mark_method_returns_true_after_setting_allow_net_connect_to_true
    FakeWeb.allow_net_connect = true
    assert FakeWeb.allow_net_connect?
  end

  def test_question_mark_method_returns_false_after_setting_allow_net_connect_to_false
    FakeWeb.allow_net_connect = false
    assert !FakeWeb.allow_net_connect?
  end

  def test_allow_net_connect_is_true_by_default
    assert FakeWeb.allow_net_connect?
  end

end

Version data entries

27 entries across 27 versions & 10 rubygems

Version Path
MarkMenard-fakeweb-1.1.2.6 test/test_allow_net_connect.rb
aeden-contacts-0.2.15 vendor/fakeweb/test/test_allow_net_connect.rb
aeden-contacts-0.2.16 vendor/fakeweb/test/test_allow_net_connect.rb
aeden-contacts-0.2.18 vendor/fakeweb/test/test_allow_net_connect.rb
aeden-contacts-0.2.19 vendor/fakeweb/test/test_allow_net_connect.rb
aeden-contacts-0.2.20 vendor/fakeweb/test/test_allow_net_connect.rb
chrisk-fakeweb-1.1.2.6 test/test_allow_net_connect.rb
chrisk-fakeweb-1.1.2.7 test/test_allow_net_connect.rb
chrisk-fakeweb-1.2.0 test/test_allow_net_connect.rb
chrisk-fakeweb-1.2.1 test/test_allow_net_connect.rb
dkubb-fakeweb-1.1.2.6 test/test_allow_net_connect.rb
eric-fakeweb-1.2.2.1 test/test_allow_net_connect.rb
eric-fakeweb-1.2.2.2 test/test_allow_net_connect.rb
eric-fakeweb-1.2.2.3 test/test_allow_net_connect.rb
eric-fakeweb-1.2.2.4 test/test_allow_net_connect.rb
eric-fakeweb-1.2.2 test/test_allow_net_connect.rb
mbleigh-fakeweb-1.1.3.8 test/test_allow_net_connect.rb
mbleigh-fakeweb-1.1.3.9 test/test_allow_net_connect.rb
mbleigh-fakeweb-1.2.1 test/test_allow_net_connect.rb
mislav-fakeweb-1.1.2.6 test/test_allow_net_connect.rb