Sha256: 288e9741111aa9bde80e7d0f73abe31b4b5bcf0971bcc57cadc734072461d226

Contents?: true

Size: 1.31 KB

Versions: 9

Compression:

Stored size: 1.31 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe Github::Issues::Labels, '#add' do
  let(:user)   { 'peter-murach' }
  let(:repo)   { 'github' }
  let(:request_path) { "/repos/#{user}/#{repo}/issues/#{issue_id}/labels" }

  before {
    stub_post(request_path).
      to_return(:body => body, :status => status,
      :headers => {:content_type => "application/json; charset=utf-8"})
  }

  after { reset_authentication_for(subject) }

  let(:issue_id) { 1 }
  let(:labels) { "Label 1" }

  context "labels added" do
    let(:body) { fixture('issues/labels.json') }
    let(:status) { 200 }

    it "should fail to add labels if issue-id is missing" do
      expect {
        subject.add user, repo, nil, labels
      }.to raise_error(ArgumentError)
    end

    it "should create resource successfully" do
      subject.add user, repo, issue_id, labels
      a_post(request_path).should have_been_made
    end

    it "should return the resource" do
      labels = subject.add user, repo, issue_id, labels
      labels.first.should be_a Hashie::Mash
    end

    it "should get the label information" do
      labels = subject.add user, repo, issue_id, labels
      labels.first.name.should == 'bug'
    end
  end

  it_should_behave_like 'request failure' do
    let(:requestable) { subject.add user, repo, issue_id, labels }
  end
end # add

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
github_api-0.9.0 spec/github/issues/labels/add_spec.rb
github_api-0.8.11 spec/github/issues/labels/add_spec.rb
github_api-0.8.10 spec/github/issues/labels/add_spec.rb
github_api-0.8.9 spec/github/issues/labels/add_spec.rb
github_api-0.8.8 spec/github/issues/labels/add_spec.rb
github_api-0.8.7 spec/github/issues/labels/add_spec.rb
github_api-0.8.6 spec/github/issues/labels/add_spec.rb
github_api-0.8.5 spec/github/issues/labels/add_spec.rb
github_api-0.8.4 spec/github/issues/labels/add_spec.rb