-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Expand file tree
/
Copy pathgist.feature
More file actions
220 lines (209 loc) · 5.83 KB
/
gist.feature
File metadata and controls
220 lines (209 loc) · 5.83 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
Feature: hub gist
Background:
Given I am "octokitten" on github.com with OAuth token "OTOKEN"
Scenario: Fetch a gist with a single file
Given the GitHub API server:
"""
get('/gists/myhash') {
json({
:files => {
'hub_gist1.txt' => {
'content' => "my content is here",
}
},
:description => "my gist",
})
}
"""
When I successfully run `hub gist show myhash`
Then the output should contain exactly:
"""
my content is here\n
"""
Scenario: Fetch a gist with many files
Given the GitHub API server:
"""
get('/gists/myhash') {
json({
:files => {
'hub_gist1.txt' => {
'content' => "my content is here"
},
'hub_gist2.txt' => {
'content' => "more content is here"
}
},
:description => "my gist",
:id => "myhash",
})
}
"""
When I run `hub gist show myhash`
Then the exit status should be 1
Then the stderr should contain:
"""
This gist contains multiple files, you must specify one:
hub_gist1.txt
hub_gist2.txt
"""
Scenario: Fetch a single file from gist
Given the GitHub API server:
"""
get('/gists/myhash') {
json({
:files => {
'hub_gist1.txt' => {
'content' => "my content is here"
},
'hub_gist2.txt' => {
'content' => "more content is here"
}
},
:description => "my gist",
:id => "myhash",
})
}
"""
When I successfully run `hub gist show myhash hub_gist1.txt`
Then the output should contain exactly:
"""
my content is here\n
"""
Scenario: Create a gist from file
Given the GitHub API server:
"""
post('/gists') {
status 201
json :html_url => 'http://gists.github.com/somehash'
}
"""
Given a file named "testfile.txt" with:
"""
this is a test file
"""
When I successfully run `hub gist create testfile.txt`
Then the output should contain exactly:
"""
http://gists.github.com/somehash\n
"""
Scenario: Open the new gist in a browser
Given the GitHub API server:
"""
post('/gists') {
status 201
json :html_url => 'http://gists.github.com/somehash'
}
"""
Given a file named "testfile.txt" with:
"""
this is a test file
"""
When I successfully run `hub gist create -o testfile.txt`
Then the output should contain exactly ""
And "open http://gists.github.com/somehash" should be run
Scenario: Create a gist with multiple files
Given the GitHub API server:
"""
post('/gists') {
halt 400 unless params[:files]["testfile.txt"]["content"]
halt 400 unless params[:files]["testfile2.txt"]["content"]
status 201
json({
:html_url => 'http://gists.github.com/somehash',
})
}
"""
Given a file named "testfile.txt" with:
"""
this is a test file
"""
Given a file named "testfile2.txt" with:
"""
this is another test file
"""
When I successfully run `hub gist create testfile.txt testfile2.txt`
Then the output should contain exactly:
"""
http://gists.github.com/somehash\n
"""
Scenario: Create a gist from stdin
Given the GitHub API server:
"""
post('/gists') {
halt 400 unless params[:files]["gistfile1.txt"]["content"] == "hello\n"
status 201
json :html_url => 'http://gists.github.com/somehash'
}
"""
When I run `hub gist create` interactively
And I pass in:
"""
hello
"""
Then the output should contain exactly:
"""
http://gists.github.com/somehash\n
"""
Scenario: Insufficient OAuth scopes
Given the GitHub API server:
"""
post('/gists') {
status 404
response.headers['x-accepted-oauth-scopes'] = 'gist'
response.headers['x-oauth-scopes'] = 'repos'
json({})
}
"""
Given a file named "testfile.txt" with:
"""
this is a test file
"""
When I run `hub gist create testfile.txt`
Then the exit status should be 1
And the stderr should contain exactly:
"""
Error creating gist: Not Found (HTTP 404)
Your access token may have insufficient scopes. Visit https://github.com/settings/tokens
to edit the 'hub' token and enable one of the following scopes: gist\n
"""
Scenario: Infer correct OAuth scopes for gist
Given the GitHub API server:
"""
post('/gists') {
status 404
response.headers['x-oauth-scopes'] = 'repos'
json({})
}
"""
Given a file named "testfile.txt" with:
"""
this is a test file
"""
When I run `hub gist create testfile.txt`
Then the exit status should be 1
And the stderr should contain exactly:
"""
Error creating gist: Not Found (HTTP 404)
Your access token may have insufficient scopes. Visit https://github.com/settings/tokens
to edit the 'hub' token and enable one of the following scopes: gist\n
"""
Scenario: Create error
Given the GitHub API server:
"""
post('/gists') {
status 404
response.headers['x-accepted-oauth-scopes'] = 'gist'
response.headers['x-oauth-scopes'] = 'repos, gist'
json({})
}
"""
Given a file named "testfile.txt" with:
"""
this is a test file
"""
When I run `hub gist create testfile.txt`
Then the exit status should be 1
And the stderr should contain exactly:
"""
Error creating gist: Not Found (HTTP 404)\n
"""