Sha256: 0653956105b6d5595af90734f1b52b6fa7bbac92b39787da71c3cd9f7814ec08

Contents?: true

Size: 1.66 KB

Versions: 33

Compression:

Stored size: 1.66 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)

      client.subscribe("https://github.com/joshk/completeness-fu/events/push", "github://Travis?token=travistoken").should == 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)

      proc {
        client.subscribe("https://github.com/joshk/completeness-fud/events/push", "github://Travis?token=travistoken")
      }.should 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)

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

end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
octokit-1.17.0 spec/octokit/client/pub_sub_hubbub_spec.rb
octokit-1.15.1 spec/octokit/client/pub_sub_hubbub_spec.rb
octokit-1.15.0 spec/octokit/client/pub_sub_hubbub_spec.rb
octokit-1.14.0 spec/octokit/client/pub_sub_hubbub_spec.rb
octokit-1.13.0 spec/octokit/client/pub_sub_hubbub_spec.rb
octokit-1.12.0 spec/octokit/client/pub_sub_hubbub_spec.rb
octokit-1.11.0 spec/octokit/client/pub_sub_hubbub_spec.rb
octokit-1.10.0 spec/octokit/client/pub_sub_hubbub_spec.rb
octokit-1.9.4 spec/octokit/client/pub_sub_hubbub_spec.rb
octokit-1.9.3 spec/octokit/client/pub_sub_hubbub_spec.rb
octokit-1.9.2 spec/octokit/client/pub_sub_hubbub_spec.rb
octokit-1.9.1 spec/octokit/client/pub_sub_hubbub_spec.rb
octokit-1.8.1 spec/octokit/client/pub_sub_hubbub_spec.rb
octokit-1.8.0 spec/octokit/client/pub_sub_hubbub_spec.rb
octokit-1.7.0 spec/octokit/client/pub_sub_hubbub_spec.rb
octokit-1.6.1 spec/octokit/client/pub_sub_hubbub_spec.rb
octokit-1.6.0 spec/octokit/client/pub_sub_hubbub_spec.rb
octokit-1.5.0 spec/octokit/client/pub_sub_hubbub_spec.rb
octokit-1.4.0 spec/octokit/client/pub_sub_hubbub_spec.rb
octokit-1.3.0 spec/octokit/client/pub_sub_hubbub_spec.rb