chicago 0.3.13 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,2 +1,4 @@
1
1
  *.gem
2
2
  *.tmproj
3
+ .rvmrc
4
+
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source :rubygems
2
+
3
+ gemspec
4
+
@@ -0,0 +1,22 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ chicago (0.3.13)
5
+ rack-test
6
+ riot
7
+
8
+ GEM
9
+ remote: http://rubygems.org/
10
+ specs:
11
+ rack (1.4.1)
12
+ rack-test (0.6.1)
13
+ rack (>= 1.0)
14
+ riot (0.12.5)
15
+ rr
16
+ rr (1.0.4)
17
+
18
+ PLATFORMS
19
+ ruby
20
+
21
+ DEPENDENCIES
22
+ chicago!
@@ -5,52 +5,29 @@
5
5
 
6
6
  Yeah, we're real clever. We're also from ["The city in mid-west best city in the whole wide wide world"](http://www.azlyrics.com/lyrics/lupefiasco/gogogadgetflow.html) ... which makes us double the clever.
7
7
 
8
- Chicago is a collection of runtime and test extensions and helpers that makes some common tasks a little bit easier.
8
+ Chicago is a collection of test extensions and helpers that makes some common tasks in Sinatra a little bit easier.
9
9
 
10
10
  ## Installation
11
11
 
12
- First, make sure GemCutter is added to your list of sources. If not, install it like so or just follow the instructions for installing the gemcutter gem:
12
+ Installing chicago is a quick gem install:
13
13
 
14
- sudo gem sources -a http://gemcutter.org
15
-
16
- Then, installing chicago is a quick gem install:
17
-
18
- sudo gem install chicago
14
+ gem install chicago
19
15
 
20
16
  ## Usage
21
17
 
22
- ### Sinatra runtime app
23
-
24
- In your Sinatra app, do this:
25
-
26
- require 'chicago'
27
-
28
- And you'll get some helpful Sinatra extensions and helpers.
29
-
30
- If you're Sinatra app is considered modular - as in, you are not using the `Sinatra::Default` app - you will want to add the following in your app:
31
-
32
- YourApp < Sinatra::Base
33
- register Sinatra::Chicago # for some DSL helpers
34
- helpers Sinatra::Chicago::Helpers # for standard helpers
35
- helpers Sinatra::Chicago::Responders # for JSON assistance
36
- end
37
-
38
- You don't necessarily need all of them. You just need to "include" the statements that mix-in the functionality you want.
39
-
40
18
  ### Sinatra testing
41
19
 
42
- Assuming you have required 'rack/test', like so:
43
-
44
- require 'rack/test'
45
-
46
- This is because these macros use last_request defined by the Rack/Test library. If you're using [Riot](http://github.com/thumblemonks/riot) in your tests of your Sinatra app, do this:
20
+ If you're using [Riot](http://github.com/thumblemonks/riot) in your tests of your Sinatra app, do this:
47
21
 
48
22
  require 'chicago/riot'
49
23
 
50
- ... and you'll get a bunch of cool Protest macros for testing specific Sinatra stuff.
51
-
52
- If you're using Shoulda in your tests of your Sinatra app, do this:
24
+ ... and you'll get a bunch of cool Riot macros for testing specific Sinatra stuff:
53
25
 
54
- require 'chicago/shoulda'
26
+ * asserts_response
27
+ * asserts_response_status
28
+ * asserts_content_type
29
+ * asserts_response_body
30
+ * asserts_location
31
+ * asserts_json_response
32
+ * asserts_redirected_to
55
33
 
56
- ... and you'll get a bunch of cool Shoulda macros for testing specific Sinatra stuff.
@@ -1,66 +1,21 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
- # -*- encoding: utf-8 -*-
1
+ require "./lib/chicago/version"
5
2
 
6
3
  Gem::Specification.new do |s|
7
- s.name = %q{chicago}
8
- s.version = "0.3.13"
4
+ s.name = %q{chicago}
5
+ s.version = Chicago::VERSION
6
+ s.platform = Gem::Platform::RUBY
9
7
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Justin 'Gus' Knowlden"]
12
- s.date = %q{2010-05-17}
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
- s.email = %q{gus@gusg.us}
15
- s.extra_rdoc_files = [
16
- "README.markdown"
17
- ]
18
- s.files = [
19
- ".gitignore",
20
- "MIT-LICENSE",
21
- "README.markdown",
22
- "Rakefile",
23
- "VERSION",
24
- "chicago.gemspec",
25
- "lib/chicago.rb",
26
- "lib/chicago/application.rb",
27
- "lib/chicago/helpers.rb",
28
- "lib/chicago/responders.rb",
29
- "lib/chicago/riot.rb",
30
- "lib/chicago/riot/macros.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"
36
- ]
37
- s.homepage = %q{http://github.com/thumblemonks/chicago}
38
- s.rdoc_options = ["--charset=UTF-8"]
39
- s.require_paths = ["lib"]
40
- s.rubygems_version = %q{1.3.6}
41
- s.summary = %q{Sinatra runtime and testing extensions used commonly by Thumblemonks}
42
- s.test_files = [
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"
48
- ]
8
+ s.authors = ["Justin 'Gus' Knowlden"]
9
+ s.summary = %q{Sinatra testing extensions used commonly by Thumblemonks}
10
+ s.description = %q{Sinatra testing extensions used commonly by Thumblemonks.}
11
+ s.email = %q{gus@gusg.us}
12
+ s.homepage = %q{http://github.com/thumblemonks/chicago}
49
13
 
50
- if s.respond_to? :specification_version then
51
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
52
- s.specification_version = 3
14
+ s.files = `git ls-files`.split("\n")
15
+ s.test_files = `git ls-files -- {test}/*`.split("\n")
16
+ s.require_paths = ["lib"]
53
17
 
54
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
55
- s.add_development_dependency(%q<riot>, [">= 0"])
56
- s.add_development_dependency(%q<rack-test>, [">= 0"])
57
- else
58
- s.add_dependency(%q<riot>, [">= 0"])
59
- s.add_dependency(%q<rack-test>, [">= 0"])
60
- end
61
- else
62
- s.add_dependency(%q<riot>, [">= 0"])
63
- s.add_dependency(%q<rack-test>, [">= 0"])
64
- end
18
+ s.add_dependency(%q<riot>, [">= 0"])
19
+ s.add_dependency(%q<rack-test>, [">= 0"])
65
20
  end
66
21
 
@@ -46,7 +46,7 @@ module Chicago
46
46
  end
47
47
  asserts("response body has JSON") { last_response.body }.equals(&(block || lambda {json}))
48
48
 
49
- asserts_content_type(args.empty? ? 'application/json' : args.shift)
49
+ asserts_content_type(args.empty? ? 'application/json;charset=utf-8' : args.shift)
50
50
  end
51
51
 
52
52
  # Usage:
@@ -0,0 +1,4 @@
1
+ module Chicago
2
+ VERSION = "0.4.0"
3
+ end
4
+
metadata CHANGED
@@ -1,105 +1,85 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: chicago
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 3
8
- - 13
9
- version: 0.3.13
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.0
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - Justin 'Gus' Knowlden
13
9
  autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
-
17
- date: 2010-05-17 00:00:00 -05:00
18
- default_executable:
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2012-09-17 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: riot
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
22
23
  prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
24
- requirements:
25
- - - ">="
26
- - !ruby/object:Gem::Version
27
- segments:
28
- - 0
29
- version: "0"
30
- type: :development
31
- version_requirements: *id001
32
- - !ruby/object:Gem::Dependency
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
33
31
  name: rack-test
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
34
39
  prerelease: false
35
- requirement: &id002 !ruby/object:Gem::Requirement
36
- requirements:
37
- - - ">="
38
- - !ruby/object:Gem::Version
39
- segments:
40
- - 0
41
- version: "0"
42
- type: :development
43
- version_requirements: *id002
44
- description: 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.
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: Sinatra testing extensions used commonly by Thumblemonks.
45
47
  email: gus@gusg.us
46
48
  executables: []
47
-
48
49
  extensions: []
49
-
50
- extra_rdoc_files:
51
- - README.markdown
52
- files:
50
+ extra_rdoc_files: []
51
+ files:
53
52
  - .gitignore
53
+ - Gemfile
54
+ - Gemfile.lock
54
55
  - MIT-LICENSE
55
56
  - README.markdown
56
- - Rakefile
57
- - VERSION
58
57
  - chicago.gemspec
59
- - lib/chicago.rb
60
- - lib/chicago/application.rb
61
- - lib/chicago/helpers.rb
62
- - lib/chicago/responders.rb
63
58
  - lib/chicago/riot.rb
64
59
  - lib/chicago/riot/macros.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
70
- has_rdoc: true
60
+ - lib/chicago/version.rb
71
61
  homepage: http://github.com/thumblemonks/chicago
72
62
  licenses: []
73
-
74
63
  post_install_message:
75
- rdoc_options:
76
- - --charset=UTF-8
77
- require_paths:
64
+ rdoc_options: []
65
+ require_paths:
78
66
  - lib
79
- required_ruby_version: !ruby/object:Gem::Requirement
80
- requirements:
81
- - - ">="
82
- - !ruby/object:Gem::Version
83
- segments:
84
- - 0
85
- version: "0"
86
- required_rubygems_version: !ruby/object:Gem::Requirement
87
- requirements:
88
- - - ">="
89
- - !ruby/object:Gem::Version
90
- segments:
91
- - 0
92
- version: "0"
67
+ required_ruby_version: !ruby/object:Gem::Requirement
68
+ none: false
69
+ requirements:
70
+ - - ! '>='
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
93
79
  requirements: []
94
-
95
80
  rubyforge_project:
96
- rubygems_version: 1.3.6
81
+ rubygems_version: 1.8.24
97
82
  signing_key:
98
83
  specification_version: 3
99
- summary: Sinatra runtime and testing extensions used commonly by Thumblemonks
100
- test_files:
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
84
+ summary: Sinatra testing extensions used commonly by Thumblemonks
85
+ test_files: []
data/Rakefile DELETED
@@ -1,40 +0,0 @@
1
- require 'rubygems'
2
- require 'rake'
3
- require 'rake/testtask'
4
-
5
- desc 'Default task: run all tests'
6
- task :default => [:test]
7
-
8
- task(:set_test_env) { ENV['RACK_ENV'] ||= 'test' }
9
-
10
- desc "Run all tests"
11
- Rake::TestTask.new("test") do |t|
12
- t.libs.concat ['./lib', './test']
13
- t.test_files = FileList['test/*_test.rb']
14
- t.verbose = true
15
- end
16
-
17
- desc "Open an irb session preloaded with this library"
18
- task :console do
19
- exec "irb -rubygems"
20
- end
21
-
22
- #
23
- # Some monks like diamonds. I like gems.
24
-
25
- begin
26
- require 'jeweler'
27
- Jeweler::Tasks.new do |gem|
28
- gem.name = "chicago"
29
- gem.summary = "Sinatra runtime and testing extensions used commonly by Thumblemonks"
30
- gem.description = "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."
31
- gem.email = "gus@gusg.us"
32
- gem.homepage = "http://github.com/thumblemonks/chicago"
33
- gem.authors = ["Justin 'Gus' Knowlden"]
34
- gem.add_development_dependency "riot"
35
- gem.add_development_dependency "rack-test"
36
- end
37
- Jeweler::GemcutterTasks.new
38
- rescue LoadError
39
- puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
40
- end
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.3.13
@@ -1,4 +0,0 @@
1
- require 'sinatra/base'
2
- require 'chicago/application'
3
- require 'chicago/responders'
4
- require 'chicago/helpers'
@@ -1,28 +0,0 @@
1
- module Sinatra
2
- module Chicago
3
-
4
- # Assumes all CSS is SASS and is referenced as being in a directory named stylesheets
5
- # If SASS file is not defined, the route will passed on to - theoretically - the real
6
- # CSS in the public directory.
7
- def catch_all_css(path='/stylesheets')
8
- get("#{path}/*.css") do
9
- begin
10
- content_type 'text/css'
11
- sass params["splat"].first.to_sym
12
- rescue Errno::ENOENT
13
- pass
14
- end
15
- end
16
- end
17
-
18
- # When you don't want anything special, but to load a named view as HAML.
19
- def get_obvious(name)
20
- get "/#{name}" do
21
- haml name.to_sym
22
- end
23
- end
24
-
25
- end # Chicago
26
-
27
- register Chicago
28
- end # Sinatra
@@ -1,77 +0,0 @@
1
- module Sinatra
2
- module Chicago
3
- module Helpers
4
- # A basic anchor (link_to) tag
5
- #
6
- # Exmaples:
7
- #
8
- # anchor('GusGus', 'http://gusg.us')
9
- # => <a href="http://gusg.us">GusG.us</a>
10
- #
11
- # anchor('GusGus', 'http://gusg.us', :title => 'You know who!')
12
- # => <a href="http://gusg.us" title="You know who!">GusG.us</a>
13
- def anchor(name, url, options={})
14
- defaults = {:href => url}
15
- options_str = hash_to_attributes(defaults.merge(options))
16
- %Q[<a #{options_str}>#{name}</a>]
17
- end
18
-
19
- # A helper to include stylesheet links. Currently defaults everything to
20
- # load from a /stylesheets directory.
21
- #
22
- # Exmaples:
23
- #
24
- # stylesheet_include('foo')
25
- # => <link href="/stylsheets/foo.css" media="screen" rel="stylesheet" type="text/css" />
26
- #
27
- # stylesheet_include('foo/bar')
28
- # => <link href="/stylsheets/foo/bar.css" media="screen" rel="stylesheet" type="text/css" />
29
- #
30
- # stylesheet_include('foo', :media => "print")
31
- # => <link href="/stylsheets/foo.css" media="print" rel="stylesheet" type="text/css" />
32
- #
33
- # stylesheet_include('http://example.com/foo.css')
34
- # => <link href="http://example.com/foo.css" media="print" rel="stylesheet" type="text/css" />
35
- def stylesheet_include(name, options={})
36
- name = "/stylesheets/#{name}.css" unless remote_asset?(name)
37
- defaults = {:href => name, :media => "screen",
38
- :rel => "stylesheet", :type => "text/css"}
39
- options_str = hash_to_attributes(defaults.merge(options))
40
- %Q[<link #{options_str}/>]
41
- end
42
-
43
- # A helper to include javascript source tags. Currently defaults everything
44
- # to load from a /javascripts directory.
45
- #
46
- # Exmaples:
47
- #
48
- # javascript_include('foo')
49
- # => <javascript src="/javascripts/foo.js" type="text/javascript"></script>
50
- #
51
- # javascript_include('foo/bar')
52
- # => <javascript src="/javascripts/foo/bar.js" type="text/javascript"></script>
53
- #
54
- # javascript_include('foo', :something => "great")
55
- # => <javascript src="/javascripts/foo.js" type="text/javascript" something="great"></script>
56
- #
57
- # javascript_include('http://example.com/foo.js')
58
- # => <javascript src="http://example.com/foo.js" type="text/javascript"></script>
59
- def javascript_include(name, options={})
60
- name = "/javascripts/#{name}.js" unless remote_asset?(name)
61
- defaults = {:src => name, :type => "text/javascript"}
62
- options_str = hash_to_attributes(defaults.merge(options))
63
- %Q[<script #{options_str}></script>]
64
- end
65
- private
66
- def remote_asset?(uri)
67
- uri =~ %r[^\w+://.+]
68
- end
69
-
70
- def hash_to_attributes(options)
71
- options.map {|k,v| "#{k}=\"#{v}\""}.join(' ')
72
- end
73
- end # Helpers
74
- end # Chicago
75
-
76
- helpers Chicago::Helpers
77
- end # Sinatra
@@ -1,15 +0,0 @@
1
- module Sinatra
2
- module Chicago
3
- module Responders
4
-
5
- # Returns a JSON response for an object. Will return an empty string if the provided object is nil.
6
- def json_response(object)
7
- content_type 'application/json'
8
- object ? object.to_json : ""
9
- end
10
-
11
- end # Responders
12
- end # Chicago
13
-
14
- helpers Chicago::Responders
15
- end # Sinatra
@@ -1,48 +0,0 @@
1
- require 'teststrap'
2
-
3
- context "Application Test:" do
4
-
5
- setup do
6
- 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
- asserts_response_status 200
25
- asserts_content_type 'text/css'
26
- asserts_response_body %r[.bar \{\s+display: none; \}\s]
27
- end
28
-
29
- context "with specified path" do
30
- setup { get '/css/goo.css' }
31
- asserts_response_status 200
32
- asserts_content_type 'text/css'
33
- asserts_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
- asserts_response_status 404
39
- asserts_content_type 'text/css'
40
- end
41
- end # catching all css
42
-
43
- context "getting obvious views" do
44
- setup { get '/baz' }
45
- asserts_response_body "Whatever man. That's just like, your opinion.\n"
46
- end # getting obvious views
47
-
48
- end
@@ -1,125 +0,0 @@
1
- require 'teststrap'
2
-
3
- context "Helpers Test:" do
4
- setup do
5
- 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
- asserts_response_body %r[^<link( \w+=".+"){4}/>$]
21
- asserts_response_body %r[href="/stylesheets/foo\.css"]
22
- asserts_response_body %r[media="screen"]
23
- asserts_response_body %r[rel="stylesheet"]
24
- asserts_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
- asserts_response_body %r[^<link( \w+=".+"){5}/>$]
37
- asserts_response_body %r[href="/stylesheets/bar\.css"]
38
- asserts_response_body %r[media="print"]
39
- asserts_response_body %r[rel="stylesheet"]
40
- asserts_response_body %r[type="text/css"]
41
- asserts_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
- asserts_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
- asserts_response_body %r[^<script( \w+=".+"){2}></script>$]
67
- asserts_response_body %r[src="/javascripts/foo\.js"]
68
- asserts_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
- asserts_response_body %r[^<script( \w+=".+"){3}></script>$]
81
- asserts_response_body %r[src="/javascripts/foo\.js"]
82
- asserts_response_body %r[type="text/blarg"]
83
- asserts_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
- asserts_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
- asserts_response_body %Q[<a href="/bar">foo</a>\n]
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
- asserts_response_body %r[^<a( \w+=".+"){2}>foo bear</a>$]
121
- asserts_response_body %r[href="/bar/ler"]
122
- asserts_response_body %r[title="gus is nice"]
123
- end # with options
124
- end # using an anchor
125
- end
@@ -1,19 +0,0 @@
1
- require 'teststrap'
2
-
3
- context "Responders Test:" do
4
- setup do
5
- mock_app {
6
- helpers Sinatra::Chicago::Responders
7
- get "/json_bait" do
8
- status(201)
9
- json_response({:foo => "bar"})
10
- end
11
- }
12
- end
13
-
14
- context "json response" do
15
- setup { get "/json_bait" }
16
- asserts_response_status 201
17
- asserts_json_response({:foo => :bar})
18
- end # json response
19
- end
@@ -1,52 +0,0 @@
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
- helper(:bar_value) { "bar" }
39
- setup { get('/json-with-content-type') }
40
- asserts_json_response("text/javascript;charset=utf-8") { {:foo => bar_value}.to_json }
41
- end # with content expectation provided as block
42
- end # json response
43
-
44
- context "response body" do
45
- context "with a block for the expected value" do
46
- setup { get('/basic-json') }
47
- asserts_response(:body).equals do
48
- {:foo => "bar"}.to_json
49
- end
50
- end # with a block for the expected value
51
- end # response body
52
- end
@@ -1,9 +0,0 @@
1
- %w[ rubygems haml sass chicago chicago/riot ].each do |lib|
2
- require lib
3
- end
4
-
5
- class Riot::Situation
6
- def extend_mock_app(&block)
7
- @app.instance_eval(&block)
8
- end
9
- end