rspec-rails 2.7.0 → 2.8.0.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/generators/rspec/install/templates/spec/spec_helper.rb +0 -1
- data/lib/generators/rspec/scaffold/scaffold_generator.rb +9 -10
- data/lib/rspec/rails/fixture_support.rb +1 -2
- data/lib/rspec/rails/version.rb +1 -1
- data/lib/rspec/rails/view_rendering.rb +13 -5
- data/spec/generators/rspec/scaffold/scaffold_generator_spec.rb +34 -40
- data/spec/rspec/rails/matchers/relation_match_array_spec.rb +2 -1
- data/spec/spec_helper.rb +5 -4
- metadata +20 -14
@@ -16,7 +16,6 @@ RSpec.configure do |config|
|
|
16
16
|
# config.mock_with :mocha
|
17
17
|
# config.mock_with :flexmock
|
18
18
|
# config.mock_with :rr
|
19
|
-
config.mock_with :rspec
|
20
19
|
|
21
20
|
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
22
21
|
config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
@@ -67,20 +67,19 @@ module Rspec
|
|
67
67
|
|
68
68
|
# support for namespaced-resources
|
69
69
|
def ns_file_name
|
70
|
-
|
71
|
-
"#{$1.underscore}_#{$2.singularize.underscore}"
|
72
|
-
else
|
73
|
-
file_name
|
74
|
-
end
|
70
|
+
ns_parts.empty? ? file_name : "#{ns_parts[0].underscore}_#{ns_parts[1].singularize.underscore}"
|
75
71
|
end
|
76
72
|
|
77
73
|
# support for namespaced-resources
|
78
74
|
def ns_table_name
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
75
|
+
ns_parts.empty? ? table_name : "#{ns_parts[0].underscore}/#{ns_parts[1].tableize}"
|
76
|
+
end
|
77
|
+
|
78
|
+
def ns_parts
|
79
|
+
@ns_parts ||= begin
|
80
|
+
matches = ARGV[0].to_s.match(/\A(\w+)\/(\w+)/)
|
81
|
+
matches ? [matches[1], matches[2]] : []
|
82
|
+
end
|
84
83
|
end
|
85
84
|
|
86
85
|
# Returns the name of the mock. For example, if the file name is user,
|
@@ -29,8 +29,7 @@ module RSpec
|
|
29
29
|
|
30
30
|
RSpec.configure do |c|
|
31
31
|
c.include RSpec::Rails::FixtureSupport
|
32
|
-
c.add_setting :use_transactional_fixtures
|
33
|
-
c.add_setting :use_transactional_examples, :alias => :use_transactional_fixtures
|
32
|
+
c.add_setting :use_transactional_fixtures, :alias_with => :use_transactional_examples
|
34
33
|
c.add_setting :use_instantiated_fixtures
|
35
34
|
c.add_setting :global_fixtures
|
36
35
|
c.add_setting :fixture_path
|
data/lib/rspec/rails/version.rb
CHANGED
@@ -1,16 +1,24 @@
|
|
1
1
|
require 'action_view/testing/resolvers'
|
2
2
|
|
3
3
|
RSpec.configure do |config|
|
4
|
-
|
4
|
+
# This allows us to expose `render_views` as a config option even though it
|
5
|
+
# breaks the convention of other options by using `render_views` as a
|
6
|
+
# command (i.e. render_views = true), where it would normally be used as a
|
7
|
+
# getter. This makes it easier for rspec-rails users because we use
|
8
|
+
# `render_views` directly in example groups, so this aligns the two APIs,
|
9
|
+
# but requires this workaround:
|
10
|
+
config.add_setting :rendering_views, :default => false
|
11
|
+
|
12
|
+
def config.render_views=(val)
|
13
|
+
self.rendering_views = val
|
14
|
+
end
|
5
15
|
|
6
|
-
# TODO - rspec-core needs a way to define a setting that works like this in
|
7
|
-
# one go
|
8
16
|
def config.render_views
|
9
|
-
|
17
|
+
self.rendering_views = true
|
10
18
|
end
|
11
19
|
|
12
20
|
def config.render_views?
|
13
|
-
|
21
|
+
rendering_views
|
14
22
|
end
|
15
23
|
end
|
16
24
|
|
@@ -1,40 +1,36 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
# Generators are not automatically loaded by Rails
|
4
3
|
require 'generators/rspec/scaffold/scaffold_generator'
|
5
4
|
|
6
5
|
describe Rspec::Generators::ScaffoldGenerator do
|
7
|
-
# Tell the generator where to put its output (what it thinks of as Rails.root)
|
8
6
|
destination File.expand_path("../../../../../tmp", __FILE__)
|
9
7
|
|
10
8
|
before { prepare_destination }
|
11
9
|
|
12
|
-
describe 'controller
|
10
|
+
describe 'standard controller spec' do
|
13
11
|
subject { file('spec/controllers/posts_controller_spec.rb') }
|
14
|
-
describe 'generated by default' do
|
15
|
-
before do
|
16
|
-
run_generator %w(posts)
|
17
|
-
end
|
18
12
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
end
|
13
|
+
describe 'with no options' do
|
14
|
+
before { run_generator %w(posts) }
|
15
|
+
it { should contain /require 'spec_helper'/ }
|
16
|
+
it { should contain /describe PostsController/ }
|
24
17
|
end
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
end
|
18
|
+
|
19
|
+
describe 'with --no-controller_specs' do
|
20
|
+
before { run_generator %w(posts --no-controller_specs) }
|
29
21
|
it { should_not exist }
|
30
22
|
end
|
31
23
|
end
|
32
24
|
|
25
|
+
describe 'namespaced controller spec' do
|
26
|
+
subject { file('spec/controllers/admin/posts_controller_spec.rb') }
|
27
|
+
before { run_generator %w(admin/posts) }
|
28
|
+
it { should contain /describe Admin::PostsController/ }
|
29
|
+
end
|
30
|
+
|
33
31
|
describe 'view specs' do
|
34
|
-
describe '
|
35
|
-
before
|
36
|
-
run_generator %w(posts)
|
37
|
-
end
|
32
|
+
describe 'with no options' do
|
33
|
+
before { run_generator %w(posts) }
|
38
34
|
describe 'edit' do
|
39
35
|
subject { file("spec/views/posts/edit.html.erb_spec.rb") }
|
40
36
|
it { should exist }
|
@@ -42,6 +38,7 @@ describe Rspec::Generators::ScaffoldGenerator do
|
|
42
38
|
it { should contain /describe "(.*)\/edit.html.erb"/ }
|
43
39
|
it { should contain /it "renders the edit (.*) form"/ }
|
44
40
|
end
|
41
|
+
|
45
42
|
describe 'index' do
|
46
43
|
subject { file("spec/views/posts/index.html.erb_spec.rb") }
|
47
44
|
it { should exist }
|
@@ -49,6 +46,7 @@ describe Rspec::Generators::ScaffoldGenerator do
|
|
49
46
|
it { should contain /describe "(.*)\/index.html.erb"/ }
|
50
47
|
it { should contain /it "renders a list of (.*)"/ }
|
51
48
|
end
|
49
|
+
|
52
50
|
describe 'new' do
|
53
51
|
subject { file("spec/views/posts/new.html.erb_spec.rb") }
|
54
52
|
it { should exist }
|
@@ -56,6 +54,7 @@ describe Rspec::Generators::ScaffoldGenerator do
|
|
56
54
|
it { should contain /describe "(.*)\/new.html.erb"/ }
|
57
55
|
it { should contain /it "renders new (.*) form"/ }
|
58
56
|
end
|
57
|
+
|
59
58
|
describe 'show' do
|
60
59
|
subject { file("spec/views/posts/show.html.erb_spec.rb") }
|
61
60
|
it { should exist }
|
@@ -65,22 +64,24 @@ describe Rspec::Generators::ScaffoldGenerator do
|
|
65
64
|
end
|
66
65
|
end
|
67
66
|
|
68
|
-
describe '
|
69
|
-
before
|
70
|
-
|
71
|
-
end
|
67
|
+
describe 'with --no-view-specs' do
|
68
|
+
before { run_generator %w(posts --no-view-specs) }
|
69
|
+
|
72
70
|
describe 'edit' do
|
73
71
|
subject { file("spec/views/posts/edit.html.erb_spec.rb") }
|
74
72
|
it { should_not exist }
|
75
73
|
end
|
74
|
+
|
76
75
|
describe 'index' do
|
77
76
|
subject { file("spec/views/posts/index.html.erb_spec.rb") }
|
78
77
|
it { should_not exist }
|
79
78
|
end
|
79
|
+
|
80
80
|
describe 'new' do
|
81
81
|
subject { file("spec/views/posts/new.html.erb_spec.rb") }
|
82
82
|
it { should_not exist }
|
83
83
|
end
|
84
|
+
|
84
85
|
describe 'show' do
|
85
86
|
subject { file("spec/views/posts/show.html.erb_spec.rb") }
|
86
87
|
it { should_not exist }
|
@@ -88,26 +89,19 @@ describe Rspec::Generators::ScaffoldGenerator do
|
|
88
89
|
end
|
89
90
|
end
|
90
91
|
|
91
|
-
describe 'routing
|
92
|
+
describe 'routing spec' do
|
92
93
|
subject { file('spec/routing/posts_routing_spec.rb') }
|
93
|
-
describe 'generated by default' do
|
94
|
-
before do
|
95
|
-
run_generator %w(posts)
|
96
|
-
end
|
97
94
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
end
|
95
|
+
describe 'with default options' do
|
96
|
+
before { run_generator %w(posts) }
|
97
|
+
it { should contain /require "spec_helper"/ }
|
98
|
+
it { should contain /describe PostsController/ }
|
99
|
+
it { should contain /describe "routing"/ }
|
104
100
|
end
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
end
|
101
|
+
|
102
|
+
describe 'with --no-routing-specs' do
|
103
|
+
before { run_generator %w(posts --no-routing_specs) }
|
109
104
|
it { should_not exist }
|
110
105
|
end
|
111
106
|
end
|
112
|
-
|
113
107
|
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe "ActiveSupport::Relation =~ matcher" do
|
4
|
+
before { MockableModel.delete_all }
|
5
|
+
|
4
6
|
let!(:models) { Array.new(3) { MockableModel.create } }
|
5
7
|
|
6
8
|
it "verifies that the scope returns the records on the right hand side, regardless of order" do
|
@@ -9,7 +11,6 @@ describe "ActiveSupport::Relation =~ matcher" do
|
|
9
11
|
|
10
12
|
it "fails if the scope encompasses more records than on the right hand side" do
|
11
13
|
another_model = MockableModel.create
|
12
|
-
|
13
14
|
MockableModel.scoped.should_not =~ models.reverse
|
14
15
|
end
|
15
16
|
|
data/spec/spec_helper.rb
CHANGED
@@ -16,12 +16,13 @@ class RSpec::Core::ExampleGroup
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
RSpec.configure do |
|
20
|
-
|
19
|
+
RSpec.configure do |config|
|
20
|
+
config.before(:each) do
|
21
21
|
@real_world = RSpec.world
|
22
22
|
RSpec.instance_variable_set(:@world, RSpec::Core::World.new)
|
23
23
|
end
|
24
|
-
|
24
|
+
config.after(:each) do
|
25
25
|
RSpec.instance_variable_set(:@world, @real_world)
|
26
26
|
end
|
27
|
-
|
27
|
+
config.order = :random
|
28
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 15424215
|
5
|
+
prerelease: 6
|
6
6
|
segments:
|
7
7
|
- 2
|
8
|
-
-
|
8
|
+
- 8
|
9
9
|
- 0
|
10
|
-
|
10
|
+
- rc
|
11
|
+
- 1
|
12
|
+
version: 2.8.0.rc1
|
11
13
|
platform: ruby
|
12
14
|
authors:
|
13
15
|
- David Chelimsky
|
@@ -15,7 +17,7 @@ autorequire:
|
|
15
17
|
bindir: bin
|
16
18
|
cert_chain: []
|
17
19
|
|
18
|
-
date: 2011-
|
20
|
+
date: 2011-11-06 00:00:00 Z
|
19
21
|
dependencies:
|
20
22
|
- !ruby/object:Gem::Dependency
|
21
23
|
version_requirements: &id001 !ruby/object:Gem::Requirement
|
@@ -66,14 +68,16 @@ dependencies:
|
|
66
68
|
version_requirements: &id004 !ruby/object:Gem::Requirement
|
67
69
|
none: false
|
68
70
|
requirements:
|
69
|
-
- -
|
71
|
+
- - "="
|
70
72
|
- !ruby/object:Gem::Version
|
71
|
-
hash:
|
73
|
+
hash: 15424215
|
72
74
|
segments:
|
73
75
|
- 2
|
74
|
-
-
|
76
|
+
- 8
|
75
77
|
- 0
|
76
|
-
|
78
|
+
- rc
|
79
|
+
- 1
|
80
|
+
version: 2.8.0.rc1
|
77
81
|
requirement: *id004
|
78
82
|
type: :runtime
|
79
83
|
prerelease: false
|
@@ -243,19 +247,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
243
247
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
244
248
|
none: false
|
245
249
|
requirements:
|
246
|
-
- - "
|
250
|
+
- - ">"
|
247
251
|
- !ruby/object:Gem::Version
|
248
|
-
hash:
|
252
|
+
hash: 25
|
249
253
|
segments:
|
250
|
-
-
|
251
|
-
|
254
|
+
- 1
|
255
|
+
- 3
|
256
|
+
- 1
|
257
|
+
version: 1.3.1
|
252
258
|
requirements: []
|
253
259
|
|
254
260
|
rubyforge_project: rspec
|
255
261
|
rubygems_version: 1.8.11
|
256
262
|
signing_key:
|
257
263
|
specification_version: 3
|
258
|
-
summary: rspec-rails-2.
|
264
|
+
summary: rspec-rails-2.8.0.rc1
|
259
265
|
test_files:
|
260
266
|
- features/Autotest.md
|
261
267
|
- features/Generators.md
|