Skip to content
This repository

Switch out test-spec for rspec 2 for Ruby 1.9 compatability #62

Open
wants to merge 2 commits into from

4 participants

mipearson Konstantin Haase Christian Neukirchen James Tucker
mipearson

Getting Test::Spec & Test::Unit working under Ruby 1.9 was a dead end. It was much easier for me to bring in rspec.

MiniTest was considered but the matcher syntax already present is much closer to what RSpec uses.

Five tests fail for me in this PR, but they're the same five tests that fail in the origin/master, so I'm guessing that's not my fault :)

Konstantin Haase
Collaborator

+1

Christian Neukirchen
James Tucker
Owner

I would strongly prefer bacon, for quite a few reasons. The non-personal reasons are however, that we can control it, which is important as it is likely that we will support a broader set of rubies for longer than rspec will, and I do not want to be encumbered with patching such a dependency set.

This kind of problem already occurred in rack when I let tenderlove commit changes that use the ruby stdlib for escaping. It's been a buggy, security flawed disaster for us, with much more complex backports, version and platform sensitivities.

Our users are everywhere, and use everything, and while the bulk of the Rails world does use RSpec, and I acknowledge that, it's also true that the bulk of that world use MRI 1.8 or JRuby.

mipearson

I have no strong preference for rspec other than it's what I'm used to. I hadn't heard of bacon until mentioned today.

Also important, and not mentioned above, is consistency with the main rack repository, which uses bacon as its test framework.

If I get time today I'll rewrite this in bacon. Its format is closer to the original Test::Spec format anyway.

mipearson

Okay. It looks like the most recent gem release of bacon, released four years ago, doesn't support nested contexts which are used heavily in the existing texts. Going by the README, the version in github does.

I'm hesitant to port the tests to depend on a version of bacon that hasn't been released yet.

I'd recommend that either a new version of bacon be released or this PR merged as is.

mipearson

.. also at the risk of taking this off topic, which Ruby implementations does rspec not support? I'm curious now. Rubinius? MacRuby? Embedded implementations?

James Tucker
Owner

Thanks!

James Tucker
Owner

RSpec probably supports most current implementations, but it is very likely it'll drop support for older implementations before we do.

Christian Neukirchen

@mipearson I'll make a new bacon release before the end of the year, ok?

mipearson
Christian Neukirchen

Bacon 1.2 released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.

Showing 34 changed files with 335 additions and 388 deletions. Show diff stats Hide diff stats

  1. +3 5 README.rdoc
  2. +3 21 Rakefile
  3. +1 1  rack-contrib.gemspec
  4. +1 2  test/spec_rack_accept_format.rb
  5. +56 57 test/spec_rack_access.rb
  6. +5 6 test/spec_rack_backstage.rb
  7. +5 6 test/spec_rack_callbacks.rb
  8. +2 3 test/spec_rack_common_cookies.rb
  9. +2 3 test/spec_rack_config.rb
  10. +2 3 test/spec_rack_contrib.rb
  11. +6 7 test/spec_rack_cookies.rb
  12. +8 9 test/spec_rack_csshttprequest.rb
  13. +22 23 test/spec_rack_deflect.rb
  14. +4 5 test/spec_rack_evil.rb
  15. +15 16 test/spec_rack_expectation_cascade.rb
  16. +1 2  test/spec_rack_garbagecollector.rb
  17. +12 13 test/spec_rack_host_meta.rb
  18. +21 22 test/spec_rack_jsonp.rb
  19. +3 4 test/spec_rack_lighttpd_script_name_fix.rb
  20. +9 10 test/spec_rack_locale.rb
  21. +23 24 test/spec_rack_mailexceptions.rb
  22. +6 7 test/spec_rack_nested_params.rb
  23. +3 4 test/spec_rack_not_found.rb
  24. +5 6 test/spec_rack_post_body_content_type_parser.rb
  25. +3 4 test/spec_rack_proctitle.rb
  26. +7 8 test/spec_rack_profiler.rb
  27. +22 23 test/spec_rack_relative_redirect.rb
  28. +39 42 test/spec_rack_response_cache.rb
  29. +2 3 test/spec_rack_response_headers.rb
  30. +1 2  test/spec_rack_runtime.rb
  31. +22 23 test/spec_rack_sendfile.rb
  32. +7 8 test/spec_rack_simple_endpoint.rb
  33. +9 10 test/spec_rack_static_cache.rb
  34. +5 6 test/spec_rack_try_static.rb
8 README.rdoc
Source Rendered
@@ -78,17 +78,15 @@ components included. The following example shows what a simple rackup
78 78
79 79 To contribute to the project, begin by cloning the repo and installing the necessary gems:
80 80
81   - gem install json rack ruby-prof test-spec test-unit
  81 + gem install json rack ruby-prof rspec
82 82
83 83 To run the entire test suite, run
84 84 rake test
85 85
86 86 To run a specific component's tests run
87   - specrb -Ilib:test -w test/spec_rack_thecomponent.rb
  87 + rspec -Ilib:test test/spec_rack_thecomponent.rb
88 88
89   -This works on ruby 1.8.7 but has problems under ruby 1.9.x.
90   -
91   -TODO: instructions for 1.9.x and include bundler
  89 +TODO: include bundler
92 90
93 91 === Links
94 92
24 Rakefile
@@ -2,27 +2,11 @@
2 2 require 'rake/rdoctask'
3 3 require 'rake/testtask'
4 4
5   -desc "Run all the tests"
6   -task :default => [:test]
7   -
8   -desc "Generate RDox"
9   -task "RDOX" do
10   - sh "specrb -Ilib:test -a --rdox >RDOX"
11   -end
12   -
13   -desc "Run specs with test/unit style output"
14   -task :test do
15   - sh "specrb -Ilib:test -w #{ENV['TEST'] || '-a'} #{ENV['TESTOPTS']}"
16   -end
17   -
18   -desc "Run specs with specdoc style output"
19   -task :spec do
20   - sh "specrb -Ilib:test -s -w #{ENV['TEST'] || '-a'} #{ENV['TESTOPTS']}"
21   -end
  5 +task :default => [:spec]
22 6
23 7 desc "Run all the tests"
24   -task :fulltest do
25   - sh "specrb -Ilib:test -w #{ENV['TEST'] || '-a'} #{ENV['TESTOPTS']}"
  8 +task :spec do
  9 + sh "rspec -Ilib:test #{ENV['TEST'] || 'test/spec_*.rb'} #{ENV['TESTOPTS']}"
