Sha256: b4ab52b1fe37335a727b34ae9e5e7d9bb93f77e7c2db876b476b61d082f1216d

Contents?: true

Size: 1.67 KB

Versions: 2

Compression:

Stored size: 1.67 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?access_token=myfaketoken").
        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?access_token=myfaketoken").
        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?access_token=myfaketoken").
      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

2 entries across 2 versions & 1 rubygems

Version Path
octokit-1.18.0 spec/octokit/client/pub_sub_hubbub_spec.rb
octokit-1.17.1 spec/octokit/client/pub_sub_hubbub_spec.rb