Sha256: b5917dea828020a0f74311084103473e0295cbaa77e363b2d1e059e089e12b06

Contents?: true

Size: 1.34 KB

Versions: 7

Compression:

Stored size: 1.34 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe Github::Gitignore, '#get' do
  let(:template) { 'Ruby' }
  let(:request_path) { "/gitignore/templates/#{template}" }


  before {
    stub_get(request_path).to_return(:body => body, :status => status,
      :headers => {:accept => accept })
  }

  after { reset_authentication_for(subject) }

  context "resource found" do
    let(:body) { fixture("gitignore/template.json") }
    let(:status) { 200 }
    let(:accept) { "application/json; charset=utf-8" }

    it { should respond_to :find }

    it "should fail to get resource without key" do
      expect { subject.get }.to raise_error(ArgumentError)
    end

    it "should get the resource" do
      subject.get template
      a_get(request_path).should have_been_made
    end

    it "should get key information" do
      temp = subject.get template
      temp.name.should == "C"
    end
  end

  context 'raw content' do
    let(:body) { fixture("gitignore/template_raw") }
    let(:status) { 200 }
    let(:accept) { 'application/vnd.github.raw' }

    it "should get the resource" do
      subject.get template, 'mime' => 'application/vnd.github.raw'
      a_get(request_path).should have_been_made
    end
  end

  it_should_behave_like 'request failure' do
    let(:accept) { 'application/json' }
    let(:requestable) { subject.get template }
  end
end # get

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
github_api-0.9.7 spec/github/gitignore/get_spec.rb
github_api-0.9.6 spec/github/gitignore/get_spec.rb
github_api-0.9.5 spec/github/gitignore/get_spec.rb
github_api-0.9.4 spec/github/gitignore/get_spec.rb
github_api-0.9.3 spec/github/gitignore/get_spec.rb
github_api-0.9.2 spec/github/gitignore/get_spec.rb
github_api-0.9.1 spec/github/gitignore/get_spec.rb