26 10 end
27 11
28 12 desc "Generate RDoc documentation"
@@ -37,8 +21,6 @@ Rake::RDocTask.new(:rdoc) do |rdoc|
37 21 rdoc.rdoc_files.include('lib/rack/*.rb')
38 22 rdoc.rdoc_files.include('lib/rack/*/*.rb')
39 23 end
40   -task :rdoc => ["RDOX"]
41   -
42 24
43 25 # PACKAGING =================================================================
44 26
2  rack-contrib.gemspec
@@ -98,7 +98,7 @@ Gem::Specification.new do |s|
98 98
99 99 s.extra_rdoc_files = %w[README.rdoc COPYING]
100 100 s.add_dependency 'rack', '>= 0.9.1'
101   - s.add_development_dependency 'test-spec', '>= 0.9.0'
  101 + s.add_development_dependency 'rspec', '>= 2.10.0'
102 102 s.add_development_dependency 'tmail', '>= 1.2'
103 103 s.add_development_dependency 'json', '>= 1.1'
104 104
3  test/spec_rack_accept_format.rb
... ... @@ -1,9 +1,8 @@
1   -require 'test/spec'
2 1 require 'rack/mock'
3 2 require 'rack/contrib/accept_format'
4 3 require 'rack/mime'
5 4
6   -context "Rack::AcceptFormat" do
  5 +describe "Rack::AcceptFormat" do
7 6 app = lambda { |env| [200, {'Content-Type' => 'text/plain'}, env['PATH_INFO']] }
8 7
9 8 specify "should do nothing when a format extension is already provided" do
113 test/spec_rack_access.rb
... ... @@ -1,10 +1,9 @@
1   -require 'test/spec'
2 1 require 'rack/mock'
3 2 require 'rack/contrib/access'
4 3
5   -context "Rack::Access" do
  4 +describe "Rack::Access" do
6 5
7   - setup do
  6 + before do
8 7 @app = lambda { |env| [200, { 'Content-Type' => 'text/plain' }, ['hello']] }
9 8 @mock_addr_1 = '111.111.111.111'
10 9 @mock_addr_2 = '192.168.1.222'
@@ -23,62 +22,62 @@ def middleware(options = {})
23 22 specify "default configuration should deny non-local requests" do
24 23 app = middleware
25 24 status, headers, body = app.call(mock_env(@mock_addr_1))
26   - status.should.equal 403
27   - body.should.equal []
  25 + status.should eq(403)
  26 + body.should eq([])
28 27 end
29 28
30 29 specify "default configuration should allow requests from 127.0.0.1" do
31 30 app = middleware
32 31 status, headers, body = app.call(mock_env(@mock_addr_localhost))
33   - status.should.equal 200
34   - body.should.equal ['hello']
  32 + status.should eq(200)
  33 + body.should eq(['hello'])
35 34 end
36 35
37 36 specify "should allow remote addresses in allow_ipmasking" do
38 37 app = middleware('/' => [@mock_addr_1])
39 38 status, headers, body = app.call(mock_env(@mock_addr_1))
40   - status.should.equal 200
41   - body.should.equal ['hello']
  39 + status.should eq(200)
  40 + body.should eq(['hello'])
42 41 end
43 42
44 43 specify "should deny remote addresses not in allow_ipmasks" do
45 44 app = middleware('/' => [@mock_addr_1])
46 45 status, headers, body = app.call(mock_env(@mock_addr_2))
47   - status.should.equal 403
48   - body.should.equal []
  46 + status.should eq(403)
  47 + body.should eq([])
49 48 end
50 49
51 50 specify "should allow remote addresses in allow_ipmasks range" do
52 51 app = middleware('/' => [@mock_addr_range])
53 52 status, headers, body = app.call(mock_env(@mock_addr_2))
54   - status.should.equal 200
55   - body.should.equal ['hello']
  53 + status.should eq(200)
  54 + body.should eq(['hello'])
56 55 end
57 56
58 57 specify "should deny remote addresses not in allow_ipmasks range" do
59 58 app = middleware('/' => [@mock_addr_range])
60 59 status, headers, body = app.call(mock_env(@mock_addr_1))
61   - status.should.equal 403
62   - body.should.equal []
  60 + status.should eq(403)
  61 + body.should eq([])
63 62 end
64 63
65 64 specify "should allow remote addresses in one of allow_ipmasking" do
66 65 app = middleware('/' => [@mock_addr_range, @mock_addr_localhost])
67 66
68 67 status, headers, body = app.call(mock_env(@mock_addr_2))
69   - status.should.equal 200
70   - body.should.equal ['hello']
  68 + status.should eq(200)
  69 + body.should eq(['hello'])
71 70
72 71 status, headers, body = app.call(mock_env(@mock_addr_localhost))
73   - status.should.equal 200
74   - body.should.equal ['hello']
  72 + status.should eq(200)
  73 + body.should eq(['hello'])
75 74 end
76 75
77 76 specify "should deny remote addresses not in one of allow_ipmasks" do
78 77 app = middleware('/' => [@mock_addr_range, @mock_addr_localhost])
79 78 status, headers, body = app.call(mock_env(@mock_addr_1))
80   - status.should.equal 403
81   - body.should.equal []
  79 + status.should eq(403)
  80 + body.should eq([])
82 81 end
83 82
84 83 specify "handles paths correctly" do
@@ -89,66 +88,66 @@ def middleware(options = {})
89 88 })
90 89
91 90 status, headers, body = app.call(mock_env(@mock_addr_1, "/"))
92   - status.should.equal 200
93   - body.should.equal ['hello']
  91 + status.should eq(200)
  92 + body.should eq(['hello'])
94 93
95 94 status, headers, body = app.call(mock_env(@mock_addr_1, "/qux"))
96   - status.should.equal 200
97   - body.should.equal ['hello']
  95 + status.should eq(200)
  96 + body.should eq(['hello'])
98 97
99 98 status, headers, body = app.call(mock_env(@mock_addr_1, "/foo"))
100   - status.should.equal 403
101   - body.should.equal []
  99 + status.should eq(403)
  100 + body.should eq([])
102 101 status, headers, body = app.call(mock_env(@mock_addr_localhost, "/foo"))
103   - status.should.equal 200
104   - body.should.equal ['hello']
  102 + status.should eq(200)
  103 + body.should eq(['hello'])
