forked from piotrmurach/github
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparse_spec.rb
More file actions
68 lines (49 loc) · 1.67 KB
/
Copy pathparse_spec.rb
File metadata and controls
68 lines (49 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# encoding: utf-8
require 'spec_helper'
describe Github::Arguments, '#parse' do
let(:api) { Github::Repos.new }
let(:object) { described_class.new api, 'required' => required }
let(:arguments) { ['peter-murach', 'github', params] }
let(:params) { { :page => 23 } }
let(:required) { [:user, :repo] }
subject { object.parse *arguments }
after { api.user =nil; api.repo = nil }
context 'with required arguments' do
it { should == object }
its(:params) { should == params }
context 'sets parameters' do
it { subject.api.user.should == 'peter-murach' }
it { subject.api.repo.should == 'github' }
end
context 'with no arguments search parameters hash' do
let(:arguments) { nil }
it 'asserts lack of presence of hash parameters' do
expect { subject }.to raise_error(ArgumentError)
end
end
context 'with nil argument' do
let(:arguments) { [nil, 'github', params] }
it 'raises an error' do
expect { subject }.to raise_error(ArgumentError, /parameter/)
end
end
context 'with hash arguments' do
let(:arguments) { [{:user => 'peter-murach', :repo => 'github'}.merge(params)]}
it 'sets parameters' do
subject.api.user.should == 'peter-murach'
end
end
end
context 'with less than required arguments' do
let(:required) { [:user, :repo] }
let(:arguments) { ['peter-murach', params] }
it 'raises an error' do
expect { subject }.to raise_error(ArgumentError, /wrong number/)
end
end
context 'without required arguments' do
let(:required) { [] }
let(:arguments) { [params] }
its(:params) { should == params }
end
end