Sha256: 264c2d04b215507bf3d4c01d0c5ecf2e251f4d3384240d2da49e707cb68f4aa6

Contents?: true

Size: 1.32 KB

Versions: 4

Compression:

Stored size: 1.32 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe Github::Client::Issues::Labels, '#replace' do
  let(:user) { 'peter-murach' }
  let(:repo) { 'github' }
  let(:number) { 1 }
  let(:label) { "Label 1" }
  let(:request_path) { "/repos/#{user}/#{repo}/issues/#{number}/labels" }

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

  after { reset_authentication_for(subject) }

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

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

    it "should create resource successfully" do
      subject.replace user, repo, number, label
      a_put(request_path).should have_been_made
    end

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

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

  it_should_behave_like 'request failure' do
    let(:requestable) { subject.replace user, repo, number, label }
  end
end # replace

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
github_api-0.12.3 spec/github/client/issues/labels/replace_spec.rb
github_api-0.12.2 spec/github/client/issues/labels/replace_spec.rb
github_api-0.12.1 spec/github/client/issues/labels/replace_spec.rb
github_api-0.12.0 spec/github/client/issues/labels/replace_spec.rb