rspec-rails 3.0.0.beta1 → 3.0.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/Changelog.md +46 -0
- data/README.md +19 -17
- data/features/Generators.md +1 -0
- data/features/README.md +7 -15
- data/features/controller_specs/anonymous_controller.feature +222 -164
- data/lib/generators/rspec/feature/feature_generator.rb +15 -0
- data/lib/generators/rspec/feature/templates/feature_spec.rb +5 -0
- data/lib/generators/rspec/install/templates/spec/spec_helper.rb.tt +0 -6
- data/lib/generators/rspec/integration/integration_generator.rb +0 -11
- data/lib/generators/rspec/integration/templates/request_spec.rb +0 -5
- data/lib/generators/rspec/model/templates/fixtures.yml +1 -1
- data/lib/generators/rspec/scaffold/scaffold_generator.rb +0 -8
- data/lib/generators/rspec/scaffold/templates/controller_spec.rb +4 -4
- data/lib/generators/rspec/scaffold/templates/edit_spec.rb +0 -9
- data/lib/generators/rspec/scaffold/templates/index_spec.rb +0 -7
- data/lib/generators/rspec/scaffold/templates/new_spec.rb +0 -9
- data/lib/generators/rspec/scaffold/templates/show_spec.rb +0 -7
- data/lib/rspec/rails.rb +1 -1
- data/lib/rspec/rails/adapters.rb +18 -15
- data/lib/rspec/rails/example/controller_example_group.rb +18 -9
- data/lib/rspec/rails/example/view_example_group.rb +3 -0
- data/lib/rspec/rails/matchers/be_a_new.rb +1 -1
- data/lib/rspec/rails/matchers/be_new_record.rb +2 -2
- data/lib/rspec/rails/matchers/be_valid.rb +10 -3
- data/lib/rspec/rails/matchers/have_rendered.rb +2 -2
- data/lib/rspec/rails/matchers/redirect_to.rb +2 -2
- data/lib/rspec/rails/matchers/relation_match_array.rb +1 -1
- data/lib/rspec/rails/matchers/routing_matchers.rb +7 -3
- data/lib/rspec/rails/mocks.rb +50 -26
- data/lib/rspec/rails/vendor/capybara.rb +4 -4
- data/lib/rspec/rails/version.rb +1 -1
- data/spec/generators/rspec/controller/controller_generator_spec.rb +16 -16
- data/spec/generators/rspec/feature/feature_generator_spec.rb +43 -0
- data/spec/generators/rspec/helper/helper_generator_spec.rb +4 -4
- data/spec/generators/rspec/install/install_generator_spec.rb +4 -4
- data/spec/generators/rspec/integration/integration_generator_spec.rb +8 -20
- data/spec/generators/rspec/mailer/mailer_generator_spec.rb +11 -11
- data/spec/generators/rspec/model/model_generator_spec.rb +7 -7
- data/spec/generators/rspec/observer/observer_generator_spec.rb +3 -3
- data/spec/generators/rspec/scaffold/scaffold_generator_spec.rb +34 -34
- data/spec/generators/rspec/view/view_generator_spec.rb +6 -6
- data/spec/rspec/rails/assertion_adapter_spec.rb +3 -3
- data/spec/rspec/rails/configuration_spec.rb +2 -2
- data/spec/rspec/rails/deprecations_spec.rb +1 -1
- data/spec/rspec/rails/example/controller_example_group_spec.rb +79 -20
- data/spec/rspec/rails/example/feature_example_group_spec.rb +2 -2
- data/spec/rspec/rails/example/helper_example_group_spec.rb +12 -12
- data/spec/rspec/rails/example/mailer_example_group_spec.rb +3 -3
- data/spec/rspec/rails/example/model_example_group_spec.rb +3 -3
- data/spec/rspec/rails/example/request_example_group_spec.rb +5 -5
- data/spec/rspec/rails/example/routing_example_group_spec.rb +5 -5
- data/spec/rspec/rails/example/view_example_group_spec.rb +44 -29
- data/spec/rspec/rails/extensions/active_model/errors_on_spec.rb +3 -3
- data/spec/rspec/rails/fixture_support_spec.rb +3 -3
- data/spec/rspec/rails/matchers/be_a_new_spec.rb +17 -17
- data/spec/rspec/rails/matchers/be_new_record_spec.rb +2 -2
- data/spec/rspec/rails/matchers/be_routable_spec.rb +8 -8
- data/spec/rspec/rails/matchers/be_valid_spec.rb +33 -4
- data/spec/rspec/rails/matchers/has_spec.rb +1 -1
- data/spec/rspec/rails/matchers/have_rendered_spec.rb +3 -3
- data/spec/rspec/rails/matchers/redirect_to_spec.rb +7 -6
- data/spec/rspec/rails/matchers/relation_match_array_spec.rb +6 -6
- data/spec/rspec/rails/matchers/route_to_spec.rb +21 -21
- data/spec/rspec/rails/minitest_lifecycle_adapter_spec.rb +9 -0
- data/spec/rspec/rails/mocks/mock_model_spec.rb +95 -73
- data/spec/rspec/rails/mocks/stub_model_spec.rb +23 -23
- data/spec/rspec/rails/setup_and_teardown_adapter_spec.rb +4 -4
- data/spec/rspec/rails/view_rendering_spec.rb +14 -14
- data/spec/spec_helper.rb +3 -5
- data/spec/support/helpers.rb +15 -1
- metadata +112 -46
- metadata.gz.sig +0 -0
- checksums.yaml +0 -15
- checksums.yaml.gz.sig +0 -2
@@ -1,3 +1,3 @@
|
|
1
1
|
if defined?(ActiveRecord::Relation)
|
2
|
-
RSpec::Matchers::OperatorMatcher.register(ActiveRecord::Relation, '=~', RSpec::Matchers::BuiltIn::
|
2
|
+
RSpec::Matchers::BuiltIn::OperatorMatcher.register(ActiveRecord::Relation, '=~', RSpec::Matchers::BuiltIn::ContainExactly)
|
3
3
|
end
|
@@ -31,10 +31,14 @@ module RSpec::Rails::Matchers
|
|
31
31
|
end
|
32
32
|
|
33
33
|
# @api private
|
34
|
-
def
|
34
|
+
def failure_message
|
35
35
|
rescued_exception.message
|
36
36
|
end
|
37
37
|
|
38
|
+
def failure_message_when_negated
|
39
|
+
"expected #{@actual.inspect} not to route to #{@expected.inspect}"
|
40
|
+
end
|
41
|
+
|
38
42
|
def description
|
39
43
|
"route #{@actual.inspect} to #{@expected.inspect}"
|
40
44
|
end
|
@@ -73,11 +77,11 @@ module RSpec::Rails::Matchers
|
|
73
77
|
end
|
74
78
|
end
|
75
79
|
|
76
|
-
def
|
80
|
+
def failure_message
|
77
81
|
"expected #{@actual.inspect} to be routable"
|
78
82
|
end
|
79
83
|
|
80
|
-
def
|
84
|
+
def failure_message_when_negated
|
81
85
|
"expected #{@actual.inspect} not to be routable, but it routes to #{@routing_options.inspect}"
|
82
86
|
end
|
83
87
|
end
|
data/lib/rspec/rails/mocks.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'active_support'
|
2
|
+
require 'active_support/deprecation'
|
1
3
|
require 'active_support/core_ext'
|
2
4
|
require 'active_model'
|
3
5
|
|
@@ -29,6 +31,19 @@ module RSpec
|
|
29
31
|
end
|
30
32
|
end
|
31
33
|
|
34
|
+
# Starting with Rails 4.1, ActiveRecord associations are inversible
|
35
|
+
# by default. This class represents an association from the mocked
|
36
|
+
# model's perspective.
|
37
|
+
#
|
38
|
+
# @private
|
39
|
+
class Association
|
40
|
+
attr_accessor :target, :inversed
|
41
|
+
|
42
|
+
def initialize(association_name)
|
43
|
+
@association_name = association_name
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
32
47
|
module ActiveRecordInstanceMethods
|
33
48
|
# Stubs `persisted?` to return `false` and `id` to return `nil`.
|
34
49
|
def destroy
|
@@ -45,6 +60,13 @@ module RSpec
|
|
45
60
|
def new_record?
|
46
61
|
!persisted?
|
47
62
|
end
|
63
|
+
|
64
|
+
# Returns an object representing an association from the mocked
|
65
|
+
# model's perspective. For use by Rails internally only.
|
66
|
+
def association(association_name)
|
67
|
+
@associations ||= Hash.new { |h, k| h[k] = Association.new(k) }
|
68
|
+
@associations[association_name]
|
69
|
+
end
|
48
70
|
end
|
49
71
|
|
50
72
|
# Creates a test double representing `string_or_model_class` with common
|
@@ -110,39 +132,41 @@ EOM
|
|
110
132
|
end
|
111
133
|
end
|
112
134
|
end
|
113
|
-
m.__send__(:__mock_proxy).instance_eval(<<-CODE, __FILE__, __LINE__)
|
114
|
-
def @object.is_a?(other)
|
115
|
-
#{model_class}.ancestors.include?(other)
|
116
|
-
end unless #{stubs.has_key?(:is_a?)}
|
117
135
|
|
118
|
-
|
119
|
-
|
120
|
-
|
136
|
+
msingleton = m.singleton_class
|
137
|
+
msingleton.__send__(:define_method, :is_a?) do |other|
|
138
|
+
model_class.ancestors.include?(other)
|
139
|
+
end unless stubs.has_key?(:is_a?)
|
121
140
|
|
122
|
-
|
123
|
-
|
124
|
-
|
141
|
+
msingleton.__send__(:define_method, :kind_of?) do |other|
|
142
|
+
model_class.ancestors.include?(other)
|
143
|
+
end unless stubs.has_key?(:kind_of?)
|
125
144
|
|
126
|
-
|
127
|
-
|
128
|
-
|
145
|
+
msingleton.__send__(:define_method, :instance_of?) do |other|
|
146
|
+
other == model_class
|
147
|
+
end unless stubs.has_key?(:instance_of?)
|
148
|
+
|
149
|
+
msingleton.__send__(:define_method, :__model_class_has_column?) do |method_name|
|
150
|
+
model_class.respond_to?(:column_names) && model_class.column_names.include?(method_name.to_s)
|
151
|
+
end
|
129
152
|
|
130
|
-
|
131
|
-
|
132
|
-
|
153
|
+
msingleton.__send__(:define_method, :respond_to?) do |method_name, *args|
|
154
|
+
include_private = args.first || false
|
155
|
+
__model_class_has_column?(method_name) ? true : super(method_name, include_private)
|
156
|
+
end unless stubs.has_key?(:respond_to?)
|
133
157
|
|
134
|
-
|
135
|
-
|
136
|
-
|
158
|
+
msingleton.__send__(:define_method, :method_missing) do |m, *a, &b|
|
159
|
+
respond_to?(m) ? null_object? ? self : nil : super(m, *a, &b)
|
160
|
+
end
|
137
161
|
|
138
|
-
|
139
|
-
|
140
|
-
|
162
|
+
msingleton.__send__(:define_method, :class) do
|
163
|
+
model_class
|
164
|
+
end unless stubs.has_key?(:class)
|
141
165
|
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
166
|
+
mock_param = to_param
|
167
|
+
msingleton.__send__(:define_method, :to_s) do
|
168
|
+
"#{model_class.name}_#{mock_param}"
|
169
|
+
end unless stubs.has_key?(:to_s)
|
146
170
|
yield m if block_given?
|
147
171
|
end
|
148
172
|
end
|
@@ -9,9 +9,11 @@ rescue LoadError
|
|
9
9
|
end
|
10
10
|
|
11
11
|
if defined?(Capybara)
|
12
|
+
require 'rspec/support/version_checker'
|
13
|
+
RSpec::Support::VersionChecker.new('capybara', Capybara::VERSION, '2.2.0').check_version!
|
14
|
+
|
12
15
|
RSpec.configure do |c|
|
13
16
|
if defined?(Capybara::DSL)
|
14
|
-
c.include Capybara::DSL, :type => :controller
|
15
17
|
c.include Capybara::DSL, :type => :feature
|
16
18
|
end
|
17
19
|
|
@@ -20,9 +22,7 @@ if defined?(Capybara)
|
|
20
22
|
c.include Capybara::RSpecMatchers, :type => :helper
|
21
23
|
c.include Capybara::RSpecMatchers, :type => :mailer
|
22
24
|
c.include Capybara::RSpecMatchers, :type => :controller
|
23
|
-
c.include Capybara::RSpecMatchers, :
|
24
|
-
:file_path => c.escaped_path(%w[spec features])
|
25
|
-
}
|
25
|
+
c.include Capybara::RSpecMatchers, :type => :feature
|
26
26
|
end
|
27
27
|
|
28
28
|
unless defined?(Capybara::RSpecMatchers) || defined?(Capybara::DSL)
|
data/lib/rspec/rails/version.rb
CHANGED
@@ -17,16 +17,16 @@ describe Rspec::Generators::ControllerGenerator do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
describe 'the spec' do
|
20
|
-
it {
|
21
|
-
it {
|
22
|
-
it {
|
20
|
+
it { is_expected.to exist }
|
21
|
+
it { is_expected.to contain(/require 'spec_helper'/) }
|
22
|
+
it { is_expected.to contain(/describe PostsController/) }
|
23
23
|
end
|
24
24
|
end
|
25
25
|
describe 'skipped with a flag' do
|
26
26
|
before do
|
27
27
|
run_generator %w(posts --no-controller_specs)
|
28
28
|
end
|
29
|
-
it {
|
29
|
+
it { is_expected.not_to exist }
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
@@ -38,7 +38,7 @@ describe Rspec::Generators::ControllerGenerator do
|
|
38
38
|
end
|
39
39
|
describe 'index.html.erb' do
|
40
40
|
subject { file('spec/views/posts/index.html.erb_spec.rb') }
|
41
|
-
it {
|
41
|
+
it { is_expected.not_to exist }
|
42
42
|
end
|
43
43
|
end
|
44
44
|
describe 'with no actions' do
|
@@ -47,7 +47,7 @@ describe Rspec::Generators::ControllerGenerator do
|
|
47
47
|
end
|
48
48
|
describe 'index.html.erb' do
|
49
49
|
subject { file('spec/views/posts/index.html.erb_spec.rb') }
|
50
|
-
it {
|
50
|
+
it { is_expected.not_to exist }
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
@@ -58,7 +58,7 @@ describe Rspec::Generators::ControllerGenerator do
|
|
58
58
|
|
59
59
|
describe 'index.html.erb' do
|
60
60
|
subject { file('spec/views/posts/index.html._spec.rb') }
|
61
|
-
it {
|
61
|
+
it { is_expected.not_to exist }
|
62
62
|
end
|
63
63
|
end
|
64
64
|
end
|
@@ -70,15 +70,15 @@ describe Rspec::Generators::ControllerGenerator do
|
|
70
70
|
end
|
71
71
|
describe 'index.html.erb' do
|
72
72
|
subject { file('spec/views/posts/index.html.erb_spec.rb') }
|
73
|
-
it {
|
74
|
-
it {
|
75
|
-
it {
|
73
|
+
it { is_expected.to exist }
|
74
|
+
it { is_expected.to contain(/require 'spec_helper'/) }
|
75
|
+
it { is_expected.to contain(/describe "posts\/index.html.erb"/) }
|
76
76
|
end
|
77
77
|
describe 'show.html.erb' do
|
78
78
|
subject { file('spec/views/posts/show.html.erb_spec.rb') }
|
79
|
-
it {
|
80
|
-
it {
|
81
|
-
it {
|
79
|
+
it { is_expected.to exist }
|
80
|
+
it { is_expected.to contain(/require 'spec_helper'/) }
|
81
|
+
it { is_expected.to contain(/describe "posts\/show.html.erb"/) }
|
82
82
|
end
|
83
83
|
end
|
84
84
|
describe 'with haml' do
|
@@ -87,9 +87,9 @@ describe Rspec::Generators::ControllerGenerator do
|
|
87
87
|
end
|
88
88
|
describe 'index.html.haml' do
|
89
89
|
subject { file('spec/views/posts/index.html.haml_spec.rb') }
|
90
|
-
it {
|
91
|
-
it {
|
92
|
-
it {
|
90
|
+
it { is_expected.to exist }
|
91
|
+
it { is_expected.to contain(/require 'spec_helper'/) }
|
92
|
+
it { is_expected.to contain(/describe "posts\/index.html.haml"/) }
|
93
93
|
end
|
94
94
|
end
|
95
95
|
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
# Generators are not automatically loaded by rails
|
4
|
+
require 'generators/rspec/feature/feature_generator'
|
5
|
+
|
6
|
+
describe Rspec::Generators::FeatureGenerator do
|
7
|
+
# Tell the generator where to put its output (what it thinks of as Rails.root)
|
8
|
+
destination File.expand_path("../../../../../temp", __FILE__)
|
9
|
+
|
10
|
+
before { prepare_destination }
|
11
|
+
|
12
|
+
describe 'feature specs' do
|
13
|
+
describe 'are generated independently from the command line' do
|
14
|
+
before do
|
15
|
+
run_generator %w(posts)
|
16
|
+
end
|
17
|
+
describe 'the spec' do
|
18
|
+
subject(:feature_spec) { file('spec/features/posts_spec.rb') }
|
19
|
+
it "exists" do
|
20
|
+
expect(feature_spec).to exist
|
21
|
+
end
|
22
|
+
it "contains 'spec_helper'" do
|
23
|
+
expect(feature_spec).to contain(/require 'spec_helper'/)
|
24
|
+
end
|
25
|
+
it "contains the feature" do
|
26
|
+
expect(feature_spec).to contain(/feature "Posts"/)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "are not generated" do
|
32
|
+
before do
|
33
|
+
run_generator %w(posts --no-feature-specs)
|
34
|
+
end
|
35
|
+
describe "the spec" do
|
36
|
+
subject(:feature_spec) { file('spec/features/posts_spec.rb') }
|
37
|
+
it "does not exist" do
|
38
|
+
expect(feature_spec).to_not exist
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -16,15 +16,15 @@ describe Rspec::Generators::HelperGenerator do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
describe 'the spec' do
|
19
|
-
it {
|
20
|
-
it {
|
21
|
-
it {
|
19
|
+
it { is_expected.to exist }
|
20
|
+
it { is_expected.to contain(/require 'spec_helper'/) }
|
21
|
+
it { is_expected.to contain(/describe PostsHelper/) }
|
22
22
|
end
|
23
23
|
end
|
24
24
|
describe 'skipped with a flag' do
|
25
25
|
before do
|
26
26
|
run_generator %w(posts --no-helper_specs)
|
27
27
|
end
|
28
|
-
it {
|
28
|
+
it { is_expected.not_to exist }
|
29
29
|
end
|
30
30
|
end
|
@@ -8,23 +8,23 @@ describe Rspec::Generators::InstallGenerator do
|
|
8
8
|
|
9
9
|
it "generates .rspec" do
|
10
10
|
run_generator
|
11
|
-
file('.rspec').
|
11
|
+
expect(file('.rspec')).to exist
|
12
12
|
end
|
13
13
|
|
14
14
|
it "generates spec/spec_helper.rb" do
|
15
15
|
run_generator
|
16
|
-
File.read( file('spec/spec_helper.rb') ).
|
16
|
+
expect(File.read( file('spec/spec_helper.rb') )).to match(/^require 'rspec\/rails'$/m)
|
17
17
|
end
|
18
18
|
|
19
19
|
if ::Rails::VERSION::STRING >= '4'
|
20
20
|
it "generates spec/spec_helper.rb with a check for pending migrations" do
|
21
21
|
run_generator
|
22
|
-
File.read( file('spec/spec_helper.rb') ).
|
22
|
+
expect(File.read( file('spec/spec_helper.rb') )).to match(/ActiveRecord::Migration\.check_pending!/m)
|
23
23
|
end
|
24
24
|
else
|
25
25
|
it "generates spec/spec_helper.rb without a check for pending migrations" do
|
26
26
|
run_generator
|
27
|
-
File.read( file('spec/spec_helper.rb') ).
|
27
|
+
expect(File.read( file('spec/spec_helper.rb') )).not_to match(/ActiveRecord::Migration\.check_pending!/m)
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
@@ -15,30 +15,18 @@ describe Rspec::Generators::IntegrationGenerator do
|
|
15
15
|
end
|
16
16
|
describe 'index.html.erb' do
|
17
17
|
subject { file('spec/requests/posts_spec.rb') }
|
18
|
-
it {
|
18
|
+
it { is_expected.not_to exist }
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
22
|
describe 'are generated' do
|
23
|
-
|
24
|
-
|
25
|
-
run_generator %w(posts)
|
26
|
-
end
|
27
|
-
subject { file('spec/requests/posts_spec.rb') }
|
28
|
-
it { should exist }
|
29
|
-
it { should contain(/require 'spec_helper'/) }
|
30
|
-
it { should contain(/describe "GET \/posts"/) }
|
31
|
-
it { should contain(/get posts_index_path/) }
|
32
|
-
end
|
33
|
-
describe 'with webrat matchers' do
|
34
|
-
before do
|
35
|
-
run_generator %w(posts --webrat)
|
36
|
-
end
|
37
|
-
subject { file('spec/requests/posts_spec.rb') }
|
38
|
-
it { should exist }
|
39
|
-
it { should contain(/require 'spec_helper'/) }
|
40
|
-
it { should contain(/describe "GET \/posts"/) }
|
41
|
-
it { should contain(/visit posts_index_path/) }
|
23
|
+
before do
|
24
|
+
run_generator %w(posts)
|
42
25
|
end
|
26
|
+
subject { file('spec/requests/posts_spec.rb') }
|
27
|
+
it { is_expected.to exist }
|
28
|
+
it { is_expected.to contain(/require 'spec_helper'/) }
|
29
|
+
it { is_expected.to contain(/describe "GET \/posts"/) }
|
30
|
+
it { is_expected.to contain(/get posts_index_path/) }
|
43
31
|
end
|
44
32
|
end
|
@@ -15,18 +15,18 @@ describe Rspec::Generators::MailerGenerator do
|
|
15
15
|
before do
|
16
16
|
run_generator %w(posts index show)
|
17
17
|
end
|
18
|
-
it {
|
19
|
-
it {
|
20
|
-
it {
|
21
|
-
it {
|
18
|
+
it { is_expected.to exist }
|
19
|
+
it { is_expected.to contain(/require "spec_helper"/) }
|
20
|
+
it { is_expected.to contain(/describe "index" do/) }
|
21
|
+
it { is_expected.to contain(/describe "show" do/) }
|
22
22
|
end
|
23
23
|
describe 'creates placeholder when no actions specified' do
|
24
24
|
before do
|
25
25
|
run_generator %w(posts)
|
26
26
|
end
|
27
|
-
it {
|
28
|
-
it {
|
29
|
-
it {
|
27
|
+
it { is_expected.to exist }
|
28
|
+
it { is_expected.to contain(/require "spec_helper"/) }
|
29
|
+
it { is_expected.to contain(/pending "add some examples to \(or delete\)/) }
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
@@ -36,13 +36,13 @@ describe Rspec::Generators::MailerGenerator do
|
|
36
36
|
end
|
37
37
|
describe 'index' do
|
38
38
|
subject { file('spec/fixtures/posts/index') }
|
39
|
-
it {
|
40
|
-
it {
|
39
|
+
it { is_expected.to exist }
|
40
|
+
it { is_expected.to contain(/Posts#index/) }
|
41
41
|
end
|
42
42
|
describe 'show' do
|
43
43
|
subject { file('spec/fixtures/posts/show') }
|
44
|
-
it {
|
45
|
-
it {
|
44
|
+
it { is_expected.to exist }
|
45
|
+
it { is_expected.to contain(/Posts#show/) }
|
46
46
|
end
|
47
47
|
end
|
48
48
|
end
|
@@ -11,8 +11,8 @@ describe Rspec::Generators::ModelGenerator do
|
|
11
11
|
|
12
12
|
it 'runs both the model and fixture tasks' do
|
13
13
|
gen = generator %w(posts)
|
14
|
-
gen.
|
15
|
-
gen.
|
14
|
+
expect(gen).to receive :create_model_spec
|
15
|
+
expect(gen).to receive :create_fixture_file
|
16
16
|
capture(:stdout) { gen.invoke_all }
|
17
17
|
end
|
18
18
|
|
@@ -25,15 +25,15 @@ describe Rspec::Generators::ModelGenerator do
|
|
25
25
|
describe 'the spec' do
|
26
26
|
subject { file('spec/models/posts_spec.rb') }
|
27
27
|
|
28
|
-
it {
|
29
|
-
it {
|
30
|
-
it {
|
28
|
+
it { is_expected.to exist }
|
29
|
+
it { is_expected.to contain(/require 'spec_helper'/) }
|
30
|
+
it { is_expected.to contain(/describe Posts/) }
|
31
31
|
end
|
32
32
|
|
33
33
|
describe 'the fixtures' do
|
34
34
|
subject { file('spec/fixtures/posts.yml') }
|
35
35
|
|
36
|
-
it {
|
36
|
+
it { is_expected.to contain(Regexp.new('# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html')) }
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
@@ -45,7 +45,7 @@ describe Rspec::Generators::ModelGenerator do
|
|
45
45
|
describe 'the fixtures' do
|
46
46
|
subject { file('spec/fixtures/posts.yml') }
|
47
47
|
|
48
|
-
it {
|
48
|
+
it { is_expected.not_to exist }
|
49
49
|
end
|
50
50
|
end
|
51
51
|
end
|