Sha256: 82abbf70368af1c1f469e5f6a70a2c8d7685d952ffe78ebb9c1382d54f3efa47

Contents?: true

Size: 1.59 KB

Versions: 3

Compression:

Stored size: 1.59 KB

Contents

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

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

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

      expect(client.subscribe("https://github.com/joshk/completeness-fu/events/push", "github://Travis?token=travistoken")).to eq(true)
    end

    it "raises an error if the topic is not recognized" do
      stub_post("/hub").
        with({
          :"hub.callback" => 'github://Travis?token=travistoken',
          :"hub.mode" => 'subscribe',
          :"hub.topic" => 'https://github.com/joshk/completeness-fud/events/push'
        }).
        to_return(:status => 422)

      expect {
        client.subscribe("https://github.com/joshk/completeness-fud/events/push", "github://Travis?token=travistoken")
      }.to raise_exception
    end
  end

  describe ".unsubscribe" do
    it "unsubscribes from pull events" do
      stub_post("/hub").
      with({
        :"hub.callback" => 'github://Travis?token=travistoken',
        :"hub.mode" => 'unsubscribe',
        :"hub.topic" => 'https://github.com/joshk/completeness-fu/events/push'
      }).
      to_return(:body => nil)

      expect(client.unsubscribe("https://github.com/joshk/completeness-fu/events/push", "github://Travis?token=travistoken")).to eq(true)
    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_spec.rb
octokit-1.20.0 spec/octokit/client/pub_sub_hubbub_spec.rb
octokit-1.19.0 spec/octokit/client/pub_sub_hubbub_spec.rb