Sha256: c0688ebc2ccb25b6857f0e52448465cab8ec8d2f2e7e4cb34938c74310ac9860

Contents?: true

Size: 1.72 KB

Versions: 1

Compression:

Stored size: 1.72 KB

Contents

require 'spec_helper'

describe Brat::Client do
  it { should respond_to :system_hooks }
  it { should respond_to :add_system_hook }
  it { should respond_to :system_hook }
  it { should respond_to :delete_system_hook }

  describe ".hooks" do
    before do
      stub_get("/hooks", "system_hooks")
      @hooks = Brat.hooks
    end

    it "should get the correct resource" do
      expect(a_get("/hooks")).to have_been_made
    end

    it "should return an array of system hooks" do
      expect(@hooks).to be_an Array
      expect(@hooks.first.url).to eq("http://example.com/hook")
    end
  end

  describe ".add_hook" do
    before do
      stub_post("/hooks", "system_hook")
      @hook = Brat.add_hook("http://example.com/hook")
    end

    it "should get the correct resource" do
      expect(a_post("/hooks")).to have_been_made
    end

    it "should return information about a added system hook" do
      expect(@hook.url).to eq("http://example.com/hook")
    end
  end

  describe ".hook" do
    before do
      stub_get("/hooks/3", "system_hook_test")
      @hook = Brat.hook(3)
    end
    it "should get the correct resource" do
      expect(a_get("/hooks/3")).to have_been_made
    end

    it "should return information about a added system hook" do
      expect(@hook.event_name).to eq("project_create")
      expect(@hook.project_id).to eq(1)
    end
  end

  describe ".delete_hook" do
    before do
      stub_delete("/hooks/3", "system_hook")
      @hook = Brat.delete_hook(3)
    end

    it "should get the correct resource" do
      expect(a_delete("/hooks/3")).to have_been_made
    end

    it "should return information about a deleted system hook" do
      expect(@hook.url).to eq("http://example.com/hook")
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
brat-0.1.1 spec/brat/client/system_hooks_spec.rb