chicago 0.3.10 → 0.3.11
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/Rakefile +1 -9
- data/VERSION +1 -1
- data/chicago.gemspec +12 -22
- data/lib/chicago/riot/macros.rb +10 -8
- data/test/{riot_tests/application_test.rb → application_test.rb} +1 -1
- data/test/{riot_tests/helpers_test.rb → helpers_test.rb} +1 -1
- data/test/{riot_tests/responders_test.rb → responders_test.rb} +1 -1
- data/test/riot_macros_test.rb +42 -0
- data/test/{riot_tests/test_helper.rb → teststrap.rb} +0 -0
- metadata +13 -23
- data/lib/chicago/shoulda.rb +0 -1
- data/lib/chicago/shoulda/sinatra.rb +0 -83
- data/test/riot_tests/riot_macros_test.rb +0 -35
- data/test/shoulda_tests/application_test.rb +0 -48
- data/test/shoulda_tests/helpers_test.rb +0 -125
- data/test/shoulda_tests/responders_test.rb +0 -28
- data/test/shoulda_tests/test_helper.rb +0 -19
data/Rakefile
CHANGED
@@ -10,15 +10,7 @@ task(:set_test_env) { ENV['RACK_ENV'] ||= 'test' }
|
|
10
10
|
desc "Run all tests"
|
11
11
|
Rake::TestTask.new("test") do |t|
|
12
12
|
t.libs.concat ['./lib', './test']
|
13
|
-
t.test_files = FileList['test
|
14
|
-
t.verbose = true
|
15
|
-
end
|
16
|
-
|
17
|
-
task "test:shoulda" => [:set_test_env]
|
18
|
-
desc "Run all Shoulda based tests"
|
19
|
-
Rake::TestTask.new("test:shoulda") do |t|
|
20
|
-
t.libs.concat ['./lib', './test']
|
21
|
-
t.test_files = FileList['test/shoulda_tests/*_test.rb']
|
13
|
+
t.test_files = FileList['test/*_test.rb']
|
22
14
|
t.verbose = true
|
23
15
|
end
|
24
16
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.11
|
data/chicago.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{chicago}
|
8
|
-
s.version = "0.3.
|
8
|
+
s.version = "0.3.11"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Justin 'Gus' Knowlden"]
|
12
|
-
s.date = %q{2010-05-
|
12
|
+
s.date = %q{2010-05-12}
|
13
13
|
s.description = %q{Sinatra runtime and testing extensions used commonly by Thumblemonks. For example, :json_response, which turns an object into JSON and sets the content-type appropriately.}
|
14
14
|
s.email = %q{gus@gusg.us}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -28,17 +28,11 @@ Gem::Specification.new do |s|
|
|
28
28
|
"lib/chicago/responders.rb",
|
29
29
|
"lib/chicago/riot.rb",
|
30
30
|
"lib/chicago/riot/macros.rb",
|
31
|
-
"
|
32
|
-
"
|
33
|
-
"test/
|
34
|
-
"test/
|
35
|
-
"test/
|
36
|
-
"test/riot_tests/riot_macros_test.rb",
|
37
|
-
"test/riot_tests/test_helper.rb",
|
38
|
-
"test/shoulda_tests/application_test.rb",
|
39
|
-
"test/shoulda_tests/helpers_test.rb",
|
40
|
-
"test/shoulda_tests/responders_test.rb",
|
41
|
-
"test/shoulda_tests/test_helper.rb"
|
31
|
+
"test/application_test.rb",
|
32
|
+
"test/helpers_test.rb",
|
33
|
+
"test/responders_test.rb",
|
34
|
+
"test/riot_macros_test.rb",
|
35
|
+
"test/teststrap.rb"
|
42
36
|
]
|
43
37
|
s.homepage = %q{http://github.com/thumblemonks/chicago}
|
44
38
|
s.rdoc_options = ["--charset=UTF-8"]
|
@@ -46,15 +40,11 @@ Gem::Specification.new do |s|
|
|
46
40
|
s.rubygems_version = %q{1.3.6}
|
47
41
|
s.summary = %q{Sinatra runtime and testing extensions used commonly by Thumblemonks}
|
48
42
|
s.test_files = [
|
49
|
-
"test/
|
50
|
-
"test/
|
51
|
-
"test/
|
52
|
-
"test/
|
53
|
-
"test/
|
54
|
-
"test/shoulda_tests/application_test.rb",
|
55
|
-
"test/shoulda_tests/helpers_test.rb",
|
56
|
-
"test/shoulda_tests/responders_test.rb",
|
57
|
-
"test/shoulda_tests/test_helper.rb"
|
43
|
+
"test/application_test.rb",
|
44
|
+
"test/helpers_test.rb",
|
45
|
+
"test/responders_test.rb",
|
46
|
+
"test/riot_macros_test.rb",
|
47
|
+
"test/teststrap.rb"
|
58
48
|
]
|
59
49
|
|
60
50
|
if s.respond_to? :specification_version then
|
data/lib/chicago/riot/macros.rb
CHANGED
@@ -25,19 +25,21 @@ module Chicago
|
|
25
25
|
end.matches(expected_path)
|
26
26
|
end
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
28
|
+
# Usage:
|
29
|
+
# asserts_json_response({"foo" => "bar"})
|
30
|
+
# asserts_json_response('{"foo":"bar"}')
|
31
|
+
# asserts_json_response("text/javascript;charset=utf-8", {"foo" => "bar"})
|
32
|
+
# asserts_json_response { {"foo" => @some_value} }
|
33
|
+
# asserts_json_response("text/javascript;charset=utf-8") { {"foo" => @some_value} }
|
34
|
+
def asserts_json_response(*args, &block)
|
35
|
+
json = block_given? ? instance_eval(&block) : args.pop
|
32
36
|
|
33
37
|
json = json.to_json unless json.instance_of?(String)
|
34
|
-
json
|
35
|
-
|
36
38
|
asserts("response body has JSON") do
|
37
39
|
last_response.body
|
38
40
|
end.equals(json)
|
39
|
-
|
40
|
-
|
41
|
+
|
42
|
+
asserts_content_type(args.empty? ? 'application/json' : args.shift)
|
41
43
|
end
|
42
44
|
|
43
45
|
# Usage:
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'teststrap'
|
2
|
+
|
3
|
+
context "Riot Macros Test:" do
|
4
|
+
setup do
|
5
|
+
mock_app {
|
6
|
+
helpers Sinatra::Chicago::Responders
|
7
|
+
get("/redirector") { redirect '/foo/bar' }
|
8
|
+
|
9
|
+
get("/basic-json") do
|
10
|
+
content_type 'application/json'
|
11
|
+
{:foo => "bar"}.to_json
|
12
|
+
end
|
13
|
+
|
14
|
+
get("/json-with-content-type") do
|
15
|
+
content_type 'text/javascript', :charset => "utf-8"
|
16
|
+
{:foo => "bar"}.to_json
|
17
|
+
end
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
context "asserts redirected to" do
|
22
|
+
setup { get('/redirector') }
|
23
|
+
asserts_redirected_to('/foo/bar')
|
24
|
+
end # asserts redirected to
|
25
|
+
|
26
|
+
context "json response" do
|
27
|
+
context "basic" do
|
28
|
+
setup { get('/basic-json') }
|
29
|
+
asserts_json_response({:foo => "bar"})
|
30
|
+
end # basic
|
31
|
+
|
32
|
+
context "with special content-type" do
|
33
|
+
setup { get('/json-with-content-type') }
|
34
|
+
asserts_json_response("text/javascript;charset=utf-8", {:foo => "bar"})
|
35
|
+
end # with special content-type
|
36
|
+
|
37
|
+
context "with content expectation provided as block" do
|
38
|
+
setup { get('/json-with-content-type') }
|
39
|
+
asserts_json_response("text/javascript;charset=utf-8") { {:foo => "bar"} }
|
40
|
+
end # with special content-type
|
41
|
+
end # json response
|
42
|
+
end
|
File without changes
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 3
|
8
|
-
-
|
9
|
-
version: 0.3.
|
8
|
+
- 11
|
9
|
+
version: 0.3.11
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Justin 'Gus' Knowlden
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-05-
|
17
|
+
date: 2010-05-12 00:00:00 -05:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -62,17 +62,11 @@ files:
|
|
62
62
|
- lib/chicago/responders.rb
|
63
63
|
- lib/chicago/riot.rb
|
64
64
|
- lib/chicago/riot/macros.rb
|
65
|
-
-
|
66
|
-
-
|
67
|
-
- test/
|
68
|
-
- test/
|
69
|
-
- test/
|
70
|
-
- test/riot_tests/riot_macros_test.rb
|
71
|
-
- test/riot_tests/test_helper.rb
|
72
|
-
- test/shoulda_tests/application_test.rb
|
73
|
-
- test/shoulda_tests/helpers_test.rb
|
74
|
-
- test/shoulda_tests/responders_test.rb
|
75
|
-
- test/shoulda_tests/test_helper.rb
|
65
|
+
- test/application_test.rb
|
66
|
+
- test/helpers_test.rb
|
67
|
+
- test/responders_test.rb
|
68
|
+
- test/riot_macros_test.rb
|
69
|
+
- test/teststrap.rb
|
76
70
|
has_rdoc: true
|
77
71
|
homepage: http://github.com/thumblemonks/chicago
|
78
72
|
licenses: []
|
@@ -104,12 +98,8 @@ signing_key:
|
|
104
98
|
specification_version: 3
|
105
99
|
summary: Sinatra runtime and testing extensions used commonly by Thumblemonks
|
106
100
|
test_files:
|
107
|
-
- test/
|
108
|
-
- test/
|
109
|
-
- test/
|
110
|
-
- test/
|
111
|
-
- test/
|
112
|
-
- test/shoulda_tests/application_test.rb
|
113
|
-
- test/shoulda_tests/helpers_test.rb
|
114
|
-
- test/shoulda_tests/responders_test.rb
|
115
|
-
- test/shoulda_tests/test_helper.rb
|
101
|
+
- test/application_test.rb
|
102
|
+
- test/helpers_test.rb
|
103
|
+
- test/responders_test.rb
|
104
|
+
- test/riot_macros_test.rb
|
105
|
+
- test/teststrap.rb
|
data/lib/chicago/shoulda.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require 'chicago/shoulda/sinatra'
|
@@ -1,83 +0,0 @@
|
|
1
|
-
require 'json'
|
2
|
-
require 'ostruct'
|
3
|
-
|
4
|
-
module ThumbleMonks
|
5
|
-
module Chicago
|
6
|
-
module Shoulda
|
7
|
-
|
8
|
-
def self.included(klass)
|
9
|
-
klass.extend(Macros)
|
10
|
-
klass.send(:include, Helpers)
|
11
|
-
end
|
12
|
-
|
13
|
-
module Macros
|
14
|
-
def should_have_response_status(expected)
|
15
|
-
should("have response status") { assert_response expected }
|
16
|
-
end
|
17
|
-
|
18
|
-
def should_have_response_body(expected)
|
19
|
-
name = expected.is_a?(String) ? expected[0...15] : expected.to_s
|
20
|
-
should("have response body like #{name}") { assert_response_body expected }
|
21
|
-
end
|
22
|
-
|
23
|
-
def should_have_content_type(expected)
|
24
|
-
should("have content_type") { assert_content_type expected }
|
25
|
-
end
|
26
|
-
|
27
|
-
def should_have_json_response(json={}, &block)
|
28
|
-
should_have_content_type 'application/json'
|
29
|
-
should "have JSON response in the body" do
|
30
|
-
json = self.instance_eval(&block) if block_given?
|
31
|
-
json = json.to_json unless json.instance_of?(String) || json.instance_of?(Regexp)
|
32
|
-
assert_response_body json
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
# Checks to see if there is a redirect in play and the path the redirect goes to
|
37
|
-
#
|
38
|
-
# Example:
|
39
|
-
# should_be_redirected_to { "/users/@user.id" }
|
40
|
-
# should_be_redirected_to "/home"
|
41
|
-
def should_be_redirected_to(expected_path=nil, &block)
|
42
|
-
should "be redirected to #{expected_path || 'a url'}" do
|
43
|
-
expected_path = self.instance_eval(&block) if block_given?
|
44
|
-
assert_redirected_to expected_path
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end # Macros
|
48
|
-
|
49
|
-
module Helpers
|
50
|
-
def deny(check, message=nil)
|
51
|
-
assert(!check, message)
|
52
|
-
end
|
53
|
-
|
54
|
-
def assert_response(status)
|
55
|
-
assert_equal status, last_response.status
|
56
|
-
end
|
57
|
-
|
58
|
-
def assert_response_body(body)
|
59
|
-
assert_match body, last_response.body
|
60
|
-
end
|
61
|
-
|
62
|
-
def assert_content_type(expected)
|
63
|
-
assert_equal expected, last_response.headers['Content-type']
|
64
|
-
end
|
65
|
-
|
66
|
-
# Usage:
|
67
|
-
#
|
68
|
-
# assert_redirected_to '/foo/bar'
|
69
|
-
# or
|
70
|
-
# assert_redirected_to %r[foo.bar]
|
71
|
-
def assert_redirected_to(expected_path)
|
72
|
-
yield if block_given?
|
73
|
-
assert_response 302
|
74
|
-
action = expected_path.kind_of?(Regexp) ? 'match' : 'equal'
|
75
|
-
send("assert_#{action}", expected_path, last_response.headers["Location"])
|
76
|
-
end
|
77
|
-
end # Helpers
|
78
|
-
|
79
|
-
end # Shoulda
|
80
|
-
end # Chicago
|
81
|
-
end # ThumbleMonks
|
82
|
-
|
83
|
-
Test::Unit::TestCase.instance_eval { include ThumbleMonks::Chicago::Shoulda }
|
@@ -1,35 +0,0 @@
|
|
1
|
-
require 'riot_tests/test_helper'
|
2
|
-
|
3
|
-
context "Riot Macros Test:" do
|
4
|
-
setup do
|
5
|
-
mock_app {
|
6
|
-
helpers Sinatra::Chicago::Responders
|
7
|
-
get("/redirector") { redirect '/foo/bar' }
|
8
|
-
|
9
|
-
get("/basic-json") do
|
10
|
-
content_type 'application/json'
|
11
|
-
{:foo => "bar"}.to_json
|
12
|
-
end
|
13
|
-
|
14
|
-
get("/json-with-content-type") do
|
15
|
-
content_type 'text/javascript', :charset => "utf-8"
|
16
|
-
{:foo => "bar"}.to_json
|
17
|
-
end
|
18
|
-
}
|
19
|
-
end
|
20
|
-
|
21
|
-
context "asserts redirected to" do
|
22
|
-
setup { get('/redirector') }
|
23
|
-
asserts_redirected_to('/foo/bar')
|
24
|
-
end # asserts redirected to
|
25
|
-
|
26
|
-
context "basic json response" do
|
27
|
-
setup { get('/basic-json') }
|
28
|
-
asserts_json_response({:foo => "bar"})
|
29
|
-
end # asserts redirected to
|
30
|
-
|
31
|
-
context "json response with special content-type" do
|
32
|
-
setup { get('/json-with-content-type') }
|
33
|
-
asserts_json_response("text/javascript;charset=utf-8", {:foo => "bar"})
|
34
|
-
end # asserts redirected to
|
35
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
require 'shoulda_tests/test_helper'
|
2
|
-
|
3
|
-
class ApplicationTest < Test::Unit::TestCase
|
4
|
-
|
5
|
-
def app
|
6
|
-
@app = mock_app {
|
7
|
-
register Sinatra::Chicago
|
8
|
-
|
9
|
-
template(:foo) { ".bar\n :display none" }
|
10
|
-
template(:goo) { ".car\n :display some" }
|
11
|
-
template(:baz) { "Whatever man. That's just like, your opinion." }
|
12
|
-
|
13
|
-
catch_all_css
|
14
|
-
catch_all_css('/css')
|
15
|
-
|
16
|
-
get_obvious 'baz'
|
17
|
-
}
|
18
|
-
end
|
19
|
-
|
20
|
-
# TODO: change to namespace
|
21
|
-
context "catching all css" do
|
22
|
-
context "with default path" do
|
23
|
-
setup { get '/stylesheets/foo.css' }
|
24
|
-
should_have_response_status 200
|
25
|
-
should_have_content_type 'text/css'
|
26
|
-
should_have_response_body %r[.bar \{\s+display: none; \}\s]
|
27
|
-
end
|
28
|
-
|
29
|
-
context "with specified path" do
|
30
|
-
setup { get '/css/goo.css' }
|
31
|
-
should_have_response_status 200
|
32
|
-
should_have_content_type 'text/css'
|
33
|
-
should_have_response_body %r[.car \{\s+display: some; \}\s]
|
34
|
-
end
|
35
|
-
|
36
|
-
context "with path that's not a defined a sass file" do
|
37
|
-
setup { get '/stylesheets/zoo.css' }
|
38
|
-
should_have_response_status 404
|
39
|
-
should_have_content_type 'text/css'
|
40
|
-
end
|
41
|
-
end # catching all css
|
42
|
-
|
43
|
-
context "getting obvious views" do
|
44
|
-
setup { get '/baz' }
|
45
|
-
should_have_response_body "Whatever man. That's just like, your opinion."
|
46
|
-
end # getting obvious views
|
47
|
-
|
48
|
-
end
|
@@ -1,125 +0,0 @@
|
|
1
|
-
require 'shoulda_tests/test_helper'
|
2
|
-
|
3
|
-
class HelpersTest < Test::Unit::TestCase
|
4
|
-
def app
|
5
|
-
@app = mock_app {
|
6
|
-
helpers Sinatra::Chicago::Helpers
|
7
|
-
}
|
8
|
-
end
|
9
|
-
|
10
|
-
context "including stylesheet" do
|
11
|
-
context "for plain old foo" do
|
12
|
-
setup do
|
13
|
-
extend_mock_app {
|
14
|
-
template(:foo) { "= stylesheet_include('foo')" }
|
15
|
-
get('/foo') { haml :foo }
|
16
|
-
}
|
17
|
-
get '/foo'
|
18
|
-
end
|
19
|
-
|
20
|
-
should_have_response_body %r[^<link( \w+=".+"){4}/>$]
|
21
|
-
should_have_response_body %r[href="/stylesheets/foo\.css"]
|
22
|
-
should_have_response_body %r[media="screen"]
|
23
|
-
should_have_response_body %r[rel="stylesheet"]
|
24
|
-
should_have_response_body %r[type="text/css"]
|
25
|
-
end # for plain old foo
|
26
|
-
|
27
|
-
context "for bar with options" do
|
28
|
-
setup do
|
29
|
-
extend_mock_app {
|
30
|
-
template(:foo) { "= stylesheet_include('bar', :media => 'print', :baz => 'boo')" }
|
31
|
-
get('/foo') { haml :foo }
|
32
|
-
}
|
33
|
-
get '/foo'
|
34
|
-
end
|
35
|
-
|
36
|
-
should_have_response_body %r[^<link( \w+=".+"){5}/>$]
|
37
|
-
should_have_response_body %r[href="/stylesheets/bar\.css"]
|
38
|
-
should_have_response_body %r[media="print"]
|
39
|
-
should_have_response_body %r[rel="stylesheet"]
|
40
|
-
should_have_response_body %r[type="text/css"]
|
41
|
-
should_have_response_body %r[baz="boo"]
|
42
|
-
end # for bar with options
|
43
|
-
|
44
|
-
context "with a specific href" do
|
45
|
-
setup do
|
46
|
-
extend_mock_app {
|
47
|
-
template(:foo) { "= stylesheet_include('http://example.com')" }
|
48
|
-
get('/foo') { haml :foo }
|
49
|
-
}
|
50
|
-
get '/foo'
|
51
|
-
end
|
52
|
-
should_have_response_body %r[href="http://example.com"]
|
53
|
-
end # with a specific href
|
54
|
-
end # including stylesheets
|
55
|
-
|
56
|
-
context "including javascript" do
|
57
|
-
context "for plain old foo" do
|
58
|
-
setup do
|
59
|
-
extend_mock_app {
|
60
|
-
template(:foo) { "= javascript_include('foo')" }
|
61
|
-
get('/foo') { haml :foo }
|
62
|
-
}
|
63
|
-
get '/foo'
|
64
|
-
end
|
65
|
-
|
66
|
-
should_have_response_body %r[^<script( \w+=".+"){2}></script>$]
|
67
|
-
should_have_response_body %r[src="/javascripts/foo\.js"]
|
68
|
-
should_have_response_body %r[type="text/javascript"]
|
69
|
-
end # for plain old foo
|
70
|
-
|
71
|
-
context "for foo with options" do
|
72
|
-
setup do
|
73
|
-
extend_mock_app {
|
74
|
-
template(:foo) { "= javascript_include('foo', :type => 'text/blarg', :gus => 'nice')" }
|
75
|
-
get('/foo') { haml :foo }
|
76
|
-
}
|
77
|
-
get '/foo'
|
78
|
-
end
|
79
|
-
|
80
|
-
should_have_response_body %r[^<script( \w+=".+"){3}></script>$]
|
81
|
-
should_have_response_body %r[src="/javascripts/foo\.js"]
|
82
|
-
should_have_response_body %r[type="text/blarg"]
|
83
|
-
should_have_response_body %r[gus="nice"]
|
84
|
-
end # for foo with options
|
85
|
-
|
86
|
-
context "with a specific src" do
|
87
|
-
setup do
|
88
|
-
extend_mock_app {
|
89
|
-
template(:foo) { "= javascript_include('http://example.com')" }
|
90
|
-
get('/foo') { haml :foo }
|
91
|
-
}
|
92
|
-
get '/foo'
|
93
|
-
end
|
94
|
-
should_have_response_body %r[src="http://example.com"]
|
95
|
-
end # with a specific src
|
96
|
-
end # including javascript
|
97
|
-
|
98
|
-
context "using an anchor" do
|
99
|
-
context "for plain old foo" do
|
100
|
-
setup do
|
101
|
-
extend_mock_app {
|
102
|
-
template(:foo) { "= anchor('foo', '/bar')" }
|
103
|
-
get('/foo') { haml :foo }
|
104
|
-
}
|
105
|
-
get '/foo'
|
106
|
-
end
|
107
|
-
|
108
|
-
should_have_response_body %Q[<a href="/bar">foo</a>]
|
109
|
-
end # for plain old foo
|
110
|
-
|
111
|
-
context "with options" do
|
112
|
-
setup do
|
113
|
-
extend_mock_app {
|
114
|
-
template(:foo) { "= anchor('foo bear', '/bar/ler', :title => 'gus is nice')" }
|
115
|
-
get('/foo') { haml :foo }
|
116
|
-
}
|
117
|
-
get '/foo'
|
118
|
-
end
|
119
|
-
|
120
|
-
should_have_response_body %r[^<a( \w+=".+"){2}>foo bear</a>$]
|
121
|
-
should_have_response_body %r[href="/bar/ler"]
|
122
|
-
should_have_response_body %r[title="gus is nice"]
|
123
|
-
end # with options
|
124
|
-
end # using an anchor
|
125
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
require 'shoulda_tests/test_helper'
|
2
|
-
|
3
|
-
class RespondersTest < Test::Unit::TestCase
|
4
|
-
def app
|
5
|
-
@app = mock_app {
|
6
|
-
helpers Sinatra::Chicago::Responders
|
7
|
-
get "/json_bait" do
|
8
|
-
status(201)
|
9
|
-
json_response({:foo => "bar"})
|
10
|
-
end
|
11
|
-
|
12
|
-
get "/no_bait" do
|
13
|
-
status(200)
|
14
|
-
json_response(nil)
|
15
|
-
end
|
16
|
-
}
|
17
|
-
end
|
18
|
-
|
19
|
-
context "json response" do
|
20
|
-
setup { get "/json_bait" }
|
21
|
-
should_have_json_response({:foo => :bar})
|
22
|
-
end # json response
|
23
|
-
|
24
|
-
context "json response with null data" do
|
25
|
-
setup { get "/no_bait" }
|
26
|
-
should_have_json_response(/^$/)
|
27
|
-
end # json response
|
28
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
%w[ rubygems test/unit shoulda haml sass chicago rack/test chicago/shoulda ].each do |lib|
|
2
|
-
require lib
|
3
|
-
end
|
4
|
-
|
5
|
-
class Test::Unit::TestCase
|
6
|
-
include Rack::Test::Methods
|
7
|
-
|
8
|
-
# Sets up a Sinatra::Base subclass defined with the block
|
9
|
-
# given. Used in setup or individual spec methods to establish
|
10
|
-
# the application.
|
11
|
-
def mock_app(base=Sinatra::Base, &block)
|
12
|
-
@app = Sinatra.new(base, &block)
|
13
|
-
end
|
14
|
-
|
15
|
-
def extend_mock_app(&block)
|
16
|
-
@_rack_test_session ||= Rack::Test::Session.new(app)
|
17
|
-
@app.instance_eval(&block)
|
18
|
-
end
|
19
|
-
end
|