105 104
106 105 status, headers, body = app.call(mock_env(@mock_addr_1, "/foo/"))
107   - status.should.equal 403
108   - body.should.equal []
  106 + status.should eq(403)
  107 + body.should eq([])
109 108 status, headers, body = app.call(mock_env(@mock_addr_localhost, "/foo/"))
110   - status.should.equal 200
111   - body.should.equal ['hello']
  109 + status.should eq(200)
  110 + body.should eq(['hello'])
112 111
113 112 status, headers, body = app.call(mock_env(@mock_addr_1, "/foo/bar"))
114   - status.should.equal 403
115   - body.should.equal []
  113 + status.should eq(403)
  114 + body.should eq([])
116 115 status, headers, body = app.call(mock_env(@mock_addr_localhost, "/foo/bar"))
117   - status.should.equal 200
118   - body.should.equal ['hello']
  116 + status.should eq(200)
  117 + body.should eq(['hello'])
119 118 status, headers, body = app.call(mock_env(@mock_addr_2, "/foo/bar"))
120   - status.should.equal 200
121   - body.should.equal ['hello']
  119 + status.should eq(200)
  120 + body.should eq(['hello'])
122 121
123 122 status, headers, body = app.call(mock_env(@mock_addr_1, "/foo/bar/"))
124   - status.should.equal 403
125   - body.should.equal []
  123 + status.should eq(403)
  124 + body.should eq([])
126 125 status, headers, body = app.call(mock_env(@mock_addr_localhost, "/foo/bar/"))
127   - status.should.equal 200
128   - body.should.equal ['hello']
  126 + status.should eq(200)
  127 + body.should eq(['hello'])
129 128
130 129 status, headers, body = app.call(mock_env(@mock_addr_1, "/foo///bar//quux"))
131   - status.should.equal 403
132   - body.should.equal []
  130 + status.should eq(403)
  131 + body.should eq([])
133 132 status, headers, body = app.call(mock_env(@mock_addr_localhost, "/foo///bar//quux"))
134   - status.should.equal 200
135   - body.should.equal ['hello']
  133 + status.should eq(200)
  134 + body.should eq(['hello'])
136 135
137 136 status, headers, body = app.call(mock_env(@mock_addr_1, "/foo/quux"))
138   - status.should.equal 403
139   - body.should.equal []
  137 + status.should eq(403)
  138 + body.should eq([])
140 139 status, headers, body = app.call(mock_env(@mock_addr_localhost, "/foo/quux"))
141   - status.should.equal 200
142   - body.should.equal ['hello']
  140 + status.should eq(200)
  141 + body.should eq(['hello'])
143 142
144 143 status, headers, body = app.call(mock_env(@mock_addr_1, "/bar"))
145   - status.should.equal 200
146   - body.should.equal ['hello']
  144 + status.should eq(200)
  145 + body.should eq(['hello'])
147 146 status, headers, body = app.call(mock_env(@mock_addr_1, "/bar").merge('HTTP_HOST' => 'foo.org'))
148   - status.should.equal 403
149   - body.should.equal []
  147 + status.should eq(403)
  148 + body.should eq([])
150 149 status, headers, body = app.call(mock_env(@mock_addr_localhost, "/bar").merge('HTTP_HOST' => 'foo.org'))
151   - status.should.equal 200
152   - body.should.equal ['hello']
  150 + status.should eq(200)
  151 + body.should eq(['hello'])
153 152 end
154 153 end
11 test/spec_rack_backstage.rb
... ... @@ -1,17 +1,16 @@
1   -require 'test/spec'
2 1 require 'rack/builder'
3 2 require 'rack/mock'
4 3 require 'rack/contrib/backstage'
5 4
6   -context "Rack::Backstage" do
  5 +describe "Rack::Backstage" do
7 6 specify "shows maintenances page if present" do
8 7 app = Rack::Builder.new do
9 8 use Rack::Backstage, 'test/Maintenance.html'
10 9 run lambda { |env| [200, {'Content-Type' => 'text/plain'}, ["Hello, World!"]] }
11 10 end
12 11 response = Rack::MockRequest.new(app).get('/')
13   - response.body.should.equal('Under maintenance.')
14   - response.status.should.equal(503)
  12 + response.body.should eq('Under maintenance.')
  13 + response.status.should eq(503)
15 14 end
16 15
17 16 specify "passes on request if page is not present" do
@@ -20,7 +19,7 @@
20 19 run lambda { |env| [200, {'Content-Type' => 'text/plain'}, ["Hello, World!"]] }
21 20 end
22 21 response = Rack::MockRequest.new(app).get('/')
23   - response.body.should.equal('Hello, World!')
24   - response.status.should.equal(200)
  22 + response.body.should eq('Hello, World!')
  23 + response.status.should eq(200)
25 24 end
26 25 end
11 test/spec_rack_callbacks.rb
... ... @@ -1,4 +1,3 @@
1   -require 'test/spec'
2 1 require 'rack/mock'
3 2
4 3 class Flame
@@ -37,7 +36,7 @@ def call(response)
37 36 end
38 37 end
39 38
40   -context "Rack::Callbacks" do
  39 +describe "Rack::Callbacks" do
41 40 specify "works for love and small stack trace" do
42 41 callback_app = Rack::Callbacks.new do
43 42 before Flame
@@ -55,11 +54,11 @@ def call(response)
55 54
56 55 response = Rack::MockRequest.new(app).get("/")
57 56
58   - response.body.should.equal 'F Lifo..with love'
  57 + response.body.should eq('F Lifo..with love')
59 58
60   - $old_status.should.equal 200
61   - response.status.should.equal 201
  59 + $old_status.should eq(200)
  60 + response.status.should eq(201)
62 61
63   - response.headers['last'].should.equal 'TheEnd'
  62 + response.headers['last'].should eq('TheEnd')
64 63 end
65 64 end
5 test/spec_rack_common_cookies.rb
... ... @@ -1,11 +1,10 @@
1   -require 'test/spec'
2 1 require 'rack/mock'
3 2 require 'rack/builder'
4 3 require 'rack/contrib/common_cookies'
5 4
6   -context Rack::CommonCookies do
  5 +describe Rack::CommonCookies do
7 6
8   - setup do
  7 + before do
9 8 @app = Rack::Builder.new do
10 9 use Rack::CommonCookies
11 10 run lambda {|env| [200, {'Set-Cookie' => env['HTTP_COOKIE']}, []] }
5 test/spec_rack_config.rb
... ... @@ -1,8 +1,7 @@
1   -require 'test/spec'
2 1 require 'rack/mock'
3 2 require 'rack/contrib/config'
4 3
5   -context "Rack::Config" do
  4 +describe "Rack::Config" do
