Sha256: e77208e020d095d4c8eef88c1403ca2ed65ac701c628411a2e585e707eb8a6c4

Contents?: true

Size: 1.46 KB

Versions: 3

Compression:

Stored size: 1.46 KB

Contents

# -*- encoding: utf-8 -*-
require 'helper'

describe Octokit::Client::PubSubHubbub::ServiceHooks do

  let(:client) { Octokit::Client.new(:oauth_token => 'myfaketoken') }

  describe "subscribe_service_hook" do
    let(:subscribe_request_body) {
      {
        :"hub.callback" => 'github://Travis?token=travistoken',
        :"hub.mode" => 'subscribe',
        :"hub.topic" => 'https://github.com/joshk/completeness-fu/events/push'
      }
    }
    it "subscribes to pull events on specified topic" do
      stub_post("/hub").
        with(subscribe_request_body).
        to_return(:body => nil)

      expect(client.subscribe_service_hook("joshk/completeness-fu", "Travis", { :token => 'travistoken' })).to eq(true)
      assert_requested :post, "https://api.github.com/hub", :body => subscribe_request_body, :times => 1
    end
  end

  describe "unsubscribe_service_hook" do
    let(:unsubscribe_request_body) {
      {
        :"hub.callback" => 'github://Travis',
        :"hub.mode" => 'unsubscribe',
        :"hub.topic" => 'https://github.com/joshk/completeness-fu/events/push'
      }
    }

    it "unsubscribes to stop receiving events on specified topic" do
      stub_post("/hub").
        with(unsubscribe_request_body).
        to_return(:body => nil)

      expect(client.unsubscribe_service_hook("joshk/completeness-fu", "Travis")).to eq(true)
      assert_requested :post, "https://api.github.com/hub", :body => unsubscribe_request_body, :times => 1
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
octokit-1.21.0 spec/octokit/client/pub_sub_hubbub/service_hooks_spec.rb
octokit-1.20.0 spec/octokit/client/pub_sub_hubbub/service_hooks_spec.rb
octokit-1.19.0 spec/octokit/client/pub_sub_hubbub/service_hooks_spec.rb