flunk 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +26 -26
- data/flunk.gemspec +1 -1
- data/lib/flunk.rb +9 -11
- data/lib/generators/flunk_test/templates/flunk_test.rb +2 -2
- metadata +2 -2
data/README.md
CHANGED
@@ -41,7 +41,7 @@ It's your typical rails integration test, but inherits from Flunk:
|
|
41
41
|
|
42
42
|
You write tests that SHOULD pass to test your app's basic functionality all works:
|
43
43
|
|
44
|
-
test "
|
44
|
+
test "User", "Create" do
|
45
45
|
desc "Creating a new Langwich user."
|
46
46
|
path "signup"
|
47
47
|
method :post
|
@@ -57,7 +57,7 @@ You write tests that SHOULD pass to test your app's basic functionality all work
|
|
57
57
|
}
|
58
58
|
end
|
59
59
|
|
60
|
-
test "Log In" do
|
60
|
+
test "User", "Log In" do
|
61
61
|
desc "Obtain a users API token by logging in with their username and password"
|
62
62
|
path "login"
|
63
63
|
method :get
|
@@ -68,7 +68,7 @@ You write tests that SHOULD pass to test your app's basic functionality all work
|
|
68
68
|
}
|
69
69
|
end
|
70
70
|
|
71
|
-
test "Log In With Email" do
|
71
|
+
test "User", "Log In With Email" do
|
72
72
|
path "login"
|
73
73
|
method :get
|
74
74
|
body username: @user.email, password: @user.password
|
@@ -78,7 +78,7 @@ You write tests that SHOULD pass to test your app's basic functionality all work
|
|
78
78
|
}
|
79
79
|
end
|
80
80
|
|
81
|
-
test "
|
81
|
+
test "User", "Read" do
|
82
82
|
desc "Read a users information."
|
83
83
|
path "account"
|
84
84
|
method :get
|
@@ -86,7 +86,7 @@ You write tests that SHOULD pass to test your app's basic functionality all work
|
|
86
86
|
status :ok
|
87
87
|
end
|
88
88
|
|
89
|
-
test "
|
89
|
+
test "User", "Update" do
|
90
90
|
desc "Update the username, e-mail, password and/or name"
|
91
91
|
path "account"
|
92
92
|
method :put
|
@@ -98,7 +98,7 @@ You write tests that SHOULD pass to test your app's basic functionality all work
|
|
98
98
|
}
|
99
99
|
end
|
100
100
|
|
101
|
-
test "Update E-mail" do
|
101
|
+
test "User", "Update E-mail" do
|
102
102
|
path "account"
|
103
103
|
method :put
|
104
104
|
username @user.api_token
|
@@ -109,7 +109,7 @@ You write tests that SHOULD pass to test your app's basic functionality all work
|
|
109
109
|
}
|
110
110
|
end
|
111
111
|
|
112
|
-
test "Update User Password" do
|
112
|
+
test "User", "Update User Password" do
|
113
113
|
path "account"
|
114
114
|
method :put
|
115
115
|
username @user.api_token
|
@@ -117,7 +117,7 @@ You write tests that SHOULD pass to test your app's basic functionality all work
|
|
117
117
|
status :ok
|
118
118
|
end
|
119
119
|
|
120
|
-
test "Update Name" do
|
120
|
+
test "User", "Update Name" do
|
121
121
|
path "account"
|
122
122
|
method :put
|
123
123
|
username @user.api_token
|
@@ -128,7 +128,7 @@ You write tests that SHOULD pass to test your app's basic functionality all work
|
|
128
128
|
}
|
129
129
|
end
|
130
130
|
|
131
|
-
test "
|
131
|
+
test "User", "Destroy" do
|
132
132
|
path "account"
|
133
133
|
method :delete
|
134
134
|
username @user.api_token
|
@@ -140,7 +140,7 @@ You write tests that SHOULD pass to test your app's basic functionality all work
|
|
140
140
|
Then, write tests that SHOULDN'T pass to make sure your app rejects bad requests correctly/gracefully:
|
141
141
|
|
142
142
|
|
143
|
-
flunk "
|
143
|
+
flunk "User", "Create", "Missing username" do
|
144
144
|
desc "Attempting to create a user without a username."
|
145
145
|
path "signup"
|
146
146
|
method :post
|
@@ -148,21 +148,21 @@ Then, write tests that SHOULDN'T pass to make sure your app rejects bad requests
|
|
148
148
|
status :unprocessable_entity
|
149
149
|
end
|
150
150
|
|
151
|
-
flunk "
|
151
|
+
flunk "User", "Create", "Username already taken" do
|
152
152
|
path "signup"
|
153
153
|
method :post
|
154
154
|
body user: FactoryGirl.attributes_for(:user, username: @user.username)
|
155
155
|
status :unprocessable_entity
|
156
156
|
end
|
157
157
|
|
158
|
-
flunk "
|
158
|
+
flunk "User", "Create", "Invalid username" do
|
159
159
|
path "signup"
|
160
160
|
method :post
|
161
161
|
body user: FactoryGirl.attributes_for(:user, username: "a234$2aa" )
|
162
162
|
status :unprocessable_entity
|
163
163
|
end
|
164
164
|
|
165
|
-
flunk "
|
165
|
+
flunk "User", "Create", "Missing e-mail" do
|
166
166
|
desc "Attempting to create a user without a e-mail."
|
167
167
|
path "signup"
|
168
168
|
method :post
|
@@ -170,7 +170,7 @@ Then, write tests that SHOULDN'T pass to make sure your app rejects bad requests
|
|
170
170
|
status :unprocessable_entity
|
171
171
|
end
|
172
172
|
|
173
|
-
flunk "
|
173
|
+
flunk "User", "Create", "E-mail already taken" do
|
174
174
|
desc "Attempting to create a user with an e-mail that's already taken."
|
175
175
|
path "signup"
|
176
176
|
method :post
|
@@ -178,14 +178,14 @@ Then, write tests that SHOULDN'T pass to make sure your app rejects bad requests
|
|
178
178
|
status :unprocessable_entity
|
179
179
|
end
|
180
180
|
|
181
|
-
flunk "
|
181
|
+
flunk "User", "Create", "Invalid e-mail" do
|
182
182
|
path "signup"
|
183
183
|
method :post
|
184
184
|
body user: FactoryGirl.attributes_for(:user, email: "aaaa@aakk")
|
185
185
|
status :unprocessable_entity
|
186
186
|
end
|
187
187
|
|
188
|
-
flunk "
|
188
|
+
flunk "User", "Create", "Missing password" do
|
189
189
|
desc "Attempting to create a user without a password."
|
190
190
|
path "signup"
|
191
191
|
method :post
|
@@ -193,7 +193,7 @@ Then, write tests that SHOULDN'T pass to make sure your app rejects bad requests
|
|
193
193
|
status :unprocessable_entity
|
194
194
|
end
|
195
195
|
|
196
|
-
flunk "
|
196
|
+
flunk "User", "Create", "Missing name" do
|
197
197
|
path "signup"
|
198
198
|
method :post
|
199
199
|
body user: FactoryGirl.attributes_for(:user, name: nil)
|
@@ -203,7 +203,7 @@ Then, write tests that SHOULDN'T pass to make sure your app rejects bad requests
|
|
203
203
|
|
204
204
|
|
205
205
|
|
206
|
-
flunk "Log In", "No username" do
|
206
|
+
flunk "User", "Log In", "No username" do
|
207
207
|
desc "Attempting to obtain an API token with the wrong password"
|
208
208
|
path "login"
|
209
209
|
method :get
|
@@ -211,7 +211,7 @@ Then, write tests that SHOULDN'T pass to make sure your app rejects bad requests
|
|
211
211
|
status :unauthorized
|
212
212
|
end
|
213
213
|
|
214
|
-
flunk "Log In", "Wrong password" do
|
214
|
+
flunk "User", "Log In", "Wrong password" do
|
215
215
|
desc "Attempting to obtain an API token with the wrong password"
|
216
216
|
path "login"
|
217
217
|
method :get
|
@@ -222,7 +222,7 @@ Then, write tests that SHOULDN'T pass to make sure your app rejects bad requests
|
|
222
222
|
|
223
223
|
|
224
224
|
|
225
|
-
flunk "
|
225
|
+
flunk "User", "Read", "Wrong API token" do
|
226
226
|
path "login"
|
227
227
|
method :get
|
228
228
|
username "a"
|
@@ -232,7 +232,7 @@ Then, write tests that SHOULDN'T pass to make sure your app rejects bad requests
|
|
232
232
|
|
233
233
|
|
234
234
|
|
235
|
-
flunk "
|
235
|
+
flunk "User", "Update", "Wrong password" do
|
236
236
|
path "account"
|
237
237
|
method :put
|
238
238
|
username "a"
|
@@ -240,7 +240,7 @@ Then, write tests that SHOULDN'T pass to make sure your app rejects bad requests
|
|
240
240
|
status :unauthorized
|
241
241
|
end
|
242
242
|
|
243
|
-
flunk "
|
243
|
+
flunk "User", "Update", "Username already taken" do
|
244
244
|
path "account"
|
245
245
|
method :put
|
246
246
|
username @user.api_token
|
@@ -249,7 +249,7 @@ Then, write tests that SHOULDN'T pass to make sure your app rejects bad requests
|
|
249
249
|
status :unprocessable_entity
|
250
250
|
end
|
251
251
|
|
252
|
-
flunk "
|
252
|
+
flunk "User", "Update", "Invalid username" do
|
253
253
|
path "account"
|
254
254
|
method :put
|
255
255
|
username @user.api_token
|
@@ -257,7 +257,7 @@ Then, write tests that SHOULDN'T pass to make sure your app rejects bad requests
|
|
257
257
|
status :unprocessable_entity
|
258
258
|
end
|
259
259
|
|
260
|
-
flunk "
|
260
|
+
flunk "User", "Update", "E-mail already taken" do
|
261
261
|
desc "Attempting to update a user with an e-mail that's already taken."
|
262
262
|
path "account"
|
263
263
|
method :put
|
@@ -267,7 +267,7 @@ Then, write tests that SHOULDN'T pass to make sure your app rejects bad requests
|
|
267
267
|
status :unprocessable_entity
|
268
268
|
end
|
269
269
|
|
270
|
-
flunk "
|
270
|
+
flunk "User", "Update", "Invalid e-mail" do
|
271
271
|
desc "Attempting to update the user with an invalid e-mail"
|
272
272
|
path "account"
|
273
273
|
method :put
|
@@ -279,7 +279,7 @@ Then, write tests that SHOULDN'T pass to make sure your app rejects bad requests
|
|
279
279
|
|
280
280
|
|
281
281
|
|
282
|
-
flunk "
|
282
|
+
flunk "User", "Delete", "Wrong password" do
|
283
283
|
path "account"
|
284
284
|
method :delete
|
285
285
|
username "a"
|
data/flunk.gemspec
CHANGED
data/lib/flunk.rb
CHANGED
@@ -2,22 +2,24 @@ require 'rails/test_help'
|
|
2
2
|
|
3
3
|
class Flunk < ActionDispatch::IntegrationTest
|
4
4
|
|
5
|
-
def self.test(
|
5
|
+
def self.test(resource, action, &block)
|
6
6
|
new_proc = Proc.new do
|
7
7
|
instance_eval(&block)
|
8
8
|
result
|
9
9
|
@assertions.call unless @assertions.nil?
|
10
10
|
end
|
11
11
|
|
12
|
-
|
13
|
-
|
12
|
+
if !action || !resource
|
13
|
+
name = action || resource
|
14
|
+
else
|
15
|
+
name = resource + ": " + action
|
16
|
+
end
|
14
17
|
|
15
|
-
|
16
|
-
test("FLUNKED: #{action} (#{failure_reason})", &block)
|
18
|
+
super name, &new_proc
|
17
19
|
end
|
18
20
|
|
19
|
-
def self.
|
20
|
-
|
21
|
+
def self.flunk(resource, action, failure_reason, &block)
|
22
|
+
test("FLUNKED! #{resource}: #{action} (#{failure_reason})", nil, &block)
|
21
23
|
end
|
22
24
|
|
23
25
|
def result
|
@@ -29,10 +31,6 @@ class Flunk < ActionDispatch::IntegrationTest
|
|
29
31
|
@headers["HTTP_AUTHORIZATION"] = "Basic #{Base64.encode64(@username.to_s + ":" + @password.to_s)}".strip
|
30
32
|
end
|
31
33
|
|
32
|
-
if @@base_url
|
33
|
-
@path = File.join(@@base_url, @path)
|
34
|
-
end
|
35
|
-
|
36
34
|
send @method, @path, @body, @headers
|
37
35
|
|
38
36
|
@response = response
|
@@ -6,7 +6,7 @@ class <%= class_name.pluralize %>Test < Flunk
|
|
6
6
|
end
|
7
7
|
|
8
8
|
# Write tests that should succeed to make sure the required functionality works.
|
9
|
-
test "
|
9
|
+
test "Resource", "Action" do
|
10
10
|
desc "A description of the function this tests"
|
11
11
|
path "resource/:id"
|
12
12
|
method :get
|
@@ -20,7 +20,7 @@ class <%= class_name.pluralize %>Test < Flunk
|
|
20
20
|
|
21
21
|
|
22
22
|
# Write a test that SHOULD fail to ensure your application handles bad requests gracefully.
|
23
|
-
flunk "
|
23
|
+
flunk "Resource", "Action, "Why it flunks" do
|
24
24
|
path "/resource/:id"
|
25
25
|
method :get
|
26
26
|
status :unauthorized
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flunk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-01-
|
12
|
+
date: 2013-01-25 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: A gem for testing Ruby on Rails web APIs by simulating a client.
|
15
15
|
email: atomkirk@gmail.com
|