|
1 | | -require 'spec_helper' |
| 1 | +# encoding: utf-8 |
2 | 2 |
|
3 | | -describe Github::GitData::References, :type => :base do |
| 3 | +require 'spec_helper' |
4 | 4 |
|
| 5 | +describe Github::GitData::References do |
| 6 | + let(:github) { Github.new } |
| 7 | + let(:user) { 'peter-murach' } |
| 8 | + let(:repo) { 'github' } |
5 | 9 | let(:ref) { "heads/master" } |
6 | 10 | let(:sha) { "3a0f86fb8db8eea7ccbb9a95f325ddbedfb25e15" } |
7 | 11 |
|
| 12 | + after { github.user, github.repo = nil, nil } |
| 13 | + |
8 | 14 | it { described_class::VALID_REF_PARAM_NAMES.should_not be_nil } |
9 | 15 | it { described_class::VALID_REF_PARAM_VALUES.should_not be_nil } |
10 | 16 |
|
|
23 | 29 | end |
24 | 30 |
|
25 | 31 | it "should fail to get resource without username" do |
26 | | - github.user, github.repo = nil, nil |
27 | 32 | expect { github.git_data.references }.to raise_error(ArgumentError) |
28 | 33 | end |
29 | 34 |
|
|
161 | 166 | it "should fail to create resource if 'sha' input is missing" do |
162 | 167 | expect { |
163 | 168 | github.git_data.create_reference user, repo, inputs.except('sha') |
164 | | - }.to raise_error(ArgumentError) |
| 169 | + }.to raise_error(Github::Error::RequiredParams) |
165 | 170 | end |
166 | 171 |
|
167 | 172 | it "should fail to create resource if 'ref' is wrong" do |
|
217 | 222 | to_return(:body => fixture('git_data/reference.json'), :status => 201, :headers => {:content_type => "application/json; charset=utf-8"}) |
218 | 223 | end |
219 | 224 |
|
220 | | - it "should fail to create resource if 'sha' input is missing" do |
| 225 | + it "should fail to update resource if 'sha' input is missing" do |
221 | 226 | expect { |
222 | 227 | github.git_data.update_reference user, repo, ref, inputs.except('sha') |
223 | | - }.to raise_error(ArgumentError) |
| 228 | + }.to raise_error(Github::Error::RequiredParams) |
224 | 229 | end |
225 | 230 |
|
226 | | - it "should fail to create resource if 'ref' is wrong" do |
| 231 | + it "should fail to update resource if 'ref' is wrong" do |
227 | 232 | expect { |
228 | 233 | github.git_data.update_reference user, repo, 'branch', inputs |
229 | 234 | }.to raise_error(ArgumentError) |
|
245 | 250 | end |
246 | 251 | end |
247 | 252 |
|
248 | | - context "failed to create resource" do |
| 253 | + context "failed to update resource" do |
249 | 254 | before do |
250 | 255 | stub_patch("/repos/#{user}/#{repo}/git/refs/#{ref}").with(inputs). |
251 | 256 | to_return(:body => fixture('git_data/reference.json'), :status => 404, :headers => {:content_type => "application/json; charset=utf-8"}) |
|
0 commit comments