rspec-rails 2.0.0.beta.8 → 2.0.0.beta.9.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +82 -27
- data/Rakefile +7 -7
- data/Upgrade.markdown +12 -0
- data/VERSION +1 -1
- data/autotest/discover.rb +1 -0
- data/cucumber.yml +3 -0
- data/example_app_template.rb +2 -2
- data/features/controller_specs/do_not_render_views.feature +61 -0
- data/features/controller_specs/readers.feature +18 -0
- data/features/controller_specs/render_views.feature +53 -0
- data/features/model_specs/errors_on.feature +32 -0
- data/features/model_specs/transactional_examples.feature +2 -2
- data/features/view_specs/view_spec.feature +102 -1
- data/lib/autotest/rails_rspec2.rb +1 -1
- data/lib/generators/rspec/helper/helper_generator.rb +1 -0
- data/lib/generators/rspec/helper/templates/helper_spec.rb +3 -3
- data/lib/generators/rspec/install/install_generator.rb +7 -7
- data/lib/generators/rspec/scaffold/scaffold_generator.rb +10 -1
- data/lib/generators/rspec/scaffold/templates/edit_spec.rb +1 -1
- data/lib/generators/rspec/scaffold/templates/index_spec.rb +1 -1
- data/lib/generators/rspec/scaffold/templates/new_spec.rb +1 -1
- data/lib/generators/rspec/scaffold/templates/show_spec.rb +2 -2
- data/lib/rspec-rails.rb +12 -0
- data/lib/rspec/rails.rb +8 -0
- data/lib/rspec/rails/adapters.rb +12 -8
- data/lib/rspec/rails/example.rb +1 -0
- data/lib/rspec/rails/example/controller_example_group.rb +13 -12
- data/lib/rspec/rails/example/helper_example_group.rb +43 -0
- data/lib/rspec/rails/example/mailer_example_group.rb +10 -5
- data/lib/rspec/rails/example/request_example_group.rb +7 -7
- data/lib/rspec/rails/example/view_example_group.rb +44 -62
- data/lib/rspec/rails/extensions.rb +1 -0
- data/lib/rspec/rails/extensions/active_record/base.rb +46 -0
- data/lib/rspec/rails/matchers.rb +28 -3
- data/lib/rspec/rails/mocks.rb +3 -3
- data/lib/rspec/rails/monkey.rb +1 -0
- data/lib/rspec/rails/monkey/action_controller/test_case.rb +153 -145
- data/lib/rspec/rails/monkey/action_view/test_case.rb +201 -0
- data/lib/rspec/rails/null_resolver.rb +10 -0
- data/lib/{generators/rspec/install/templates/lib → rspec/rails}/tasks/rspec.rake +4 -5
- data/lib/rspec/rails/transactional_database_support.rb +4 -6
- data/lib/rspec/rails/version.rb +1 -1
- data/lib/rspec/rails/view_assigns.rb +28 -0
- data/lib/rspec/rails/view_rendering.rb +33 -0
- data/rspec-rails.gemspec +41 -11
- data/spec/rspec/rails/example/controller_example_group_spec.rb +11 -0
- data/spec/rspec/rails/example/helper_example_group_spec.rb +20 -0
- data/spec/rspec/rails/example/mailer_example_group_spec.rb +11 -0
- data/spec/rspec/rails/example/request_example_group_spec.rb +11 -0
- data/spec/rspec/rails/example/view_example_group_spec.rb +75 -0
- data/spec/rspec/rails/example/view_rendering_spec.rb +68 -0
- data/spec/rspec/rails/matchers/errors_on_spec.rb +38 -0
- data/spec/rspec/rails/mocks/ar_classes.rb +1 -1
- data/spec/rspec/rails/mocks/mock_model_spec.rb +88 -65
- data/spec/rspec/rails/mocks/stub_model_spec.rb +1 -1
- data/spec/rspec/rails/transactional_database_support_spec.rb +2 -2
- data/spec/spec_helper.rb +18 -2
- data/spec/support/helpers.rb +20 -0
- data/specs.watchr +10 -10
- data/templates/generate_stuff.rb +3 -1
- metadata +40 -9
@@ -42,7 +42,7 @@ describe "stub_model" do
|
|
42
42
|
lambda do
|
43
43
|
model = stub_model(MockableModel, :changed => true, :attributes_with_quotes => {'this' => 'that'})
|
44
44
|
model.save
|
45
|
-
end.should raise_error(
|
45
|
+
end.should raise_error(RSpec::Rails::IllegalDataAccessException, /stubbed models are not allowed to access the database/)
|
46
46
|
end
|
47
47
|
|
48
48
|
it "should increment the id" do
|
@@ -1,11 +1,11 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe RSpec::Rails::TransactionalDatabaseSupport do
|
4
4
|
|
5
5
|
let(:connection) { double('connection', :open_transactions => 1) }
|
6
6
|
let(:test_bed) do
|
7
7
|
Class.new do
|
8
|
-
include
|
8
|
+
include RSpec::Rails::TransactionalDatabaseSupport
|
9
9
|
def active_record_configured?; true; end
|
10
10
|
end.new
|
11
11
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -3,11 +3,27 @@ Bundler.setup
|
|
3
3
|
|
4
4
|
require 'rspec/rails'
|
5
5
|
|
6
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
7
|
+
|
8
|
+
# TODO - most of this is borrowed from rspec-core's spec_helper - should
|
9
|
+
# be extracted to something we can use here
|
6
10
|
def in_editor?
|
7
11
|
ENV.has_key?('TM_MODE') || ENV.has_key?('EMACS') || ENV.has_key?('VIM')
|
8
12
|
end
|
9
13
|
|
10
|
-
|
11
|
-
|
14
|
+
class RSpec::Core::ExampleGroup
|
15
|
+
def self.run_all(reporter=nil)
|
16
|
+
run(reporter || RSpec::Mocks::Mock.new('reporter').as_null_object)
|
17
|
+
end
|
12
18
|
end
|
13
19
|
|
20
|
+
RSpec.configure do |c|
|
21
|
+
c.color_enabled = !in_editor?
|
22
|
+
c.before(:each) do
|
23
|
+
@real_world = RSpec.world
|
24
|
+
RSpec.instance_variable_set(:@world, RSpec::Core::World.new)
|
25
|
+
end
|
26
|
+
c.after(:each) do
|
27
|
+
RSpec.instance_variable_set(:@world, @real_world)
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Helpers
|
2
|
+
def stub_metadata(additional_metadata)
|
3
|
+
stub_metadata = metadata_with(additional_metadata)
|
4
|
+
RSpec::Core::ExampleGroup.stub(:metadata) { stub_metadata }
|
5
|
+
end
|
6
|
+
|
7
|
+
def metadata_with(additional_metadata)
|
8
|
+
m = RSpec::Core::Metadata.new
|
9
|
+
m.process("example group")
|
10
|
+
|
11
|
+
group_metadata = additional_metadata.delete(:example_group)
|
12
|
+
if group_metadata
|
13
|
+
m[:example_group].merge!(group_metadata)
|
14
|
+
end
|
15
|
+
m.merge!(additional_metadata)
|
16
|
+
m
|
17
|
+
end
|
18
|
+
|
19
|
+
RSpec.configure {|c| c.include self}
|
20
|
+
end
|
data/specs.watchr
CHANGED
@@ -5,12 +5,12 @@
|
|
5
5
|
# --------------------------------------------------
|
6
6
|
# Convenience Methods
|
7
7
|
# --------------------------------------------------
|
8
|
-
def
|
8
|
+
def all_spec_files
|
9
9
|
Dir['spec/**/*_spec.rb']
|
10
10
|
end
|
11
11
|
|
12
|
-
def
|
13
|
-
matches =
|
12
|
+
def run_spec_matching(thing_to_match)
|
13
|
+
matches = all_spec_files.grep(/#{thing_to_match}/i)
|
14
14
|
if matches.empty?
|
15
15
|
puts "Sorry, thanks for playing, but there were no matches for #{thing_to_match}"
|
16
16
|
else
|
@@ -24,17 +24,17 @@ def run(files_to_run)
|
|
24
24
|
no_int_for_you
|
25
25
|
end
|
26
26
|
|
27
|
-
def
|
28
|
-
run(
|
27
|
+
def run_all_specs
|
28
|
+
run(all_spec_files.join(' '))
|
29
29
|
end
|
30
30
|
|
31
31
|
# --------------------------------------------------
|
32
32
|
# Watchr Rules
|
33
33
|
# --------------------------------------------------
|
34
|
-
watch('^spec/(.*)_spec\.rb') { |m|
|
35
|
-
watch('^lib/(.*)\.rb') { |m|
|
36
|
-
watch('^spec/spec_helper\.rb') {
|
37
|
-
watch('^spec/support/.*\.rb') {
|
34
|
+
watch('^spec/(.*)_spec\.rb') { |m| run_spec_matching(m[1]) }
|
35
|
+
watch('^lib/(.*)\.rb') { |m| run_spec_matching(m[1]) }
|
36
|
+
watch('^spec/spec_helper\.rb') { run_all_specs }
|
37
|
+
watch('^spec/support/.*\.rb') { run_all_specs }
|
38
38
|
|
39
39
|
# --------------------------------------------------
|
40
40
|
# Signal Handling
|
@@ -52,7 +52,7 @@ Signal.trap 'INT' do
|
|
52
52
|
puts " Did you just send me an INT? Ugh. I'll quit for real if you do it again."
|
53
53
|
@sent_an_int = true
|
54
54
|
Kernel.sleep 1.5
|
55
|
-
|
55
|
+
run_all_specs
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
data/templates/generate_stuff.rb
CHANGED
@@ -3,8 +3,10 @@ generate('controller wombats index')
|
|
3
3
|
generate('integration_test widgets')
|
4
4
|
generate('mailer Notifications signup')
|
5
5
|
generate('model thing name:string')
|
6
|
-
generate('
|
6
|
+
generate('helper things')
|
7
7
|
generate('scaffold widget name:string')
|
8
|
+
generate('observer widget')
|
9
|
+
generate('scaffold gadget ') # scaffold with no attributes
|
8
10
|
|
9
11
|
run('rake db:migrate')
|
10
12
|
run('rake db:test:prepare')
|
metadata
CHANGED
@@ -7,8 +7,9 @@ version: !ruby/object:Gem::Version
|
|
7
7
|
- 0
|
8
8
|
- 0
|
9
9
|
- beta
|
10
|
-
-
|
11
|
-
|
10
|
+
- 9
|
11
|
+
- 1
|
12
|
+
version: 2.0.0.beta.9.1
|
12
13
|
platform: ruby
|
13
14
|
authors:
|
14
15
|
- David Chelimsky
|
@@ -17,7 +18,7 @@ autorequire:
|
|
17
18
|
bindir: bin
|
18
19
|
cert_chain: []
|
19
20
|
|
20
|
-
date: 2010-
|
21
|
+
date: 2010-05-27 00:00:00 -05:00
|
21
22
|
default_executable:
|
22
23
|
dependencies:
|
23
24
|
- !ruby/object:Gem::Dependency
|
@@ -32,8 +33,8 @@ dependencies:
|
|
32
33
|
- 0
|
33
34
|
- 0
|
34
35
|
- beta
|
35
|
-
-
|
36
|
-
version: 2.0.0.beta.
|
36
|
+
- 9
|
37
|
+
version: 2.0.0.beta.9
|
37
38
|
type: :runtime
|
38
39
|
version_requirements: *id001
|
39
40
|
- !ruby/object:Gem::Dependency
|
@@ -50,7 +51,7 @@ dependencies:
|
|
50
51
|
version: 0.7.0
|
51
52
|
type: :runtime
|
52
53
|
version_requirements: *id002
|
53
|
-
description:
|
54
|
+
description: RSpec-2 for Rails-3
|
54
55
|
email: dchelimsky@gmail.com;chad.humphries@gmail.com
|
55
56
|
executables: []
|
56
57
|
|
@@ -63,9 +64,16 @@ files:
|
|
63
64
|
- Gemfile
|
64
65
|
- README.markdown
|
65
66
|
- Rakefile
|
67
|
+
- Upgrade.markdown
|
66
68
|
- VERSION
|
69
|
+
- autotest/discover.rb
|
70
|
+
- cucumber.yml
|
67
71
|
- example_app_template.rb
|
72
|
+
- features/controller_specs/do_not_render_views.feature
|
73
|
+
- features/controller_specs/readers.feature
|
74
|
+
- features/controller_specs/render_views.feature
|
68
75
|
- features/matchers/new_record_matcher.feature
|
76
|
+
- features/model_specs/errors_on.feature
|
69
77
|
- features/model_specs/transactional_examples.feature
|
70
78
|
- features/step_definitions/model_steps.rb
|
71
79
|
- features/support/env.rb
|
@@ -80,7 +88,6 @@ files:
|
|
80
88
|
- lib/generators/rspec/install/install_generator.rb
|
81
89
|
- lib/generators/rspec/install/templates/autotest/discover.rb
|
82
90
|
- lib/generators/rspec/install/templates/config/initializers/rspec_generator.rb.tt
|
83
|
-
- lib/generators/rspec/install/templates/lib/tasks/rspec.rake
|
84
91
|
- lib/generators/rspec/install/templates/spec/spec_helper.rb
|
85
92
|
- lib/generators/rspec/integration/integration_generator.rb
|
86
93
|
- lib/generators/rspec/integration/templates/request_spec.rb
|
@@ -106,18 +113,33 @@ files:
|
|
106
113
|
- lib/rspec/rails/adapters.rb
|
107
114
|
- lib/rspec/rails/example.rb
|
108
115
|
- lib/rspec/rails/example/controller_example_group.rb
|
116
|
+
- lib/rspec/rails/example/helper_example_group.rb
|
109
117
|
- lib/rspec/rails/example/mailer_example_group.rb
|
110
118
|
- lib/rspec/rails/example/request_example_group.rb
|
111
119
|
- lib/rspec/rails/example/view_example_group.rb
|
120
|
+
- lib/rspec/rails/extensions.rb
|
121
|
+
- lib/rspec/rails/extensions/active_record/base.rb
|
112
122
|
- lib/rspec/rails/matchers.rb
|
113
123
|
- lib/rspec/rails/mocks.rb
|
114
124
|
- lib/rspec/rails/monkey.rb
|
115
125
|
- lib/rspec/rails/monkey/action_controller/test_case.rb
|
126
|
+
- lib/rspec/rails/monkey/action_view/test_case.rb
|
116
127
|
- lib/rspec/rails/monkey/active_support/notifications/fanout.rb
|
128
|
+
- lib/rspec/rails/null_resolver.rb
|
129
|
+
- lib/rspec/rails/tasks/rspec.rake
|
117
130
|
- lib/rspec/rails/transactional_database_support.rb
|
118
131
|
- lib/rspec/rails/version.rb
|
132
|
+
- lib/rspec/rails/view_assigns.rb
|
133
|
+
- lib/rspec/rails/view_rendering.rb
|
119
134
|
- rspec-rails.gemspec
|
135
|
+
- spec/rspec/rails/example/controller_example_group_spec.rb
|
136
|
+
- spec/rspec/rails/example/helper_example_group_spec.rb
|
137
|
+
- spec/rspec/rails/example/mailer_example_group_spec.rb
|
138
|
+
- spec/rspec/rails/example/request_example_group_spec.rb
|
139
|
+
- spec/rspec/rails/example/view_example_group_spec.rb
|
140
|
+
- spec/rspec/rails/example/view_rendering_spec.rb
|
120
141
|
- spec/rspec/rails/matchers/be_a_new_spec.rb
|
142
|
+
- spec/rspec/rails/matchers/errors_on_spec.rb
|
121
143
|
- spec/rspec/rails/matchers/redirect_to_spec.rb
|
122
144
|
- spec/rspec/rails/matchers/render_template_spec.rb
|
123
145
|
- spec/rspec/rails/mocks/ar_classes.rb
|
@@ -125,6 +147,7 @@ files:
|
|
125
147
|
- spec/rspec/rails/mocks/stub_model_spec.rb
|
126
148
|
- spec/rspec/rails/transactional_database_support_spec.rb
|
127
149
|
- spec/spec_helper.rb
|
150
|
+
- spec/support/helpers.rb
|
128
151
|
- specs.watchr
|
129
152
|
- templates/generate_stuff.rb
|
130
153
|
- templates/run_specs.rb
|
@@ -135,7 +158,7 @@ licenses: []
|
|
135
158
|
post_install_message: |
|
136
159
|
**************************************************
|
137
160
|
|
138
|
-
Thank you for installing rspec-rails-2.0.0.beta.
|
161
|
+
Thank you for installing rspec-rails-2.0.0.beta.9.1!
|
139
162
|
|
140
163
|
This version of rspec-rails only works with
|
141
164
|
versions of rails >= 3.0.0.pre.
|
@@ -172,9 +195,16 @@ rubyforge_project: rspec
|
|
172
195
|
rubygems_version: 1.3.6
|
173
196
|
signing_key:
|
174
197
|
specification_version: 3
|
175
|
-
summary: rspec-rails-2.0.0.beta.
|
198
|
+
summary: rspec-rails-2.0.0.beta.9.1
|
176
199
|
test_files:
|
200
|
+
- spec/rspec/rails/example/controller_example_group_spec.rb
|
201
|
+
- spec/rspec/rails/example/helper_example_group_spec.rb
|
202
|
+
- spec/rspec/rails/example/mailer_example_group_spec.rb
|
203
|
+
- spec/rspec/rails/example/request_example_group_spec.rb
|
204
|
+
- spec/rspec/rails/example/view_example_group_spec.rb
|
205
|
+
- spec/rspec/rails/example/view_rendering_spec.rb
|
177
206
|
- spec/rspec/rails/matchers/be_a_new_spec.rb
|
207
|
+
- spec/rspec/rails/matchers/errors_on_spec.rb
|
178
208
|
- spec/rspec/rails/matchers/redirect_to_spec.rb
|
179
209
|
- spec/rspec/rails/matchers/render_template_spec.rb
|
180
210
|
- spec/rspec/rails/mocks/ar_classes.rb
|
@@ -182,3 +212,4 @@ test_files:
|
|
182
212
|
- spec/rspec/rails/mocks/stub_model_spec.rb
|
183
213
|
- spec/rspec/rails/transactional_database_support_spec.rb
|
184
214
|
- spec/spec_helper.rb
|
215
|
+
- spec/support/helpers.rb
|