chicago 0.3.5 → 0.3.6

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ *.gem
data/README.markdown CHANGED
@@ -5,7 +5,19 @@
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
- ## What what?
8
+ Chicago is a collection of runtime and test extensions and helpers that makes some common tasks a little bit easier.
9
+
10
+ ## Installation
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:
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
19
+
20
+ ## Usage
9
21
 
10
22
  ### Sinatra runtime app
11
23
 
@@ -31,9 +43,9 @@ Assuming you have required 'rack/test', like so:
31
43
 
32
44
  require 'rack/test'
33
45
 
34
- This is because these macros use last_request defined by the Rack/Test library. If you're using [Protest](http://github.com/thumblemonks/protest) in your tests of your Sinatra app, do this:
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:
35
47
 
36
- require 'chicago/protest'
48
+ require 'chicago/riot'
37
49
 
38
50
  ... and you'll get a bunch of cool Protest macros for testing specific Sinatra stuff.
39
51
 
data/Rakefile CHANGED
@@ -8,15 +8,16 @@ task :default => [:test]
8
8
  task(:set_test_env) { ENV['RACK_ENV'] ||= 'test' }
9
9
 
10
10
  desc "Run all tests"
11
- task :test => [:set_test_env] do
12
- $:.concat ['./lib', './test']
13
- Dir.glob("./test/*_test.rb").each { |test| require test }
11
+ Rake::TestTask.new("test") do |t|
12
+ t.libs.concat ['./lib', './test']
13
+ t.test_files = FileList['test/riot_tests/*_test.rb']
14
+ t.verbose = true
14
15
  end
15
16
 
16
17
  task "test:shoulda" => [:set_test_env]
17
18
  desc "Run all Shoulda based tests"
18
19
  Rake::TestTask.new("test:shoulda") do |t|
19
- t.libs << "test/shoulda_tests"
20
+ t.libs.concat ['./lib', './test']
20
21
  t.test_files = FileList['test/shoulda_tests/*_test.rb']
21
22
  t.verbose = true
22
23
  end
@@ -30,3 +31,23 @@ desc "Open an irb session preloaded with this library"
30
31
  task :console do
31
32
  exec "irb -rubygems"
32
33
  end
34
+
35
+ #
36
+ # Some monks like diamonds. I like gems.
37
+
38
+ begin
39
+ require 'jeweler'
40
+ Jeweler::Tasks.new do |gem|
41
+ gem.name = "chicago"
42
+ gem.summary = "Sinatra runtime and testing extensions used commonly by Thumblemonks"
43
+ 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."
44
+ gem.email = "gus@gusg.us"
45
+ gem.homepage = "http://github.com/thumblemonks/chicago"
46
+ gem.authors = ["Justin 'Gus' Knowlden"]
47
+ gem.add_development_dependency "riot"
48
+ gem.add_development_dependency "rack-test"
49
+ end
50
+ Jeweler::GemcutterTasks.new
51
+ rescue LoadError
52
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
53
+ end
data/chicago.gemspec CHANGED
@@ -1,42 +1,75 @@
1
- Gem::Specification.new do |s|
2
- s.name = "chicago"
3
- s.version = "0.3.5"
4
- s.date = "2009-10-04"
5
- s.summary = "Sinatra runtime and testing extensions used commonly by Thumblemonks"
6
- s.email = %w[gus@gusg.us gabriel.gironda@gmail.com]
7
- s.homepage = "http://github.com/thumblemonks/chicago/tree/master"
8
- s.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."
9
- s.authors = %w[Justin\ Knowlden Gabriel\ Gironda]
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 -*-
10
5
 
11
- s.has_rdoc = true
12
- s.rdoc_options = ["--main", "README.markdown"]
13
- s.extra_rdoc_files = ["README.markdown"]
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{chicago}
8
+ s.version = "0.3.6"
14
9
 
15
- # run git ls-files to get an updated list
16
- s.files = %w[
17
- MIT-LICENSE
18
- README.markdown
19
- chicago.gemspec
20
- lib/chicago.rb
21
- lib/chicago/application.rb
22
- lib/chicago/helpers.rb
23
- lib/chicago/responders.rb
24
- lib/chicago/riot.rb
25
- lib/chicago/riot/macros.rb
26
- lib/chicago/shoulda.rb
27
- lib/chicago/shoulda/sinatra.rb
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{2009-11-21}
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
+ "chicago.gemspec",
24
+ "lib/chicago.rb",
25
+ "lib/chicago/application.rb",
26
+ "lib/chicago/helpers.rb",
27
+ "lib/chicago/responders.rb",
28
+ "lib/chicago/riot.rb",
29
+ "lib/chicago/riot/macros.rb",
30
+ "lib/chicago/shoulda.rb",
31
+ "lib/chicago/shoulda/sinatra.rb",
32
+ "test/riot_tests/application_test.rb",
33
+ "test/riot_tests/helpers_test.rb",
34
+ "test/riot_tests/responders_test.rb",
35
+ "test/riot_tests/riot_macros_test.rb",
36
+ "test/riot_tests/test_helper.rb",
37
+ "test/shoulda_tests/application_test.rb",
38
+ "test/shoulda_tests/helpers_test.rb",
39
+ "test/shoulda_tests/responders_test.rb",
40
+ "test/shoulda_tests/test_helper.rb"
28
41
  ]
