Sha256: 5995962b07bf5bd89aff10d3eda16f11bc99d7b1ff0fdbe2fa3f88845759201a

Contents?: true

Size: 1.31 KB

Versions: 1

Compression:

Stored size: 1.31 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe Github::Repos::PubSubHubbub, '#subscribe' do
  let(:topic)  { "https://github.com/peter-murach/github/events/push"}
  let(:callback) { "github://campfire?subdomain=github&room=Commits&token=abc123" }
  let(:hub_inputs) {
    {
       "hub.mode" => 'subscribe',
       "hub.topic" => topic,
       "hub.callback" => callback,
       "hub.verify"   => 'sync',
       "hub.secret"   => ''
    }
  }

  let(:request_path) { "/hub?access_token=#{OAUTH_TOKEN}" }

  before {
    subject.oauth_token = OAUTH_TOKEN
    stub_post(request_path).with(hub_inputs).
      to_return(:body => '[]', :status => status,
        :headers => {:content_type => "application/json; charset=utf-8"})

  }

  after { reset_authentication_for subject }

  context "success" do
    let(:status) { 200 }

    it { expect { subject.subscribe }.to raise_error(ArgumentError) }

    it { expect { subject.subscribe topic, nil}.to raise_error(ArgumentError) }

    it "subscribes to hub" do
      subject.subscribe topic, callback
      a_post("/hub?access_token=#{OAUTH_TOKEN}").with(hub_inputs).should have_been_made
    end

    it "" do
      subject.subscribe(topic, callback)
    end
  end

  it_should_behave_like 'request failure' do
    let(:requestable) { subject.subscribe topic, callback }
  end

end # subscribe

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
github_api-0.9.1 spec/github/repos/pub_sub_hubbub/subscribe_spec.rb