Sha256: d1d8955527d0aea82d81570a0ed053a178b7956b7ede4b8351a5eedcd865b8f7

Contents?: true

Size: 1.27 KB

Versions: 1

Compression:

Stored size: 1.27 KB

Contents

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

class RequestTest < Scope::TestCase
  context "with an ecology and mocked server but no leading 'http'" do
    setup do
      Ecology.reset

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

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

      Ecology.read
    end

    context "with a single HTTP response" do
      setup do
        @response = mock "HTTP response"
        @response.stubs(:headers).returns({ "last-modified" => "" })
      end

      should "call HTTP GET on the first query to feature_flag" do
        @response.expects(:code).returns(200).at_least_once
        @response.expects(:body).returns(<<JSON).at_least_once
{
  "version": 1,
  "account_sets": { "12345": 1 },
  "features" : {
    "foo_feature": { "1" : 1 }
  },
  "md5": "fake-md5"
}
JSON
        HTTParty.expects(:get).with("http://fake-server.com/all_if_modified", anything).returns(@response)
        assert_equal true, Glowworm.feature_flag(12345, "foo_feature", :default => true)
      end

    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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