Sha256: 062e027d7b7bb733ed11b97b6ade51c016d6b2a3dfceebc33e84db392bb40661

Contents?: true

Size: 1.34 KB

Versions: 11

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 nil }.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

11 entries across 11 versions & 1 rubygems

Version Path
github_api-0.9.0 spec/github/gitignore/get_spec.rb
github_api-0.8.11 spec/github/gitignore/get_spec.rb
github_api-0.8.10 spec/github/gitignore/get_spec.rb
github_api-0.8.9 spec/github/gitignore/get_spec.rb
github_api-0.8.8 spec/github/gitignore/get_spec.rb
github_api-0.8.7 spec/github/gitignore/get_spec.rb
github_api-0.8.6 spec/github/gitignore/get_spec.rb
github_api-0.8.5 spec/github/gitignore/get_spec.rb
github_api-0.8.4 spec/github/gitignore/get_spec.rb
github_api-0.8.3 spec/github/gitignore/get_spec.rb
github_api-0.8.2 spec/github/gitignore/get_spec.rb