6 5
7 6 specify "should accept a block that modifies the environment" do
8 7 app = Rack::Builder.new do
@@ -16,7 +15,7 @@
16 15 }
17 16 end
18 17 response = Rack::MockRequest.new(app).get('/')
19   - response.body.should.equal('hello')
  18 + response.body.should eq('hello')
20 19 end
21 20
22 21 end
5 test/spec_rack_contrib.rb
... ... @@ -1,8 +1,7 @@
1   -require 'test/spec'
2 1 require 'rack/contrib'
3 2
4   -context "Rack::Contrib" do
  3 +describe "Rack::Contrib" do
5 4 specify "should expose release" do
6   - Rack::Contrib.should.respond_to :release
  5 + Rack::Contrib.should respond_to :release
7 6 end
8 7 end
13 test/spec_rack_cookies.rb
... ... @@ -1,8 +1,7 @@
1   -require 'test/spec'
2 1 require 'rack/mock'
3 2 require 'rack/contrib/cookies'
4 3
5   -context "Rack::Cookies" do
  4 +describe "Rack::Cookies" do
6 5 specify "should be able to read received cookies" do
7 6 app = lambda { |env|
8 7 cookies = env['rack.cookies']
@@ -12,7 +11,7 @@
12 11 app = Rack::Cookies.new(app)
13 12
14 13 response = Rack::MockRequest.new(app).get('/', 'HTTP_COOKIE' => 'foo=bar;quux=h&m')
15   - response.body.should.equal('foo: bar, quux: h&m')
  14 + response.body.should eq('foo: bar, quux: h&m')
16 15 end
17 16
18 17 specify "should be able to set new cookies" do
@@ -25,7 +24,7 @@
25 24 app = Rack::Cookies.new(app)
26 25
27 26 response = Rack::MockRequest.new(app).get('/')
28   - response.headers['Set-Cookie'].should.equal("quux=h%26m; path=/\nfoo=bar; path=/")
  27 + response.headers['Set-Cookie'].should eq("quux=h%26m; path=/\nfoo=bar; path=/")
29 28 end
30 29
31 30 specify "should be able to set cookie with options" do
@@ -37,7 +36,7 @@
37 36 app = Rack::Cookies.new(app)
38 37
39 38 response = Rack::MockRequest.new(app).get('/')
40   - response.headers['Set-Cookie'].should.equal('foo=bar; path=/login; secure')
  39 + response.headers['Set-Cookie'].should eq('foo=bar; path=/login; secure')
41 40 end
42 41
43 42 specify "should be able to delete received cookies" do
@@ -50,7 +49,7 @@
50 49 app = Rack::Cookies.new(app)
51 50
52 51 response = Rack::MockRequest.new(app).get('/', 'HTTP_COOKIE' => 'foo=bar;quux=h&m')
53   - response.body.should.equal('foo: , quux: h&m')
54   - response.headers['Set-Cookie'].should.equal('foo=; path=/; expires=Thu, 01-Jan-1970 00:00:00 GMT')
  52 + response.body.should eq('foo: , quux: h&m')
  53 + response.headers['Set-Cookie'].should eq('foo=; path=/; expires=Thu, 01-Jan-1970 00:00:00 GMT')
55 54 end
56 55 end
17 test/spec_rack_csshttprequest.rb
... ... @@ -1,4 +1,3 @@
1   -require 'test/spec'
2 1 require 'rack/mock'
3 2
4 3 begin
@@ -18,21 +17,21 @@
18 17 PATH_INFO ends with '.chr'" do
19 18 request = Rack::MockRequest.env_for("/blah.chr", :lint => true, :fatal => true)
20 19 Rack::CSSHTTPRequest.new(@app).call(request)
21   - request['csshttprequest.chr'].should.equal true
  20 + request['csshttprequest.chr'].should eq(true)
22 21 end
23 22
24 23 specify "env['csshttprequest.chr'] should be set to true when \
25 24 request parameter _format == 'chr'" do
26 25 request = Rack::MockRequest.env_for("/?_format=chr", :lint => true, :fatal => true)
27 26 Rack::CSSHTTPRequest.new(@app).call(request)
28   - request['csshttprequest.chr'].should.equal true
  27 + request['csshttprequest.chr'].should eq(true)
29 28 end
30 29
31 30 specify "should not change the headers or response when !env['csshttprequest.chr']" do
32 31 request = Rack::MockRequest.env_for("/", :lint => true, :fatal => true)
33 32 status, headers, response = Rack::CSSHTTPRequest.new(@app).call(request)
34   - headers.should.equal @test_headers
35   - response.join.should.equal @test_body
  33 + headers.should eq(@test_headers)
  34 + response.join.should eq(@test_body)
36 35 end
37 36
38 37 context "when env['csshttprequest.chr']" do
@@ -43,20 +42,20 @@
43 42
44 43 specify "should modify the content length to the correct value" do
45 44 headers = Rack::CSSHTTPRequest.new(@app).call(@request)[1]
46   - headers['Content-Length'].should.equal @encoded_body.length.to_s
  45 + headers['Content-Length'].should eq(@encoded_body.length.to_s)
47 46 end
48 47
49 48 specify "should modify the content type to the correct value" do
50 49 headers = Rack::CSSHTTPRequest.new(@app).call(@request)[1]
51   - headers['Content-Type'].should.equal 'text/css'
  50 + headers['Content-Type'].should eq('text/css')
52 51 end
53 52
54 53 specify "should not modify any other headers" do
55 54 headers = Rack::CSSHTTPRequest.new(@app).call(@request)[1]
56   - headers.should.equal @test_headers.merge({
  55 + headers.should eq(@test_headers.merge({
57 56 'Content-Type' => 'text/css',
58 57 'Content-Length' => @encoded_body.length.to_s
59   - })
  58 + }))
60 59 end
61 60 end
62 61
45 test/spec_rack_deflect.rb
... ... @@ -1,10 +1,9 @@
1   -require 'test/spec'
2 1 require 'rack/mock'
3 2 require 'rack/contrib/deflect'
4 3
5   -context "Rack::Deflect" do
  4 +describe "Rack::Deflect" do
6 5
7   - setup do
  6 + before do
8 7 @app = lambda { |env| [200, { 'Content-Type' => 'text/plain' }, ['cookies']] }
9 8 @mock_addr_1 = '111.111.111.111'
10 9 @mock_addr_2 = '222.222.222.222'
@@ -22,8 +21,8 @@ def mock_deflect options = {}
22 21 specify "should allow regular requests to follow through" do
23 22 app = mock_deflect
24 23 status, headers, body = app.call mock_env(@mock_addr_1)
25   - status.should.equal 200
26   - body.should.equal ['cookies']
  24 + status.should eq(200)
  25 + body.should eq(['cookies'])
27 26 end
28 27
29 28 specify "should deflect requests exceeding the request threshold" do
@@ -34,19 +33,19 @@ def mock_deflect options = {}
34 33 # First 5 should be fine
35 34 5.times do
36 35 status, headers, body = app.call env
37   - status.should.equal 200
38   - body.should.equal ['cookies']
  36 + status.should eq(200)
  37 + body.should eq(['cookies'])
39 38 end
40 39
41 40 # Remaining requests should fail for 10 seconds
42 41 10.times do
43 42 status, headers, body = app.call env
44   - status.should.equal 403
45   - body.should.equal []
  43 + status.should eq(403)
  44 + body.should eq([])
46 45 end
47 46
48 47 # Log should reflect that we have blocked an address
49   - log.string.should.match(/^deflect\(\d+\/\d+\/\d+\): blocked 111.111.111.111\n/)
  48 + log.string.should match(/^deflect\(\d+\/\d+\/\d+\): blocked 111.111.111.111\n/)
50 49 end
51 50
52 51 specify "should expire blocking" do
@@ -57,14 +56,14 @@ def mock_deflect options = {}
57 56 # First 5 should be fine
58 57 5.times do
59 58 status, headers, body = app.call env
60   - status.should.equal 200
61   - body.should.equal ['cookies']
  59 + status.should eq(200)
  60 + body.should eq(['cookies'])
62 61 end
63 62
64 63 # Exceeds request threshold
65 64 status, headers, body = app.call env
66   - status.should.equal 403
67   - body.should.equal []
  65 + status.should eq(403)
  66 + body.should eq([])
68 67
69 68 # Allow block to expire
70 69 sleep 3
@@ -72,12 +71,12 @@ def mock_deflect options = {}
72 71 # Another 5 is fine now
73 72 5.times do
74 73 status, headers, body = app.call env
75   - status.should.equal 200
76   - body.should.equal ['cookies']
  74 + status.should eq(200)
  75 + body.should eq(['cookies'])
77 76 end
78 77
79 78 # Log should reflect block and release
80   - log.string.should.match(/deflect.*: blocked 111\.111\.111\.111\ndeflect.*: released 111\.111\.111\.111\n/)
  79 + log.string.should match(/deflect.*: blocked 111\.111\.111\.111\ndeflect.*: released 111\.111\.111\.111\n/)
81 80 end
82 81
83 82 specify "should allow whitelisting of remote addresses" do
@@ -87,8 +86,8 @@ def mock_deflect options = {}
87 86 # Whitelisted addresses are always fine
88 87 10.times do
89 88 status, headers, body = app.call env
90   - status.should.equal 200
91   - body.should.equal ['cookies']
  89 + status.should eq(200)
  90 + body.should eq(['cookies'])
92 91 end
93 92 end
94 93
@@ -96,12 +95,12 @@ def mock_deflect options = {}
96 95 app = mock_deflect :blacklist => [@mock_addr_2]
97 96
98 97 status, headers, body = app.call mock_env(@mock_addr_1)
99   - status.should.equal 200
100   - body.should.equal ['cookies']
  98 + status.should eq(200)
  99 + body.should eq(['cookies'])
101 100
102 101 status, headers, body = app.call mock_env(@mock_addr_2)
103   - status.should.equal 403
104   - body.should.equal []
  102 + status.should eq(403)
  103 + body.should eq([])
105 104 end
106 105
107 106 end
9 test/spec_rack_evil.rb
... ... @@ -1,9 +1,8 @@
1   -require 'test/spec'
2 1 require 'rack/mock'
3 2 require 'rack/contrib/evil'
4 3 require 'erb'
5 4
6   -context "Rack::Evil" do
  5 +describe "Rack::Evil" do
7 6 app = lambda do |env|
8 7 template = ERB.new("<%= throw :response, [404, {'Content-Type' => 'text/html'}, 'Never know where it comes from'] %>")
9 8 [200, {'Content-Type' => 'text/plain'}, template.result(binding)]
@@ -12,8 +11,8 @@
12 11 specify "should enable the app to return the response from anywhere" do
13 12 status, headers, body = Rack::Evil.new(app).call({})
14 13
15   - status.should.equal 404
16   - headers['Content-Type'].should.equal 'text/html'
17   - body.should.equal 'Never know where it comes from'
  14 + status.should eq(404)
  15 + headers['Content-Type'].should eq('text/html')
  16 + body.should eq('Never know where it comes from')
18 17 end
19 18 end
31 test/spec_rack_expectation_cascade.rb
... ... @@ -1,22 +1,21 @@
1   -require 'test/spec'
2 1 require 'rack/mock'
3 2 require 'rack/contrib/expectation_cascade'
4 3
5   -context "Rack::ExpectationCascade" do
  4 +describe "Rack::ExpectationCascade" do
6 5 specify "with no apps returns a 404 if no expectation header was set" do
7 6 app = Rack::ExpectationCascade.new
8 7 env = {}
9 8 response = app.call(env)
10   - response[0].should.equal 404
11   - env.should.equal({})
  9 + response[0].should eq(404)
  10 + env.should eq({})
12 11 end
13 12
14 13 specify "with no apps returns a 417 if expectation header was set" do
15 14 app = Rack::ExpectationCascade.new
16 15 env = {"Expect" => "100-continue"}
17 16 response = app.call(env)
18   - response[0].should.equal 417
19   - env.should.equal({"Expect" => "100-continue"})
  17 + response[0].should eq(417)
  18 + env.should eq({"Expect" => "100-continue"})
20 19 end
21 20
22 21 specify "returns first successful response" do
@@ -25,8 +24,8 @@
25 24 cascade << lambda { |env| [200, {"Content-Type" => "text/plain"}, ["OK"]] }
26 25 end
27 26 response = app.call({})
28   - response[0].should.equal 200
29   - response[2][0].should.equal "OK"
  27 + response[0].should eq(200)
  28 + response[2][0].should eq("OK")
30 29 end
31 30
32 31 specify "expectation is set if it has not been already" do
@@ -34,8 +33,8 @@
34 33 cascade << lambda { |env| [200, {"Content-Type" => "text/plain"}, ["Expect: #{env["Expect"]}"]] }
35 34 end
36 35 response = app.call({})
37   - response[0].should.equal 200
38   - response[2][0].should.equal "Expect: 100-continue"
  36 + response[0].should eq(200)
  37 + response[2][0].should eq("Expect: 100-continue")
39 38 end
40 39
41 40 specify "returns a 404 if no apps where matched and no expectation header was set" do
@@ -43,8 +42,8 @@
43 42 cascade << lambda { |env| [417, {"Content-Type" => "text/plain"}, []] }
44 43 end
45 44 response = app.call({})
46   - response[0].should.equal 404
47   - response[2][0].should.equal nil
  45 + response[0].should eq(404)
  46 + response[2][0].should eq(nil)
48 47 end
49 48
50 49 specify "returns a 417 if no apps where matched and a expectation header was set" do
@@ -52,8 +51,8 @@
52 51 cascade << lambda { |env| [417, {"Content-Type" => "text/plain"}, []] }
53 52 end
54 53 response = app.call({"Expect" => "100-continue"})
55   - response[0].should.equal 417
56   - response[2][0].should.equal nil
  54 + response[0].should eq(417)
  55 + response[2][0].should eq(nil)
57 56 end
58 57
59 58 specify "nests expectation cascades" do
@@ -66,7 +65,7 @@
66 65 end
67 66 end
68 67 response = app.call({})
69   - response[0].should.equal 200
70   - response[2][0].should.equal "OK"
  68 + response[0].should eq(200)
  69 + response[2][0].should eq("OK")
71 70 end
72 71 end
3  test/spec_rack_garbagecollector.rb
... ... @@ -1,8 +1,7 @@
1   -require 'test/spec'
2 1 require 'rack/mock'
3 2 require 'rack/contrib/garbagecollector'
4 3
5   -context 'Rack::GarbageCollector' do
  4 +describe 'Rack::GarbageCollector' do
6 5
7 6 specify 'starts the garbage collector after each request' do
8 7 app = lambda { |env|
25 test/spec_rack_host_meta.rb
... ... @@ -1,11 +1,10 @@
1   -require 'test/spec'
2 1 require 'rack/mock'
3 2 require 'rack/contrib/host_meta'
4 3 require 'rack/contrib/not_found'
5 4
6   -context "Rack::HostMeta" do
  5 +describe "Rack::HostMeta" do
7 6
8   - setup do
  7 + before do
9 8 app = Rack::Builder.new do
10 9 use Rack::Lint
11 10 use Rack::ContentLength
@@ -20,31 +19,31 @@
20 19 end
21 20
22 21 specify "should respond to /host-meta" do
23   - @response.status.should.equal 200
  22 + @response.status.should eq(200)
24 23 end
25 24
26 25 specify "should respond with the correct media type" do
27   - @response['Content-Type'].should.equal 'application/host-meta'
  26 + @response['Content-Type'].should eq('application/host-meta')
28 27 end
29 28
30 29 specify "should include a Link entry for each Link item in the config block" do
31   - @response.body.should.match(/Link:\s*<\/robots.txt>;.*\n/)
32   - @response.body.should.match(/Link:\s*<\/w3c\/p3p.xml>;.*/)
  30 + @response.body.should match(/Link:\s*<\/robots.txt>;.*\n/)
  31 + @response.body.should match(/Link:\s*<\/w3c\/p3p.xml>;.*/)
33 32 end
34 33
35 34 specify "should include a Link-Pattern entry for each Link-Pattern item in the config" do
36   - @response.body.should.match(/Link-Pattern:\s*<\{uri\};json_schema>;.*/)
  35 + @response.body.should match(/Link-Pattern:\s*<\{uri\};json_schema>;.*/)
37 36 end
38 37
39 38 specify "should include a rel attribute for each Link or Link-Pattern entry where specified" do
40   - @response.body.should.match(/rel="robots"/)
41   - @response.body.should.match(/rel="privacy"/)
42   - @response.body.should.match(/rel="describedby"/)
  39 + @response.body.should match(/rel="robots"/)
  40 + @response.body.should match(/rel="privacy"/)
  41 + @response.body.should match(/rel="describedby"/)
43 42 end
44 43
45 44 specify "should include a type attribute for each Link or Link-Pattern entry where specified" do
46   - @response.body.should.match(/Link:\s*<\/w3c\/p3p.xml>;.*type.*application\/p3p.xml/)
47   - @response.body.should.match(/Link-Pattern:\s*<\{uri\};json_schema>;.*type.*application\/x-schema\+json/)
  45 + @response.body.should match(/Link:\s*<\/w3c\/p3p.xml>;.*type.*application\/p3p.xml/)
  46 + @response.body.should match(/Link-Pattern:\s*<\{uri\};json_schema>;.*type.*application\/x-schema\+json/)
48 47 end
49 48
50 49 end
43 test/spec_rack_jsonp.rb
... ... @@ -1,8 +1,7 @@
1   -require 'test/spec'
2 1 require 'rack/mock'
3 2 require 'rack/contrib/jsonp'
4 3
5   -context "Rack::JSONP" do
  4 +describe "Rack::JSONP" do
6 5
7 6 context "when a callback parameter is provided" do
8 7 specify "should wrap the response body in the Javascript callback if JSON" do
@@ -11,7 +10,7 @@
11 10 app = lambda { |env| [200, {'Content-Type' => 'application/json'}, [test_body]] }
12 11 request = Rack::MockRequest.env_for("/", :params => "foo=bar&callback=#{callback}")
13 12 body = Rack::JSONP.new(app).call(request).last
14   - body.should.equal ["#{callback}(#{test_body})"]
  13 + body.should eq(["#{callback}(#{test_body})"])
15 14 end
16 15
17 16 specify "should not wrap the response body in a callback if body is not JSON" do
@@ -20,7 +19,7 @@
20 19 app = lambda { |env| [200, {'Content-Type' => 'text/plain'}, [test_body]] }
21 20 request = Rack::MockRequest.env_for("/", :params => "foo=bar&callback=#{callback}")
22 21 body = Rack::JSONP.new(app).call(request).last
23   - body.should.equal ['{"bar":"foo"}']
  22 + body.should eq(['{"bar":"foo"}'])
24 23 end
25 24
26 25 specify "should update content length if it was set" do
@@ -31,7 +30,7 @@
31 30
32 31 headers = Rack::JSONP.new(app).call(request)[1]
33 32 expected_length = test_body.length + callback.length + "()".length
34   - headers['Content-Length'].should.equal(expected_length.to_s)
  33 + headers['Content-Length'].should eq(expected_length.to_s)
35 34 end
36 35
37 36 specify "should not touch content length if not set" do
@@ -40,7 +39,7 @@
40 39 app = lambda { |env| [200, {'Content-Type' => 'application/json'}, [test_body]] }
41 40 request = Rack::MockRequest.env_for("/", :params => "foo=bar&callback=#{callback}")
42 41 headers = Rack::JSONP.new(app).call(request)[1]
43   - headers['Content-Length'].should.equal nil
  42 + headers['Content-Length'].should eq(nil)
44 43 end
45 44
46 45 specify "should modify the content type to application/javascript" do
@@ -49,7 +48,7 @@
49 48 app = lambda { |env| [200, {'Content-Type' => 'application/json'}, [test_body]] }
50 49 request = Rack::MockRequest.env_for("/", :params => "foo=bar&callback=#{callback}")
51 50 headers = Rack::JSONP.new(app).call(request)[1]
52   - headers['Content-Type'].should.equal('application/javascript')
  51 + headers['Content-Type'].should eq('application/javascript')
53 52 end
54 53
55 54 specify "should not allow literal U+2028 or U+2029" do
@@ -63,9 +62,9 @@
63 62 request = Rack::MockRequest.env_for("/", :params => "foo=bar&callback=#{callback}")
64 63 body = Rack::JSONP.new(app).call(request).last
65 64 unless "\u2028" == 'u2028'
66   - body.join.should.not.match(/\u2028|\u2029/)
  65 + body.join.should_not match(/\u2028|\u2029/)
67 66 else
68   - body.join.should.not.match(/\342\200\250|\342\200\251/)
  67 + body.join.should_not match(/\342\200\250|\342\200\251/)
69 68 end
70 69 end
71 70
@@ -76,7 +75,7 @@
76 75 app = lambda { |env| [200, {'Content-Type' => 'application/json'}, [test_body]] }
77 76 request = Rack::MockRequest.env_for("/", :params => "foo=bar&callback=#{callback}")
78 77 body = Rack::JSONP.new(app).call(request).last
79   - body.should.equal ['{"bar":"foo"}']
  78 + body.should eq(['{"bar":"foo"}'])
80 79 end
81 80 end
82 81
@@ -89,7 +88,7 @@
89 88 app = lambda { |env| [200, {'Content-Type' => content_type}, [test_body]] }
90 89 request = Rack::MockRequest.env_for("/", :params => "foo=bar&callback=#{callback}")
91 90 body = Rack::JSONP.new(app).call(request).last
92   - body.should.equal ['Bad Request']
  91 + body.should eq(['Bad Request'])
93 92 end
94 93
95 94 specify 'should return set the response code to 400' do
@@ -99,7 +98,7 @@
99 98 app = lambda { |env| [200, {'Content-Type' => content_type}, [test_body]] }
100 99 request = Rack::MockRequest.env_for("/", :params => "foo=bar&callback=#{callback}")
101 100 response_code = Rack::JSONP.new(app).call(request).first
102   - response_code.should.equal 400
  101 + response_code.should eq(400)
103 102 end
104 103 end
105 104
@@ -111,7 +110,7 @@
111 110 app = lambda { |env| [200, {'Content-Type' => content_type}, [test_body]] }
112 111 request = Rack::MockRequest.env_for("/", :params => "foo=bar&callback=#{callback}")
113 112 body = Rack::JSONP.new(app).call(request).last
114   - body.should.equal ['Good Request']
  113 + body.should eq(['Good Request'])
115 114 end
116 115
117 116 specify 'should not change the response code from 200' do
@@ -121,7 +120,7 @@
121 120 app = lambda { |env| [200, {'Content-Type' => content_type}, [test_body]] }
122 121 request = Rack::MockRequest.env_for("/", :params => "foo=bar&callback=#{callback}")
123 122 response_code = Rack::JSONP.new(app).call(request).first
124   - response_code.should.equal 200
  123 + response_code.should eq(200)
125 124 end
126 125 end
127 126 end
@@ -134,10 +133,10 @@ def request(callback, body = '{"bar":"foo"}')
134 133 end
135 134
136 135 def assert_bad_request(response)
137   - response.should.not.equal nil
  136 + response.should_not be_nil
138 137 status, headers, body = response
139   - status.should.equal 400
140   - body.should.equal ["Bad Request"]
  138 + status.should eq(400)
  139 + body.should eq(["Bad Request"])
141 140 end
142 141
143 142 specify "should return bad request for callback with invalid characters" do
@@ -154,8 +153,8 @@ def assert_bad_request(response)
154 153
155 154 specify "should not return a bad request for callbacks with dots in the callback" do
156 155 status, headers, body = request(callback = "foo.bar.baz", test_body = '{"foo":"bar"}')
157   - status.should.equal 200
158   - body.should.equal ["#{callback}(#{test_body})"]
  156 + status.should eq(200)
  157 + body.should eq(["#{callback}(#{test_body})"])
159 158 end
160 159 end
161 160
@@ -166,7 +165,7 @@ def assert_bad_request(response)
166 165 app = lambda { |env| [200, {'Content-Type' => 'application/json'}, test_body] }
167 166 request = Rack::MockRequest.env_for("/", :params => "foo=bar")
168 167 body = Rack::JSONP.new(app).call(request).last
169   - body.should.equal test_body
  168 + body.should eq(test_body)
170 169 end
171 170
172 171 specify "should not change anything if it's not a json response" do
@@ -174,7 +173,7 @@ def assert_bad_request(response)
174 173 app = lambda { |env| [404, {'Content-Type' => 'text/html'}, [test_body]] }
175 174 request = Rack::MockRequest.env_for("/", :params => "callback=foo", 'HTTP_ACCEPT' => 'application/json')
176 175 body = Rack::JSONP.new(app).call(request).last
177   - body.should.equal [test_body]
  176 + body.should eq([test_body])
178 177 end
179 178
180 179 specify "should not change anything if there is no Content-Type header" do
@@ -182,7 +181,7 @@ def assert_bad_request(response)
182 181 app = lambda { |env| [404, {}, [test_body]] }
183 182 request = Rack::MockRequest.env_for("/", :params => "callback=foo", 'HTTP_ACCEPT' => 'application/json')
184 183 body = Rack::JSONP.new(app).call(request).last
185   - body.should.equal [test_body]
  184 + body.should eq([test_body])
186 185 end
187 186
188 187 end
7 test/spec_rack_lighttpd_script_name_fix.rb
... ... @@ -1,8 +1,7 @@
1   -require 'test/spec'
2 1 require 'rack/mock'
3 2 require 'rack/contrib/lighttpd_script_name_fix'
4 3
5   -context "Rack::LighttpdScriptNameFix" do
  4 +describe "Rack::LighttpdScriptNameFix" do
6 5 specify "corrects SCRIPT_NAME and PATH_INFO set by lighttpd " do
7 6 env = {
8 7 "PATH_INFO" => "/foo/bar/baz",
@@ -10,7 +9,7 @@
10 9 }
11 10 app = lambda { |_| [200, {'Content-Type' => 'text/plain'}, ["Hello, World!"]] }
12 11 response = Rack::LighttpdScriptNameFix.new(app).call(env)
13   - env['SCRIPT_NAME'].should.be.empty
14   - env['PATH_INFO'].should.equal '/hello/foo/bar/baz'
  12 + env['SCRIPT_NAME'].should be_empty
  13 + env['PATH_INFO'].should eq('/hello/foo/bar/baz')
15 14 end
16 15 end
19 test/spec_rack_locale.rb
... ... @@ -1,9 +1,8 @@
1   -require 'test/spec'
2 1 require 'rack/mock'
3 2
4   -context "Rack::Locale" do
  3 +describe "Rack::Locale" do
5 4
6   - setup do
  5 + before do
7 6 begin
8 7 require 'rack/contrib/locale'
9 8 rescue LoadError
@@ -24,34 +23,34 @@ def response_with_languages(accept_languages)
24 23
25 24 specify 'should use I18n.default_locale if no languages are requested' do
26 25 I18n.default_locale = :zh
27   - response_with_languages(nil).body.should.equal('zh')
  26 + response_with_languages(nil).body.should eq('zh')
28 27 end
29 28
30 29 specify 'should treat an empty qvalue as 1.0' do
31   - response_with_languages('en,es;q=0.95').body.should.equal('en')
  30 + response_with_languages('en,es;q=0.95').body.should eq('en')
32 31 end
33 32
34 33 specify 'should set the Content-Language response header' do
35 34 headers = response_with_languages('de;q=0.7,dk;q=0.9').headers
36   - headers['Content-Language'].should.equal('dk')
  35 + headers['Content-Language'].should eq('dk')
37 36 end
38 37
39 38 specify 'should pick the language with the highest qvalue' do
40   - response_with_languages('en;q=0.9,es;q=0.95').body.should.equal('es')
  39 + response_with_languages('en;q=0.9,es;q=0.95').body.should eq('es')
41 40 end
42 41
43 42 specify 'should retain full language codes' do
44   - response_with_languages('en-gb,en-us;q=0.95;en').body.should.equal('en-gb')
  43 + response_with_languages('en-gb,en-us;q=0.95;en').body.should eq('en-gb')
45 44 end
46 45
47 46 specify 'should treat a * as "all other languages"' do
48   - response_with_languages('*,en;q=0.5').body.should.equal( I18n.default_locale.to_s )
  47 + response_with_languages('*,en;q=0.5').body.should eq(I18n.default_locale.to_s )
49 48 end
50 49
51 50 specify 'should reset the I18n locale after the response' do
52 51 I18n.locale = 'es'
53 52 response_with_languages('en,de;q=0.8')
54   - I18n.locale.should.equal(:es)
  53 + I18n.locale.should eq(:es)
55 54 end
56 55
57 56 end
47 test/spec_rack_mailexceptions.rb
... ... @@ -1,4 +1,3 @@
1   -require 'test/spec'
2 1 require 'rack/mock'
3 2
4 3 begin
@@ -14,9 +13,9 @@ def test_exception
14 13 return boom
15 14 end
16 15
17   - context 'Rack::MailExceptions' do
  16 + describe 'Rack::MailExceptions' do
18 17
19   - setup do
  18 + before do
20 19 @app = lambda { |env| raise TestError, 'Why, I say' }
21 20 @env = Rack::MockRequest.env_for("/foo",
22 21 'FOO' => 'BAR',
@@ -43,7 +42,7 @@ def test_exception
43 42 mail.subject '[ERROR] %s'
44 43 mail.smtp @smtp_settings
45 44 end
46   - called.should.be == true
  45 + called.should == true
47 46 end
48 47
49 48 specify 'generates a TMail object with configured settings' do
@@ -56,12 +55,12 @@ def test_exception
56 55 end
57 56
58 57 mail = mailer.send(:generate_mail, test_exception, @env)
59   - mail.to.should.equal ['foo@example.org']
60   - mail.from.should.equal ['bar@example.org']
61   - mail.subject.should.equal '[ERROR] Suffering Succotash!'
62   - mail.body.should.not.be.nil
63   - mail.body.should.be =~ /FOO:\s+"BAR"/
64   - mail.body.should.be =~ /^\s*THE BODY\s*$/
  58 + mail.to.should eq(['foo@example.org'])
  59 + mail.from.should eq(['bar@example.org'])
  60 + mail.subject.should eq('[ERROR] Suffering Succotash!')
  61 + mail.body.should_not be_nil
  62 + mail.body.should =~ /FOO:\s+"BAR"/
  63 + mail.body.should =~ /^\s*THE BODY\s*$/
65 64 end
66 65
67 66 specify 'catches exceptions raised from app, sends mail, and re-raises' do
@@ -72,8 +71,8 @@ def test_exception
72 71 mail.subject '[ERROR] %s'
73 72 mail.smtp @smtp_settings
74 73 end
75   - lambda { mailer.call(@env) }.should.raise(TestError)
76   - @env['mail.sent'].should.be == true
  74 + lambda { mailer.call(@env) }.should raise_exception(TestError)
  75 + @env['mail.sent'].should == true
77 76 end
78 77
79 78 if TEST_SMTP && ! TEST_SMTP.empty?
@@ -82,15 +81,15 @@ def test_exception
82 81 Rack::MailExceptions.new(@app) do |mail|
83 82 mail.config.merge! TEST_SMTP