rspec-rails 2.0.0.beta.18 → 2.0.0.beta.19
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -1
- data/Rakefile +2 -2
- data/VERSION +1 -1
- data/features/controller_specs/anonymous_controller.feature +40 -0
- data/lib/rspec/rails/example/controller_example_group.rb +48 -0
- data/lib/rspec/rails/extensions/active_record/base.rb +3 -5
- data/lib/rspec/rails/fixture_support.rb +24 -22
- data/lib/rspec/rails/mocks.rb +1 -1
- data/rspec-rails.gemspec +12 -11
- metadata +17 -14
data/Gemfile
CHANGED
data/Rakefile
CHANGED
@@ -43,8 +43,8 @@ begin
|
|
43
43
|
gem.homepage = "http://github.com/rspec/rspec-rails"
|
44
44
|
gem.authors = ["David Chelimsky", "Chad Humphries"]
|
45
45
|
gem.rubyforge_project = "rspec"
|
46
|
-
gem.add_dependency "rspec",
|
47
|
-
gem.add_dependency "webrat", ">= 0.7.
|
46
|
+
gem.add_dependency "rspec", RSpec::Rails::Version::STRING
|
47
|
+
gem.add_dependency "webrat", ">= 0.7.2.beta.1"
|
48
48
|
gem.post_install_message = <<-EOM
|
49
49
|
#{"*"*50}
|
50
50
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0.0.beta.
|
1
|
+
2.0.0.beta.19
|
@@ -0,0 +1,40 @@
|
|
1
|
+
Feature: anonymous controller
|
2
|
+
|
3
|
+
As a Rails developer using RSpec
|
4
|
+
In order to specify behaviour of ApplicationController
|
5
|
+
I want a simple DSL for generating anonymous subclasses
|
6
|
+
|
7
|
+
Scenario: specify error handling in ApplicationController
|
8
|
+
Given a file named "spec/controllers/application_controller_spec.rb" with:
|
9
|
+
"""
|
10
|
+
require "spec_helper"
|
11
|
+
|
12
|
+
class ApplicationController < ActionController::Base
|
13
|
+
class AccessDenied < StandardError; end
|
14
|
+
|
15
|
+
rescue_from AccessDenied, :with => :access_denied
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def access_denied
|
20
|
+
redirect_to "/401.html"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe ApplicationController do
|
25
|
+
controller do
|
26
|
+
def index
|
27
|
+
raise ApplicationController::AccessDenied
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "handling AccessDenied exceptions" do
|
32
|
+
it "redirects to the /401.html page" do
|
33
|
+
get :index
|
34
|
+
response.should redirect_to("/401.html")
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
"""
|
39
|
+
When I run "rspec spec"
|
40
|
+
Then the output should contain "1 example, 0 failures"
|
@@ -89,6 +89,54 @@ module RSpec::Rails
|
|
89
89
|
def controller_class
|
90
90
|
describes
|
91
91
|
end
|
92
|
+
|
93
|
+
# Creates an anonymous subclass of ApplicationController and evals the
|
94
|
+
# +body+ in that context. Also sets up implicit routes for this
|
95
|
+
# controller, that are separate from those defined in
|
96
|
+
# <tt>config/routes.rb</tt>.
|
97
|
+
#
|
98
|
+
# Supports a simple DSL for specifying behaviour of ApplicationController.
|
99
|
+
#
|
100
|
+
# == Example
|
101
|
+
#
|
102
|
+
# describe ApplicationController do
|
103
|
+
# controller do
|
104
|
+
# def index
|
105
|
+
# raise ApplicationController::AccessDenied
|
106
|
+
# end
|
107
|
+
# end
|
108
|
+
|
109
|
+
# describe "handling AccessDenied exceptions" do
|
110
|
+
# it "redirects to the /401.html page" do
|
111
|
+
# get :index
|
112
|
+
# response.should redirect_to("/401.html")
|
113
|
+
# end
|
114
|
+
# end
|
115
|
+
# end
|
116
|
+
#
|
117
|
+
# NOTICE: Due to Ruby 1.8 scoping rules in anoymous subclasses, constants
|
118
|
+
# defined in +ApplicationController+ must be fully qualified (e.g.
|
119
|
+
# ApplicationController::AccessDenied) in the block passed to the
|
120
|
+
# +controller+ method. Any instance methods, filters, etc, that are
|
121
|
+
# defined in +ApplicationController+, however, are accessible from within
|
122
|
+
# the block.
|
123
|
+
def controller(&body)
|
124
|
+
metadata[:example_group][:describes] = Class.new(ApplicationController, &body)
|
125
|
+
metadata[:example_group][:describes].singleton_class.class_eval do
|
126
|
+
def name
|
127
|
+
"StubResourcesController"
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
before do
|
132
|
+
@orig_routes, @routes = @routes, ActionDispatch::Routing::RouteSet.new
|
133
|
+
@routes.draw { resources :stub_resources }
|
134
|
+
end
|
135
|
+
|
136
|
+
after do
|
137
|
+
@routes = @orig_routes
|
138
|
+
end
|
139
|
+
end
|
92
140
|
end
|
93
141
|
|
94
142
|
module InstanceMethods
|
@@ -36,11 +36,9 @@ if defined?(ActiveRecord::Base)
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
include RSpec::Rails::Extensions::ActiveRecord::InstanceMethods
|
43
|
-
end
|
39
|
+
class ActiveRecord::Base #:nodoc:
|
40
|
+
extend RSpec::Rails::Extensions::ActiveRecord::ClassMethods
|
41
|
+
include RSpec::Rails::Extensions::ActiveRecord::InstanceMethods
|
44
42
|
end
|
45
43
|
end
|
46
44
|
|
@@ -1,31 +1,33 @@
|
|
1
|
-
|
2
|
-
module
|
3
|
-
module
|
4
|
-
|
1
|
+
if defined?(ActiveRecord)
|
2
|
+
module RSpec
|
3
|
+
module Rails
|
4
|
+
module FixtureSupport
|
5
|
+
extend ActiveSupport::Concern
|
5
6
|
|
6
|
-
|
7
|
-
|
7
|
+
include RSpec::Rails::SetupAndTeardownAdapter
|
8
|
+
include RSpec::Rails::TestUnitAssertionAdapter
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
included do
|
11
|
+
if RSpec.configuration.use_transactional_fixtures
|
12
|
+
# TODO - figure out how to move this outside the included block
|
13
|
+
include ActiveRecord::TestFixtures
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
self.fixture_path = RSpec.configuration.fixture_path
|
16
|
+
self.use_transactional_fixtures = RSpec.configuration.use_transactional_fixtures
|
17
|
+
self.use_instantiated_fixtures = RSpec.configuration.use_instantiated_fixtures
|
18
|
+
fixtures RSpec.configuration.global_fixtures if RSpec.configuration.global_fixtures
|
19
|
+
end
|
18
20
|
end
|
19
21
|
end
|
20
22
|
end
|
21
23
|
end
|
22
|
-
end
|
23
24
|
|
24
|
-
RSpec.configure do |c|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
25
|
+
RSpec.configure do |c|
|
26
|
+
c.include RSpec::Rails::FixtureSupport
|
27
|
+
c.add_setting :use_transactional_fixtures
|
28
|
+
c.add_setting :use_transactional_examples, :alias => :use_transactional_fixtures
|
29
|
+
c.add_setting :use_instantiated_fixtures
|
30
|
+
c.add_setting :global_fixtures
|
31
|
+
c.add_setting :fixture_path
|
32
|
+
end
|
31
33
|
end
|
data/lib/rspec/rails/mocks.rb
CHANGED
data/rspec-rails.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{rspec-rails}
|
8
|
-
s.version = "2.0.0.beta.
|
8
|
+
s.version = "2.0.0.beta.19"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["David Chelimsky", "Chad Humphries"]
|
12
|
-
s.date = %q{2010-07-
|
12
|
+
s.date = %q{2010-07-25}
|
13
13
|
s.description = %q{RSpec-2 for Rails-3}
|
14
14
|
s.email = %q{dchelimsky@gmail.com;chad.humphries@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -26,6 +26,7 @@ Gem::Specification.new do |s|
|
|
26
26
|
"autotest/discover.rb",
|
27
27
|
"cucumber.yml",
|
28
28
|
"features/README.markdown",
|
29
|
+
"features/controller_specs/anonymous_controller.feature",
|
29
30
|
"features/controller_specs/isolation_from_views.feature",
|
30
31
|
"features/controller_specs/readers.feature",
|
31
32
|
"features/controller_specs/render_views.feature",
|
@@ -122,7 +123,7 @@ Gem::Specification.new do |s|
|
|
122
123
|
s.homepage = %q{http://github.com/rspec/rspec-rails}
|
123
124
|
s.post_install_message = %q{**************************************************
|
124
125
|
|
125
|
-
Thank you for installing rspec-rails-2.0.0.beta.
|
126
|
+
Thank you for installing rspec-rails-2.0.0.beta.19!
|
126
127
|
|
127
128
|
This version of rspec-rails only works with versions of rails >= 3.0.0.beta.4.
|
128
129
|
|
@@ -132,7 +133,7 @@ Gem::Specification.new do |s|
|
|
132
133
|
can access its generators and rake tasks.
|
133
134
|
|
134
135
|
group :development, :test do
|
135
|
-
gem "rspec-rails", ">= 2.0.0.beta.
|
136
|
+
gem "rspec-rails", ">= 2.0.0.beta.19"
|
136
137
|
end
|
137
138
|
|
138
139
|
Be sure to run the following command in each of your Rails apps if you're
|
@@ -158,7 +159,7 @@ Gem::Specification.new do |s|
|
|
158
159
|
s.require_paths = ["lib"]
|
159
160
|
s.rubyforge_project = %q{rspec}
|
160
161
|
s.rubygems_version = %q{1.3.7}
|
161
|
-
s.summary = %q{rspec-rails-2.0.0.beta.
|
162
|
+
s.summary = %q{rspec-rails-2.0.0.beta.19}
|
162
163
|
s.test_files = [
|
163
164
|
"spec/rspec/rails/example/controller_example_group_spec.rb",
|
164
165
|
"spec/rspec/rails/example/helper_example_group_spec.rb",
|
@@ -185,15 +186,15 @@ Gem::Specification.new do |s|
|
|
185
186
|
s.specification_version = 3
|
186
187
|
|
187
188
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
188
|
-
s.add_runtime_dependency(%q<rspec>, ["
|
189
|
-
s.add_runtime_dependency(%q<webrat>, [">= 0.7.
|
189
|
+
s.add_runtime_dependency(%q<rspec>, ["= 2.0.0.beta.19"])
|
190
|
+
s.add_runtime_dependency(%q<webrat>, [">= 0.7.2.beta.1"])
|
190
191
|
else
|
191
|
-
s.add_dependency(%q<rspec>, ["
|
192
|
-
s.add_dependency(%q<webrat>, [">= 0.7.
|
192
|
+
s.add_dependency(%q<rspec>, ["= 2.0.0.beta.19"])
|
193
|
+
s.add_dependency(%q<webrat>, [">= 0.7.2.beta.1"])
|
193
194
|
end
|
194
195
|
else
|
195
|
-
s.add_dependency(%q<rspec>, ["
|
196
|
-
s.add_dependency(%q<webrat>, [">= 0.7.
|
196
|
+
s.add_dependency(%q<rspec>, ["= 2.0.0.beta.19"])
|
197
|
+
s.add_dependency(%q<webrat>, [">= 0.7.2.beta.1"])
|
197
198
|
end
|
198
199
|
end
|
199
200
|
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 62196421
|
5
5
|
prerelease: true
|
6
6
|
segments:
|
7
7
|
- 2
|
8
8
|
- 0
|
9
9
|
- 0
|
10
10
|
- beta
|
11
|
-
-
|
12
|
-
version: 2.0.0.beta.
|
11
|
+
- 19
|
12
|
+
version: 2.0.0.beta.19
|
13
13
|
platform: ruby
|
14
14
|
authors:
|
15
15
|
- David Chelimsky
|
@@ -18,7 +18,7 @@ autorequire:
|
|
18
18
|
bindir: bin
|
19
19
|
cert_chain: []
|
20
20
|
|
21
|
-
date: 2010-07-
|
21
|
+
date: 2010-07-25 00:00:00 -05:00
|
22
22
|
default_executable:
|
23
23
|
dependencies:
|
24
24
|
- !ruby/object:Gem::Dependency
|
@@ -28,16 +28,16 @@ dependencies:
|
|
28
28
|
version_requirements: &id001 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
hash:
|
33
|
+
hash: 62196421
|
34
34
|
segments:
|
35
35
|
- 2
|
36
36
|
- 0
|
37
37
|
- 0
|
38
38
|
- beta
|
39
|
-
-
|
40
|
-
version: 2.0.0.beta.
|
39
|
+
- 19
|
40
|
+
version: 2.0.0.beta.19
|
41
41
|
requirement: *id001
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
type: :runtime
|
@@ -48,12 +48,14 @@ dependencies:
|
|
48
48
|
requirements:
|
49
49
|
- - ">="
|
50
50
|
- !ruby/object:Gem::Version
|
51
|
-
hash:
|
51
|
+
hash: 62196417
|
52
52
|
segments:
|
53
53
|
- 0
|
54
54
|
- 7
|
55
|
-
-
|
56
|
-
|
55
|
+
- 2
|
56
|
+
- beta
|
57
|
+
- 1
|
58
|
+
version: 0.7.2.beta.1
|
57
59
|
requirement: *id002
|
58
60
|
description: RSpec-2 for Rails-3
|
59
61
|
email: dchelimsky@gmail.com;chad.humphries@gmail.com
|
@@ -74,6 +76,7 @@ files:
|
|
74
76
|
- autotest/discover.rb
|
75
77
|
- cucumber.yml
|
76
78
|
- features/README.markdown
|
79
|
+
- features/controller_specs/anonymous_controller.feature
|
77
80
|
- features/controller_specs/isolation_from_views.feature
|
78
81
|
- features/controller_specs/readers.feature
|
79
82
|
- features/controller_specs/render_views.feature
|
@@ -173,7 +176,7 @@ licenses: []
|
|
173
176
|
post_install_message: |
|
174
177
|
**************************************************
|
175
178
|
|
176
|
-
Thank you for installing rspec-rails-2.0.0.beta.
|
179
|
+
Thank you for installing rspec-rails-2.0.0.beta.19!
|
177
180
|
|
178
181
|
This version of rspec-rails only works with versions of rails >= 3.0.0.beta.4.
|
179
182
|
|
@@ -183,7 +186,7 @@ post_install_message: |
|
|
183
186
|
can access its generators and rake tasks.
|
184
187
|
|
185
188
|
group :development, :test do
|
186
|
-
gem "rspec-rails", ">= 2.0.0.beta.
|
189
|
+
gem "rspec-rails", ">= 2.0.0.beta.19"
|
187
190
|
end
|
188
191
|
|
189
192
|
Be sure to run the following command in each of your Rails apps if you're
|
@@ -235,7 +238,7 @@ rubyforge_project: rspec
|
|
235
238
|
rubygems_version: 1.3.7
|
236
239
|
signing_key:
|
237
240
|
specification_version: 3
|
238
|
-
summary: rspec-rails-2.0.0.beta.
|
241
|
+
summary: rspec-rails-2.0.0.beta.19
|
239
242
|
test_files:
|
240
243
|
- spec/rspec/rails/example/controller_example_group_spec.rb
|
241
244
|
- spec/rspec/rails/example/helper_example_group_spec.rb
|