Sha256: 1508a4a68e6901f686515badea9a5645887edd5ede2a99abbcdab9aa1d6176ab

Contents?: true

Size: 1.59 KB

Versions: 1

Compression:

Stored size: 1.59 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("https://api.github.com/hub?access_token=myfaketoken").
        with(subscribe_request_body).
        to_return(:body => nil)

      client.subscribe_service_hook("joshk/completeness-fu", "Travis", { :token => 'travistoken' }).should == true
      assert_requested :post, "https://api.github.com/hub?access_token=myfaketoken", :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("https://api.github.com/hub?access_token=myfaketoken").
        with(unsubscribe_request_body).
        to_return(:body => nil)

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
octokit-0.6.4 spec/octokit/client/pub_sub_hubbub/service_hooks_spec.rb