|
| 1 | +# encoding: utf-8 |
| 2 | + |
| 3 | +require 'spec_helper' |
| 4 | + |
| 5 | +describe Github::Repos::Contents do |
| 6 | + let(:github) { Github.new } |
| 7 | + let(:user) { 'octokit' } |
| 8 | + let(:repo) { 'github' } |
| 9 | + |
| 10 | + after { reset_authentication_for(github) } |
| 11 | + |
| 12 | + context "#readme" do |
| 13 | + before do |
| 14 | + stub_get("/repos/#{user}/#{repo}/readme"). |
| 15 | + to_return(:body => fixture('repos/readme.json'), :status => 200, |
| 16 | + :headers => {:content_type => "application/json; charset=utf-8"}) |
| 17 | + end |
| 18 | + |
| 19 | + it "should get the resources" do |
| 20 | + github.repos.contents.readme user, repo |
| 21 | + a_get("/repos/#{user}/#{repo}/readme").should have_been_made |
| 22 | + end |
| 23 | + |
| 24 | + it "should get readme information" do |
| 25 | + readme= github.repos.contents.readme user, repo |
| 26 | + readme.name.should == 'README.md' |
| 27 | + end |
| 28 | + end |
| 29 | + |
| 30 | + context "#get" do |
| 31 | + let(:path) { 'README.md' } |
| 32 | + |
| 33 | + before do |
| 34 | + stub_get("/repos/#{user}/#{repo}/contents/#{path}"). |
| 35 | + to_return(:body => fixture('repos/content.json'), :status => 200, |
| 36 | + :headers => {:content_type => "application/json; charset=utf-8"}) |
| 37 | + end |
| 38 | + |
| 39 | + it "should get the resources" do |
| 40 | + github.repos.contents.get user, repo, path |
| 41 | + a_get("/repos/#{user}/#{repo}/contents/#{path}").should have_been_made |
| 42 | + end |
| 43 | + |
| 44 | + it "should get repository information" do |
| 45 | + content = github.repos.contents.get user, repo, path |
| 46 | + content.name.should == 'README.md' |
| 47 | + end |
| 48 | + end |
| 49 | + |
| 50 | + context "#users" do |
| 51 | + let(:archive_format) { 'tarball' } |
| 52 | + let(:ref) { 'master' } |
| 53 | + |
| 54 | + before do |
| 55 | + stub_get("/repos/#{user}/#{repo}/#{archive_format}/#{ref}"). |
| 56 | + to_return(:body => '', :status => 302) |
| 57 | + end |
| 58 | + |
| 59 | + it "should get the resources" do |
| 60 | + github.repos.contents.archive user, repo, :archive_format => archive_format, :ref => ref |
| 61 | + a_get("/repos/#{user}/#{repo}/#{archive_format}/#{ref}").should have_been_made |
| 62 | + end |
| 63 | + end |
| 64 | + |
| 65 | +end # Github::Repos::Contents |
0 commit comments