29
-
30
- s.test_files = %w[
31
- Rakefile
32
- test/application_test.rb
33
- test/helpers_test.rb
34
- test/protest_macros_test.rb
35
- test/responders_test.rb
36
- test/shoulda_tests/application_test.rb
37
- test/shoulda_tests/helpers_test.rb
38
- test/shoulda_tests/responders_test.rb
39
- test/shoulda_tests/test_helper.rb
40
- test/test_helper.rb
42
+ s.homepage = %q{http://github.com/thumblemonks/chicago}
43
+ s.rdoc_options = ["--charset=UTF-8"]
44
+ s.require_paths = ["lib"]
45
+ s.rubygems_version = %q{1.3.5}
46
+ s.summary = %q{Sinatra runtime and testing extensions used commonly by Thumblemonks}
47
+ s.test_files = [
48
+ "test/riot_tests/application_test.rb",
49
+ "test/riot_tests/helpers_test.rb",
50
+ "test/riot_tests/responders_test.rb",
51
+ "test/riot_tests/riot_macros_test.rb",
52
+ "test/riot_tests/test_helper.rb",
53
+ "test/shoulda_tests/application_test.rb",
54
+ "test/shoulda_tests/helpers_test.rb",
55
+ "test/shoulda_tests/responders_test.rb",
56
+ "test/shoulda_tests/test_helper.rb"
41
57
  ]
58
+
59
+ if s.respond_to? :specification_version then
60
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
61
+ s.specification_version = 3
62
+
63
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
64
+ s.add_development_dependency(%q<riot>, [">= 0"])
65
+ s.add_development_dependency(%q<rack-test>, [">= 0"])
66
+ else
67
+ s.add_dependency(%q<riot>, [">= 0"])
68
+ s.add_dependency(%q<rack-test>, [">= 0"])
69
+ end
70
+ else
71
+ s.add_dependency(%q<riot>, [">= 0"])
72
+ s.add_dependency(%q<rack-test>, [">= 0"])
73
+ end
42
74
  end
75
+
@@ -21,12 +21,15 @@ module Chicago
21
21
  end.matches(expected_path)
22
22
  end
23
23
 
24
- def asserts_json_response(json, &block)
24
+ def asserts_json_response(json)
25
25
  asserts_content_type 'application/json'
26
+
27
+ json = json.to_json unless json.instance_of?(String)
28
+ json
29
+
26
30
  asserts("response body has JSON") do
27
- json = json.to_json unless json.instance_of?(String)
28
- json
29
- end.equals(situation.last_response.body)
31
+ last_response.body
32
+ end.equals(json)
30
33
  # Calling situation is kind of yucky, but maybe not. The maybe not is because of how explicit it is
31
34
  # to say "situation" (gus)
32
35
  end
@@ -42,4 +45,4 @@ module Chicago
42
45
  end # Riot
43
46
  end # Chicago
44
47
 
45
- Riot::Context.instance_eval { include Chicago::Riot::Macros }
48
+ Riot::Context.instance_eval { include Chicago::Riot::Macros }
@@ -1,4 +1,4 @@
1
- require 'test_helper'
1
+ require 'riot_tests/test_helper'
2
2
 
3
3
  context "Application Test:" do
4
4
 
@@ -1,4 +1,4 @@
1
- require 'test_helper'
1
+ require 'riot_tests/test_helper'
2
2
 
3
3
  context "Helpers Test:" do
4
4
  setup do
@@ -1,4 +1,4 @@
1
- require 'test_helper'
1
+ require 'riot_tests/test_helper'
2
2
 
3
3
  context "Responders Test:" do
4
4
  setup do
@@ -1,15 +1,15 @@
1
- require 'test_helper'
1
+ require 'riot_tests/test_helper'
2
2
 
3
3
  context "Riot Macros Test:" do
4
4
  setup do
5
5
  mock_app {
6
6
  helpers Sinatra::Chicago::Responders
7
- get("/redirecter") { redirect '/foo/bar' }
7
+ get("/redirector") { redirect '/foo/bar' }
8
8
  }
9
9
  end
10
10
 
11
11
  context "asserts redirected to" do
12
- setup { get('/redirecter') }
12
+ setup { get('/redirector') }
13
13
  asserts_redirected_to('/foo/bar')
14
14
  end # asserts redirected to
15
15
  end
@@ -2,7 +2,9 @@
2
2
  require lib
3
3
  end
4
4
 
5
- module Rack::Test::Methods
5
+ class Riot::Situation
6
+ include Rack::Test::Methods
7
+
6
8
  # Sets up a Sinatra::Base subclass defined with the block
7
9
  # given. Used in setup or individual spec methods to establish
8
10
  # the application.
@@ -11,7 +13,6 @@ module Rack::Test::Methods
11
13
  end
12
14
 
13
15
  def extend_mock_app(&block)
14
- @_rack_test_session ||= Rack::Test::Session.new(app)
15
16
  @app.instance_eval(&block)
16
17
  end
17
18
 
@@ -19,9 +20,3 @@ module Rack::Test::Methods
19
20
  @app
20
21
  end
21
22
  end
22
-
23
- class Riot::Situation
24
- include Rack::Test::Methods
25
- end
26
-
27
- at_exit { Riot.report }
@@ -1,4 +1,4 @@
1
- require 'test_helper'
1
+ require 'shoulda_tests/test_helper'
2
2
 
3
3
  class ApplicationTest < Test::Unit::TestCase
4
4
 
@@ -1,4 +1,4 @@
1
- require 'test_helper'
1
+ require 'shoulda_tests/test_helper'
2
2
 
3
3
  class HelpersTest < Test::Unit::TestCase
4
4
  def app
@@ -1,4 +1,4 @@
1
- require 'test_helper'
1
+ require 'shoulda_tests/test_helper'
2
2
 
3
3
  class RespondersTest < Test::Unit::TestCase
4
4
  def app
@@ -2,7 +2,9 @@
2
2
  require lib
3
3
  end
4
4
 
5
- module Rack::Test::Methods
5
+ class Test::Unit::TestCase
6
+ include Rack::Test::Methods
7
+
6
8
  # Sets up a Sinatra::Base subclass defined with the block
7
9
  # given. Used in setup or individual spec methods to establish
8
10
  # the application.
@@ -15,7 +17,3 @@ module Rack::Test::Methods
15
17
  @app.instance_eval(&block)
16
18
  end
17
19
  end
18
-
19
- class Test::Unit::TestCase
20
- include Rack::Test::Methods
21
- end
metadata CHANGED
@@ -1,23 +1,39 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chicago
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.5
4
+ version: 0.3.6
5
5
  platform: ruby
6
6
  authors:
7
- - Justin Knowlden
8
- - Gabriel Gironda
7
+ - Justin 'Gus' Knowlden
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
11
 
13
- date: 2009-10-04 00:00:00 -05:00
12
+ date: 2009-11-21 00:00:00 -06:00
14
13
  default_executable:
15
- dependencies: []
16
-
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: riot
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: rack-test
27
+ type: :development
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0"
34
+ version:
17
35
  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.
18
- email:
19
- - gus@gusg.us
20
- - gabriel.gironda@gmail.com
36
+ email: gus@gusg.us
21
37
  executables: []
22
38
 
23
39
  extensions: []
@@ -25,8 +41,10 @@ extensions: []
25
41
  extra_rdoc_files:
26
42
  - README.markdown
27
43
  files:
44
+ - .gitignore
28
45
  - MIT-LICENSE
29
46
  - README.markdown
47
+ - Rakefile
30
48
  - chicago.gemspec
31
49
  - lib/chicago.rb
32
50
  - lib/chicago/application.rb
@@ -36,14 +54,22 @@ files:
36
54
  - lib/chicago/riot/macros.rb
37
55
  - lib/chicago/shoulda.rb
38
56
  - lib/chicago/shoulda/sinatra.rb
57
+ - test/riot_tests/application_test.rb
58
+ - test/riot_tests/helpers_test.rb
59
+ - test/riot_tests/responders_test.rb
60
+ - test/riot_tests/riot_macros_test.rb
61
+ - test/riot_tests/test_helper.rb
62
+ - test/shoulda_tests/application_test.rb
63
+ - test/shoulda_tests/helpers_test.rb
64
+ - test/shoulda_tests/responders_test.rb
65
+ - test/shoulda_tests/test_helper.rb
39
66
  has_rdoc: true
40
- homepage: http://github.com/thumblemonks/chicago/tree/master
67
+ homepage: http://github.com/thumblemonks/chicago
41
68
  licenses: []
42
69
 
43
70
  post_install_message:
44
71
  rdoc_options:
45
- - --main
46
- - README.markdown
72
+ - --charset=UTF-8
47
73
  require_paths:
48
74
  - lib
49
75
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -66,13 +92,12 @@ signing_key:
66
92
  specification_version: 3
67
93
  summary: Sinatra runtime and testing extensions used commonly by Thumblemonks
68
94
  test_files:
69
- - Rakefile
70
- - test/application_test.rb
71
- - test/helpers_test.rb
72
- - test/protest_macros_test.rb
73
- - test/responders_test.rb
95
+ - test/riot_tests/application_test.rb
96
+ - test/riot_tests/helpers_test.rb
97
+ - test/riot_tests/responders_test.rb
98
+ - test/riot_tests/riot_macros_test.rb
99
+ - test/riot_tests/test_helper.rb
74
100
  - test/shoulda_tests/application_test.rb
75
101
  - test/shoulda_tests/helpers_test.rb
76
102
  - test/shoulda_tests/responders_test.rb
77
103
  - test/shoulda_tests/test_helper.rb
78
- - test/test_helper.rb