Sha256: f49f7fdf53a6704f5d0efef3aa81bba18c163b22083d71248dc63e9d45e844d9

Contents?: true

Size: 1.12 KB

Versions: 1

Compression:

Stored size: 1.12 KB

Contents

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

class NoBgTest < Scope::TestCase
  context "with an ecology and mocked server" do
    setup do
      Ecology.reset

      set_up_ecology <<ECOLOGY_TEXT
{
  "application": "foo_app",
  "features": {
    "server": "http://fake-server.com",
    "refresh": 300,
    "timeout": 5
  }
}
ECOLOGY_TEXT

      # Turn off loud logging for tests
      Glowworm.termite_logger = stub("fake termite logger", :debug => nil, :info => nil, :warn => nil)

      # @response = mock "HTTP response"
      # @response.stubs(:headers).returns({ "last-modified" => "" })
      # @response.stubs(:code).returns(200)
      # HTTParty.stubs(:get).returns(@response)
      Glowworm.stubs(:update_cache)
      Glowworm.no_bg
    end

    should "have a timeout of 0" do
      assert_equal(0, Glowworm.timeout, "timeout will be 0 if the ecology is overridden by no_bg.")
    end

    should "return 204 immediately for fetch_from_server" do
      assert_equal(204, Glowworm.send(:fetch_from_server, :all, :all),
        "fetch_from_server not returning 204 right away.")
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
glowworm-0.3.0 test/units/no_bg_test.rb