Sha256: 1dedf81f948fd18eac3a10e4baa7b89d6ae691dddc836d6211c04c70ef7ac13a

Contents?: true

Size: 1.58 KB

Versions: 4

Compression:

Stored size: 1.58 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe Github::Client::Repos::Contents, '#delete' do
  let(:user) { 'peter-murach' }
  let(:repo) { 'github' }
  let(:path) { 'hello.rb' }
  let(:params) {
    {
      "path"    => 'hello.rb',
      "message" => "initial commit",
      "sha"     => "329688480d39049927147c162b9d2deaf885005f"
    }
  }
  let(:request_path) { "/repos/#{user}/#{repo}/contents/#{path}" }

  after { reset_authentication_for(subject) }

  before do
    stub_delete(request_path).with(:query => params).
      to_return(:body => body, :status => status,
        :headers => { :content_type => "application/json; charset=utf-8"})
  end

  context "resource deleted successfully" do
    let(:body)   { fixture('repos/content_deleted.json') }
    let(:status) { 200 }

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

    it "should fail to delete without 'user/repo' parameters" do
      expect { subject.delete user }.to raise_error(ArgumentError)
    end

    it "should fail to delete resource without 'path'" do
      expect { subject.delete user, repo, path }.to raise_error(Github::Error::RequiredParams)
    end

    it "should delete the resource" do
      subject.delete user, repo, path, params
      a_delete(request_path).with(:query => params).should have_been_made
    end

    it "gets repository contents information" do
      content = subject.delete user, repo, path, params
      content.content.should be_nil
    end
  end

  it_should_behave_like 'request failure' do
    let(:requestable) { subject.delete user, repo, path, params }
  end

end # delete

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
github_api-0.12.3 spec/github/client/repos/contents/delete_spec.rb
github_api-0.12.2 spec/github/client/repos/contents/delete_spec.rb
github_api-0.12.1 spec/github/client/repos/contents/delete_spec.rb
github_api-0.12.0 spec/github/client/repos/contents/delete_spec.rb