Sha256: b1cefa79e7aa3b3843761983a3884278161c2b76bf82bb484e5c7f64a0525894

Contents?: true

Size: 1.33 KB

Versions: 1

Compression:

Stored size: 1.33 KB

Contents

require 'spec_helper'

describe WebhookStopwatch::Client do
  let(:base_url) { "http://0.0.0.0:9292" }

  subject { WebhookStopwatch::Client.new(base_url) }

  before(:each) do
    stub_request(:post, /#{base_url}/)
  end

  describe "#start" do
    it "POSTs to start" do
      subject.start(123, 1000000)

      a_request(:post, "http://0.0.0.0:9292/messages/123/start").
        with(:body => {"timestamp" => "1000000"}).
        should have_been_made
    end

    it "returns true" do
      subject.start(123, 1000000).should == true
    end

    context "all hell breaks loose" do
      before(:each) do
        stub_request(:post, /#{base_url}/).to_return(:status => 500)
      end

      it "returns false" do
        subject.start(123, 1000000).should == false
      end
    end
  end

  describe "#stop" do
    it "POSTs to stop" do
      subject.stop(123, 1000000)

      a_request(:post, "http://0.0.0.0:9292/messages/123/stop").
        with(:body => {"timestamp" => "1000000"}).
        should have_been_made
    end

    it "returns true" do
      subject.stop(123, 1000000).should == true
    end

    context "all hell breaks loose" do
      before(:each) do
        stub_request(:post, /#{base_url}/).to_return(:status => 500)
      end

      it "returns false" do
        subject.stop(123, 1000000).should == false
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
webhook_stopwatch_client-0.0.1 spec/lib/webhook_stopwatch/client_spec.rb