thumblemonks-chicago 0.1.2.3 → 0.1.2.4
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/chicago.gemspec +3 -3
- data/lib/chicago/application.rb +3 -15
- data/lib/chicago/helpers.rb +1 -1
- data/lib/chicago/responders.rb +1 -1
- data/lib/chicago/shoulda/sinatra.rb +2 -1
- data/test/application_test.rb +22 -4
- data/test/helpers_test.rb +108 -46
- data/test/responders_test.rb +7 -1
- data/test/test_helper.rb +11 -28
- metadata +3 -3
data/chicago.gemspec
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Gem::Specification.new do |s|
|
|
2
2
|
s.name = "chicago"
|
|
3
|
-
s.version = "0.1.2.
|
|
4
|
-
s.date = "
|
|
3
|
+
s.version = "0.1.2.4"
|
|
4
|
+
s.date = "2009-02-01"
|
|
5
5
|
s.summary = "Sinatra runtime and testing extensions used commonly by Thumblemonks"
|
|
6
6
|
s.email = %w[gus@gusg.us gabriel.gironda@gmail.com]
|
|
7
7
|
s.homepage = "http://github.com/thumblemonks/chicago/tree/master"
|
|
@@ -29,8 +29,8 @@ Gem::Specification.new do |s|
|
|
|
29
29
|
|
|
30
30
|
s.test_files = %w[
|
|
31
31
|
test/application_test.rb
|
|
32
|
-
test/responders_test.rb
|
|
33
32
|
test/helpers_test.rb
|
|
33
|
+
test/responders_test.rb
|
|
34
34
|
test/test_helper.rb
|
|
35
35
|
]
|
|
36
36
|
end
|
data/lib/chicago/application.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
module Thumblemonks
|
|
2
2
|
module Sinatra
|
|
3
|
-
module
|
|
3
|
+
module Base
|
|
4
4
|
|
|
5
5
|
# Assumes all CSS is SASS and is referenced as being in a directory named stylesheets
|
|
6
6
|
def catch_all_css(path='/stylesheets')
|
|
@@ -18,21 +18,9 @@ module Thumblemonks
|
|
|
18
18
|
end
|
|
19
19
|
end
|
|
20
20
|
|
|
21
|
-
end #
|
|
21
|
+
end # Base
|
|
22
22
|
|
|
23
|
-
module Object
|
|
24
|
-
def self.forward_sinatra_method(*methods)
|
|
25
|
-
Array(methods).each do |method|
|
|
26
|
-
module_eval <<-EOS
|
|
27
|
-
def #{method}(*args, &b) ::Sinatra.application.#{method}(*args, &b); end
|
|
28
|
-
EOS
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
forward_sinatra_method :catch_all_css, :get_obvious
|
|
33
|
-
end # Object
|
|
34
23
|
end # Sinatra
|
|
35
24
|
end # Thumblemonks
|
|
36
25
|
|
|
37
|
-
Sinatra::
|
|
38
|
-
Object.instance_eval { include Thumblemonks::Sinatra::Object }
|
|
26
|
+
Sinatra::Base.extend(Thumblemonks::Sinatra::Base)
|
data/lib/chicago/helpers.rb
CHANGED
data/lib/chicago/responders.rb
CHANGED
|
@@ -16,7 +16,8 @@ module Thumblemonks
|
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
def should_have_response_body(expected)
|
|
19
|
-
|
|
19
|
+
name = expected.is_a?(String) ? expected[0...15] : expected.to_s
|
|
20
|
+
should("have response body like #{name}") { assert_response_body expected }
|
|
20
21
|
end
|
|
21
22
|
|
|
22
23
|
def should_have_content_type(expected)
|
data/test/application_test.rb
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
require File.join(File.dirname(__FILE__), 'test_helper')
|
|
2
2
|
|
|
3
3
|
class ApplicationTest < Test::Unit::TestCase
|
|
4
|
-
|
|
4
|
+
|
|
5
5
|
context "catching all css" do
|
|
6
6
|
context "with default path" do
|
|
7
7
|
setup do
|
|
8
|
-
|
|
8
|
+
mock_app {
|
|
9
|
+
catch_all_css
|
|
10
|
+
template :foo do
|
|
11
|
+
".bar\n :display none"
|
|
12
|
+
end
|
|
13
|
+
}
|
|
14
|
+
get '/stylesheets/foo.css'
|
|
9
15
|
end
|
|
10
16
|
|
|
11
17
|
should_have_response_status 200
|
|
@@ -15,7 +21,13 @@ class ApplicationTest < Test::Unit::TestCase
|
|
|
15
21
|
|
|
16
22
|
context "with specified path" do
|
|
17
23
|
setup do
|
|
18
|
-
|
|
24
|
+
mock_app {
|
|
25
|
+
catch_all_css('/css')
|
|
26
|
+
template :goo do
|
|
27
|
+
".car\n :display some"
|
|
28
|
+
end
|
|
29
|
+
}
|
|
30
|
+
get '/css/goo.css'
|
|
19
31
|
end
|
|
20
32
|
|
|
21
33
|
should_have_response_status 200
|
|
@@ -26,7 +38,13 @@ class ApplicationTest < Test::Unit::TestCase
|
|
|
26
38
|
|
|
27
39
|
context "getting obvious views" do
|
|
28
40
|
setup do
|
|
29
|
-
|
|
41
|
+
mock_app {
|
|
42
|
+
get_obvious 'baz'
|
|
43
|
+
template :baz do
|
|
44
|
+
"Whatever man. That's just like, your opinion."
|
|
45
|
+
end
|
|
46
|
+
}
|
|
47
|
+
get '/baz'
|
|
30
48
|
end
|
|
31
49
|
|
|
32
50
|
should_have_response_body "Whatever man. That's just like, your opinion."
|
data/test/helpers_test.rb
CHANGED
|
@@ -1,57 +1,119 @@
|
|
|
1
1
|
require File.join(File.dirname(__FILE__), 'test_helper')
|
|
2
2
|
|
|
3
3
|
class HelpersTest < Test::Unit::TestCase
|
|
4
|
-
context "including
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
4
|
+
context "including stylesheet" do
|
|
5
|
+
context "for plain old foo" do
|
|
6
|
+
setup do
|
|
7
|
+
mock_app {
|
|
8
|
+
template(:foo) { "= stylesheet_include('foo')" }
|
|
9
|
+
get('/foo') { haml :foo }
|
|
10
|
+
}
|
|
11
|
+
get '/foo'
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
should_have_response_body %r[^<link( \w+=".+"){4}/>$]
|
|
15
|
+
should_have_response_body %r[href="/stylesheets/foo\.css"]
|
|
16
|
+
should_have_response_body %r[media="screen"]
|
|
17
|
+
should_have_response_body %r[rel="stylesheet"]
|
|
18
|
+
should_have_response_body %r[type="text/css"]
|
|
19
|
+
end # for plain old foo
|
|
20
|
+
|
|
21
|
+
context "for bar with options" do
|
|
22
|
+
setup do
|
|
23
|
+
mock_app {
|
|
24
|
+
template(:foo) { "= stylesheet_include('bar', :media => 'print', :baz => 'boo')" }
|
|
25
|
+
get('/foo') { haml :foo }
|
|
26
|
+
}
|
|
27
|
+
get '/foo'
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
should_have_response_body %r[^<link( \w+=".+"){5}/>$]
|
|
31
|
+
should_have_response_body %r[href="/stylesheets/bar\.css"]
|
|
32
|
+
should_have_response_body %r[media="print"]
|
|
33
|
+
should_have_response_body %r[rel="stylesheet"]
|
|
34
|
+
should_have_response_body %r[type="text/css"]
|
|
35
|
+
should_have_response_body %r[baz="boo"]
|
|
36
|
+
end # for bar with options
|
|
37
|
+
|
|
38
|
+
context "with a specific href" do
|
|
39
|
+
setup do
|
|
40
|
+
mock_app {
|
|
41
|
+
template(:foo) { "= stylesheet_include('http://example.com')" }
|
|
42
|
+
get('/foo') { haml :foo }
|
|
43
|
+
}
|
|
44
|
+
get '/foo'
|
|
45
|
+
end
|
|
46
|
+
should_have_response_body %r[href="http://example.com"]
|
|
47
|
+
end # with a specific href
|
|
25
48
|
end # including stylesheets
|
|
26
49
|
|
|
27
50
|
context "including javascript" do
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
51
|
+
context "for plain old foo" do
|
|
52
|
+
setup do
|
|
53
|
+
mock_app {
|
|
54
|
+
template(:foo) { "= javascript_include('foo')" }
|
|
55
|
+
get('/foo') { haml :foo }
|
|
56
|
+
}
|
|
57
|
+
get '/foo'
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
should_have_response_body %r[^<script( \w+=".+"){2}></script>$]
|
|
61
|
+
should_have_response_body %r[src="/javascripts/foo\.js"]
|
|
62
|
+
should_have_response_body %r[type="text/javascript"]
|
|
63
|
+
end # for plain old foo
|
|
64
|
+
|
|
65
|
+
context "for foo with options" do
|
|
66
|
+
setup do
|
|
67
|
+
mock_app {
|
|
68
|
+
template(:foo) { "= javascript_include('foo', :type => 'text/blarg', :gus => 'nice')" }
|
|
69
|
+
get('/foo') { haml :foo }
|
|
70
|
+
}
|
|
71
|
+
get '/foo'
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
should_have_response_body %r[^<script( \w+=".+"){3}></script>$]
|
|
75
|
+
should_have_response_body %r[src="/javascripts/foo\.js"]
|
|
76
|
+
should_have_response_body %r[type="text/blarg"]
|
|
77
|
+
should_have_response_body %r[gus="nice"]
|
|
78
|
+
end # for foo with options
|
|
79
|
+
|
|
80
|
+
context "with a specific src" do
|
|
81
|
+
setup do
|
|
82
|
+
mock_app {
|
|
83
|
+
template(:foo) { "= javascript_include('http://example.com')" }
|
|
84
|
+
get('/foo') { haml :foo }
|
|
85
|
+
}
|
|
86
|
+
get '/foo'
|
|
87
|
+
end
|
|
88
|
+
should_have_response_body %r[src="http://example.com"]
|
|
89
|
+
end # with a specific src
|
|
44
90
|
end # including javascript
|
|
45
91
|
|
|
46
92
|
context "using an anchor" do
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
93
|
+
context "for plain old foo" do
|
|
94
|
+
setup do
|
|
95
|
+
mock_app {
|
|
96
|
+
template(:foo) { "= anchor('foo', '/bar')" }
|
|
97
|
+
get('/foo') { haml :foo }
|
|
98
|
+
}
|
|
99
|
+
get '/foo'
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
should_have_response_body %Q[<a href="/bar">foo</a>]
|
|
103
|
+
end # for plain old foo
|
|
104
|
+
|
|
105
|
+
context "with options" do
|
|
106
|
+
setup do
|
|
107
|
+
mock_app {
|
|
108
|
+
template(:foo) { "= anchor('foo bear', '/bar/ler', :title => 'gus is nice')" }
|
|
109
|
+
get('/foo') { haml :foo }
|
|
110
|
+
}
|
|
111
|
+
get '/foo'
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
should_have_response_body %r[^<a( \w+=".+"){2}>foo bear</a>$]
|
|
115
|
+
should_have_response_body %r[href="/bar/ler"]
|
|
116
|
+
should_have_response_body %r[title="gus is nice"]
|
|
117
|
+
end # with options
|
|
56
118
|
end # using an anchor
|
|
57
119
|
end
|
data/test/responders_test.rb
CHANGED
|
@@ -4,7 +4,13 @@ class RespondersTest < Test::Unit::TestCase
|
|
|
4
4
|
|
|
5
5
|
context "json response" do
|
|
6
6
|
setup do
|
|
7
|
-
|
|
7
|
+
mock_app {
|
|
8
|
+
get "/json_bait" do
|
|
9
|
+
status(201)
|
|
10
|
+
json_response({:foo => "bar"})
|
|
11
|
+
end
|
|
12
|
+
}
|
|
13
|
+
get "/json_bait"
|
|
8
14
|
end
|
|
9
15
|
|
|
10
16
|
should_have_response_status 201
|
data/test/test_helper.rb
CHANGED
|
@@ -1,36 +1,19 @@
|
|
|
1
1
|
require 'rubygems'
|
|
2
2
|
|
|
3
|
-
require 'sinatra'
|
|
4
|
-
require 'sinatra/test/unit'
|
|
5
3
|
require 'shoulda'
|
|
6
4
|
|
|
5
|
+
require 'sinatra/base'
|
|
6
|
+
require 'sinatra/test'
|
|
7
|
+
require 'sinatra/test/unit'
|
|
8
|
+
|
|
7
9
|
require 'chicago'
|
|
8
10
|
require 'chicago/shoulda'
|
|
9
11
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
module Sinatra::Test
|
|
13
|
+
# Sets up a Sinatra::Base subclass defined with the block
|
|
14
|
+
# given. Used in setup or individual spec methods to establish
|
|
15
|
+
# the application.
|
|
16
|
+
def mock_app(base=Sinatra::Base, &block)
|
|
17
|
+
@app = Sinatra.new(base, &block)
|
|
18
|
+
end
|
|
14
19
|
end
|
|
15
|
-
|
|
16
|
-
# CSS Stuff
|
|
17
|
-
|
|
18
|
-
catch_all_css
|
|
19
|
-
template :foo do
|
|
20
|
-
".bar\n :display none"
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
catch_all_css('/css')
|
|
24
|
-
template :goo do
|
|
25
|
-
".car\n :display some"
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
# Getting obvious
|
|
29
|
-
|
|
30
|
-
get_obvious 'baz'
|
|
31
|
-
template :baz do
|
|
32
|
-
"Whatever man. That's just like, your opinion."
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
# Helpers
|
|
36
|
-
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: thumblemonks-chicago
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.2.
|
|
4
|
+
version: 0.1.2.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Justin Knowlden
|
|
@@ -10,7 +10,7 @@ autorequire:
|
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
12
|
|
|
13
|
-
date:
|
|
13
|
+
date: 2009-02-01 00:00:00 -08:00
|
|
14
14
|
default_executable:
|
|
15
15
|
dependencies: []
|
|
16
16
|
|
|
@@ -66,6 +66,6 @@ specification_version: 2
|
|
|
66
66
|
summary: Sinatra runtime and testing extensions used commonly by Thumblemonks
|
|
67
67
|
test_files:
|
|
68
68
|
- test/application_test.rb
|
|
69
|
-
- test/responders_test.rb
|
|
70
69
|
- test/helpers_test.rb
|
|
70
|
+
- test/responders_test.rb
|
|
71
71
|
- test/test_helper.rb
|