Skip to content

Commit 73bcd20

Browse files
committed
centralize all tests for the lapis.spec.request module
1 parent 1184670 commit 73bcd20

File tree

2 files changed

+58
-51
lines changed

2 files changed

+58
-51
lines changed

spec/request_spec.moon

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
lapis = require "lapis"
32

43
require "spec.helpers" -- defines assert.one_of
@@ -10,56 +9,6 @@ import
109
stub_request
1110
from require "lapis.spec.request"
1211

13-
describe "lapis.spec.request", ->
14-
describe "mock_request", ->
15-
class App extends lapis.Application
16-
"/hello": =>
17-
18-
it "should mock a request", ->
19-
assert.same 200, (mock_request App, "/hello")
20-
assert.has_error ->
21-
mock_request App, "/world"
22-
23-
it "should mock a request with double headers", ->
24-
mock_request App, "/hello", {
25-
method: "POST"
26-
headers: {
27-
["Content-type"]: {
28-
"hello"
29-
"world"
30-
}
31-
}
32-
}
33-
34-
it "should mock request with session", ->
35-
class SessionApp extends lapis.Application
36-
"/test-session": =>
37-
import flatten_session from require "lapis.session"
38-
assert.same {
39-
color: "hello"
40-
height: {1,2,3,4}
41-
}, flatten_session @session
42-
43-
mock_request SessionApp, "/test-session", {
44-
session: {
45-
color: "hello"
46-
height: {1,2,3,4}
47-
}
48-
}
49-
50-
describe "mock_action action", ->
51-
it "should mock action", ->
52-
assert.same "hello", mock_action lapis.Application, "/hello", {}, ->
53-
"hello"
54-
55-
describe "stub_request", ->
56-
class SomeApp extends lapis.Application
57-
[cool_page: "/cool/:name"]: =>
58-
59-
it "should stub a request object", ->
60-
req = stub_request SomeApp, "/"
61-
assert.same "/cool/world", req\url_for "cool_page", name: "world"
62-
6312
describe "lapis.request", ->
6413
describe "session", ->
6514
class SessionApp extends lapis.Application

spec/spec_request_spec.moon

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
lapis = require "lapis"
2+
3+
import
4+
mock_request
5+
mock_action
6+
assert_request
7+
stub_request
8+
from require "lapis.spec.request"
9+
10+
describe "lapis.spec.request", ->
11+
describe "mock_request", ->
12+
class App extends lapis.Application
13+
"/hello": =>
14+
15+
it "should mock a request", ->
16+
assert.same 200, (mock_request App, "/hello")
17+
assert.has_error ->
18+
mock_request App, "/world"
19+
20+
it "should mock a request with double headers", ->
21+
mock_request App, "/hello", {
22+
method: "POST"
23+
headers: {
24+
["Content-type"]: {
25+
"hello"
26+
"world"
27+
}
28+
}
29+
}
30+
31+
it "should mock request with session", ->
32+
class SessionApp extends lapis.Application
33+
"/test-session": =>
34+
import flatten_session from require "lapis.session"
35+
assert.same {
36+
color: "hello"
37+
height: {1,2,3,4}
38+
}, flatten_session @session
39+
40+
mock_request SessionApp, "/test-session", {
41+
session: {
42+
color: "hello"
43+
height: {1,2,3,4}
44+
}
45+
}
46+
47+
describe "mock_action", ->
48+
it "should mock action", ->
49+
assert.same "hello", mock_action lapis.Application, "/hello", {}, ->
50+
"hello"
51+
52+
describe "stub_request", ->
53+
class SomeApp extends lapis.Application
54+
[cool_page: "/cool/:name"]: =>
55+
56+
it "should stub a request object", ->
57+
req = stub_request SomeApp, "/"
58+
assert.same "/cool/world", req\url_for "cool_page", name: "world"

0 commit comments

Comments
 (0)