test/http_store_test.rb in fiveruns-dash-ruby-0.7.6 vs test/http_store_test.rb in fiveruns-dash-ruby-0.8.0

- old
+ new

@@ -40,11 +40,11 @@ flexmock(IPSocket).should_receive(:getaddress).times(1).returns("1.1.1.1") assert_equal @update.resolved_hostnames.keys.size, 0 new_uri = @update.resolved_hostname(uris.first.host) assert_equal new_uri, "1.1.1.1" assert_equal @update.resolved_hostnames.keys.size, 1 - assert @update.resolved_hostnames[uris.first.host].next_update > (Time.now + 23.hours) + assert @update.resolved_hostnames[uris.first.host].next_update > (Time.now + (23 * 60 * 60)) assert_equal @update.resolved_hostname(uris.first.host), "1.1.1.1" junk = @update.resolved_hostname(uris.first.host) end @@ -52,18 +52,18 @@ flexmock(@update).should_receive(:rand).returns(1) flexmock(IPSocket).should_receive(:getaddress).returns("1.1.1.1", "2.2.2.2") assert_equal @update.resolved_hostnames.keys.size, 0 new_uri = @update.resolved_hostname(uris.first.host) assert_equal new_uri, "1.1.1.1" - @update.resolved_hostnames[uris.first.host].next_update = 10.hours.ago + @update.resolved_hostnames[uris.first.host].next_update = Time.now - (10 * 60 * 60) first_expire = @update.resolved_hostnames[uris.first.host].next_update new_uri = @update.resolved_hostname(uris.first.host) second_expire = @update.resolved_hostnames[uris.first.host].next_update assert_equal new_uri, "2.2.2.2" - assert second_expire < (Time.now + 25.hours) - assert second_expire > (Time.now + 23.hours) + assert second_expire < (Time.now + (25 * 60 * 60)) + assert second_expire > (Time.now + (23 * 60 * 60)) end end context "with info payload" do setup do @@ -81,13 +81,12 @@ full_urls(:processes)[1..-1].each do |url| FakeWeb.register_uri url, :status => 201, :string => File.read(File.dirname(__FILE__) << "/fixtures/http_store_test/response.json") end end should "fallback to working URL" do - returning @update.store_http(*uris) do |pass_uri| - assert_equal uris[1], pass_uri - end + pass_uri = @update.store_http(*uris) + assert_equal uris[1], pass_uri end end context "on non-201 response" do setup do [500, 403, 200].zip(full_urls(:processes)).each do |status, url| @@ -115,13 +114,12 @@ full_urls(:metrics)[1..-1].each do |url| FakeWeb.register_uri url, :string => '{"message" : "OK!"}', :status => 201 end end should "fallback to working URL" do - returning @update.store_http(*uris) do |pass_uri| - assert_equal uris[1], pass_uri - end + pass_uri = @update.store_http(*uris) + assert_equal uris[1], pass_uri end end context "on non-201 response" do setup do [500, 403, 200].zip(full_urls(:metrics)).each do |status, url| @@ -164,13 +162,12 @@ full_urls(:exceptions)[1..-1].each do |url| FakeWeb.register_uri url, :string => '{"message" : "OK!"}', :status => 201 end end should "fallback to working URL" do - returning @update.store_http(*uris) do |pass_uri| - assert_equal uris[1], pass_uri - end + pass_uri = @update.store_http(*uris) + assert_equal uris[1], pass_uri end end context "on non-201 response" do setup do [500, 403, 200].zip(full_urls(:exceptions)).each do |status, url| @@ -190,10 +187,10 @@ ####### private ####### def full_urls(service) - full_uris(service).map(&:to_s) + full_uris(service).map { |u| u.to_s } end def full_uris(service) @urls.map do |url| uri = URI.parse(url) \ No newline at end of file