Sha256: 226e18433c5dec33fc8546f4b017fdad983a2493cb7ff27bbf4d4733be2947e2

Contents?: true

Size: 1.61 KB

Versions: 20

Compression:

Stored size: 1.61 KB

Contents

require 'spec_helper'

module Hubstats
  describe EventsHandler, :type => :model do
    context "PullRequestEvent" do
      let(:pull) {build(:pull_request)}
      let(:repo) {build(:repo)}
      let(:payload) {build(:pull_request_payload_hash)}

      subject {Hubstats::EventsHandler.new()}
      it 'should successfully route the event' do
        expect(subject).to receive(:pull_processor)
        subject.route(payload,payload[:type])
      end

      it 'should add labels to pull request' do
        allow(PullRequest).to receive(:create_or_update) {pull}
        allow(Repo).to receive(:where) {[repo,repo]}
        allow(GithubAPI).to receive(:get_labels_for_pull) {['low','high']}
        expect(pull).to receive(:add_labels).with(['low','high'])
        subject.route(payload,payload[:type])
      end
    end

    context "CommentEvent" do
      it 'should successfully route the event' do
        ehandler = EventsHandler.new()
        payload = build(:comment_payload_hash)
        expect(ehandler).to receive(:comment_processor)

        ehandler.route(payload,payload[:type])
      end

      it 'should successfully process the event' do
        ehandler = Hubstats::EventsHandler.new()
        payload = build(:comment_payload_hash)
        expect(Hubstats::Comment).to receive(:create_or_update)

        ehandler.route(payload,payload[:type])
      end

      it 'should successfully creates_or_updates the event' do
        ehandler = Hubstats::EventsHandler.new()
        payload = build(:comment_payload_hash)
        expect(ehandler.route(payload,payload[:type]).class).to eq(Hubstats::Comment)
      end
    end

  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
hubstats-0.4.4 spec/lib/hubstats/events_handler_spec.rb
hubstats-0.4.2 spec/lib/hubstats/events_handler_spec.rb
hubstats-0.4.1 spec/lib/hubstats/events_handler_spec.rb
hubstats-0.3.17 spec/lib/hubstats/events_handler_spec.rb
hubstats-0.3.16 spec/lib/hubstats/events_handler_spec.rb
hubstats-0.3.15 spec/lib/hubstats/events_handler_spec.rb
hubstats-0.3.14 spec/lib/hubstats/events_handler_spec.rb
hubstats-0.3.13 spec/lib/hubstats/events_handler_spec.rb
hubstats-0.3.12 spec/lib/hubstats/events_handler_spec.rb
hubstats-0.3.11 spec/lib/hubstats/events_handler_spec.rb
hubstats-0.3.10 spec/lib/hubstats/events_handler_spec.rb
hubstats-0.3.9 spec/lib/hubstats/events_handler_spec.rb
hubstats-0.3.8 spec/lib/hubstats/events_handler_spec.rb
hubstats-0.3.7 spec/lib/hubstats/events_handler_spec.rb
hubstats-0.3.6 spec/lib/hubstats/events_handler_spec.rb
hubstats-0.3.5 spec/lib/hubstats/events_handler_spec.rb
hubstats-0.3.4 spec/lib/hubstats/events_handler_spec.rb
hubstats-0.3.3 spec/lib/hubstats/events_handler_spec.rb
hubstats-0.3.2 spec/lib/hubstats/events_handler_spec.rb
hubstats-0.3.1 spec/lib/hubstats/events_handler_spec.rb