rspec-rails 3.0.0.beta2 → 3.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +2 -1
- data/Capybara.md +1 -3
- data/Changelog.md +126 -58
- data/README.md +31 -4
- data/lib/generators/rspec/controller/templates/controller_spec.rb +1 -1
- data/lib/generators/rspec/controller/templates/view_spec.rb +1 -1
- data/lib/generators/rspec/feature/templates/feature_spec.rb +1 -1
- data/lib/generators/rspec/helper/templates/helper_spec.rb +1 -1
- data/lib/generators/rspec/install/templates/spec/spec_helper.rb.tt +21 -1
- data/lib/generators/rspec/integration/templates/request_spec.rb +1 -1
- data/lib/generators/rspec/mailer/templates/mailer_spec.rb +1 -1
- data/lib/generators/rspec/model/templates/model_spec.rb +1 -1
- data/lib/generators/rspec/observer/templates/observer_spec.rb +1 -1
- data/lib/generators/rspec/scaffold/templates/controller_spec.rb +11 -3
- data/lib/generators/rspec/scaffold/templates/edit_spec.rb +4 -3
- data/lib/generators/rspec/scaffold/templates/index_spec.rb +2 -2
- data/lib/generators/rspec/scaffold/templates/new_spec.rb +5 -4
- data/lib/generators/rspec/scaffold/templates/routing_spec.rb +1 -1
- data/lib/generators/rspec/scaffold/templates/show_spec.rb +2 -2
- data/lib/generators/rspec/view/templates/view_spec.rb +1 -1
- data/lib/rspec/rails.rb +1 -8
- data/lib/rspec/rails/configuration.rb +72 -0
- data/lib/rspec/rails/example.rb +0 -64
- data/lib/rspec/rails/example/controller_example_group.rb +16 -12
- data/lib/rspec/rails/example/feature_example_group.rb +0 -2
- data/lib/rspec/rails/example/helper_example_group.rb +0 -2
- data/lib/rspec/rails/example/mailer_example_group.rb +0 -1
- data/lib/rspec/rails/example/model_example_group.rb +0 -4
- data/lib/rspec/rails/example/request_example_group.rb +0 -2
- data/lib/rspec/rails/example/routing_example_group.rb +0 -2
- data/lib/rspec/rails/example/view_example_group.rb +1 -2
- data/lib/rspec/rails/extensions.rb +0 -1
- data/lib/rspec/rails/fixture_support.rb +0 -8
- data/lib/rspec/rails/matchers.rb +1 -0
- data/lib/rspec/rails/matchers/have_http_status.rb +355 -0
- data/lib/rspec/rails/matchers/routing_matchers.rb +1 -1
- data/lib/rspec/rails/tasks/rspec.rake +12 -5
- data/lib/rspec/rails/version.rb +1 -1
- data/lib/rspec/rails/view_rendering.rb +6 -34
- metadata +42 -316
- metadata.gz.sig +0 -0
- data/features/Generators.md +0 -25
- data/features/GettingStarted.md +0 -84
- data/features/README.md +0 -48
- data/features/RailsVersions.md +0 -4
- data/features/Transactions.md +0 -84
- data/features/Upgrade.md +0 -121
- data/features/controller_specs/Cookies.md +0 -57
- data/features/controller_specs/README.md +0 -45
- data/features/controller_specs/anonymous_controller.feature +0 -436
- data/features/controller_specs/bypass_rescue.feature +0 -75
- data/features/controller_specs/controller_spec.feature +0 -58
- data/features/controller_specs/engine_routes.feature +0 -51
- data/features/controller_specs/isolation_from_views.feature +0 -87
- data/features/controller_specs/render_views.feature +0 -114
- data/features/directory_structure.feature +0 -71
- data/features/feature_specs/feature_spec.feature +0 -35
- data/features/helper_specs/helper_spec.feature +0 -122
- data/features/mailer_specs/url_helpers.feature +0 -38
- data/features/matchers/README.md +0 -18
- data/features/matchers/new_record_matcher.feature +0 -41
- data/features/matchers/redirect_to_matcher.feature +0 -40
- data/features/matchers/relation_match_array.feature +0 -27
- data/features/matchers/render_template_matcher.feature +0 -49
- data/features/mocks/mock_model.feature +0 -147
- data/features/mocks/stub_model.feature +0 -58
- data/features/model_specs/README.md +0 -21
- data/features/model_specs/errors_on.feature +0 -51
- data/features/model_specs/records.feature +0 -27
- data/features/model_specs/transactional_examples.feature +0 -109
- data/features/request_specs/request_spec.feature +0 -49
- data/features/routing_specs/README.md +0 -16
- data/features/routing_specs/be_routable_matcher.feature +0 -80
- data/features/routing_specs/engine_routes.feature +0 -38
- data/features/routing_specs/named_routes.feature +0 -18
- data/features/routing_specs/route_to_matcher.feature +0 -90
- data/features/step_definitions/additional_cli_steps.rb +0 -4
- data/features/step_definitions/model_steps.rb +0 -3
- data/features/support/capybara.rb +0 -7
- data/features/support/env.rb +0 -53
- data/features/support/rails_versions.rb +0 -4
- data/features/support/rubinius.rb +0 -6
- data/features/view_specs/inferred_controller_path.feature +0 -45
- data/features/view_specs/stub_template.feature +0 -51
- data/features/view_specs/view_spec.feature +0 -206
- data/lib/rspec/rails/extensions/active_record/base.rb +0 -58
- data/lib/rspec/rails/mocks.rb +0 -272
- data/lib/rspec/rails/vendor/webrat.rb +0 -33
- data/spec/generators/rspec/controller/controller_generator_spec.rb +0 -97
- data/spec/generators/rspec/feature/feature_generator_spec.rb +0 -43
- data/spec/generators/rspec/helper/helper_generator_spec.rb +0 -30
- data/spec/generators/rspec/install/install_generator_spec.rb +0 -30
- data/spec/generators/rspec/integration/integration_generator_spec.rb +0 -32
- data/spec/generators/rspec/mailer/mailer_generator_spec.rb +0 -48
- data/spec/generators/rspec/model/model_generator_spec.rb +0 -52
- data/spec/generators/rspec/observer/observer_generator_spec.rb +0 -21
- data/spec/generators/rspec/scaffold/scaffold_generator_spec.rb +0 -138
- data/spec/generators/rspec/view/view_generator_spec.rb +0 -41
- data/spec/rspec/rails/assertion_adapter_spec.rb +0 -28
- data/spec/rspec/rails/assertion_delegator_spec.rb +0 -43
- data/spec/rspec/rails/configuration_spec.rb +0 -26
- data/spec/rspec/rails/deprecations_spec.rb +0 -18
- data/spec/rspec/rails/example/controller_example_group_spec.rb +0 -159
- data/spec/rspec/rails/example/feature_example_group_spec.rb +0 -56
- data/spec/rspec/rails/example/helper_example_group_spec.rb +0 -66
- data/spec/rspec/rails/example/mailer_example_group_spec.rb +0 -21
- data/spec/rspec/rails/example/model_example_group_spec.rb +0 -15
- data/spec/rspec/rails/example/request_example_group_spec.rb +0 -17
- data/spec/rspec/rails/example/routing_example_group_spec.rb +0 -32
- data/spec/rspec/rails/example/view_example_group_spec.rb +0 -235
- data/spec/rspec/rails/extensions/active_model/errors_on_spec.rb +0 -23
- data/spec/rspec/rails/extensions/active_record/base_spec.rb +0 -42
- data/spec/rspec/rails/fixture_support_spec.rb +0 -17
- data/spec/rspec/rails/matchers/be_a_new_spec.rb +0 -142
- data/spec/rspec/rails/matchers/be_new_record_spec.rb +0 -33
- data/spec/rspec/rails/matchers/be_routable_spec.rb +0 -41
- data/spec/rspec/rails/matchers/be_valid_spec.rb +0 -73
- data/spec/rspec/rails/matchers/has_spec.rb +0 -29
- data/spec/rspec/rails/matchers/have_rendered_spec.rb +0 -93
- data/spec/rspec/rails/matchers/redirect_to_spec.rb +0 -81
- data/spec/rspec/rails/matchers/relation_match_array_spec.rb +0 -31
- data/spec/rspec/rails/matchers/route_to_spec.rb +0 -151
- data/spec/rspec/rails/minitest_lifecycle_adapter_spec.rb +0 -31
- data/spec/rspec/rails/mocks/mock_model_spec.rb +0 -400
- data/spec/rspec/rails/mocks/stub_model_spec.rb +0 -154
- data/spec/rspec/rails/setup_and_teardown_adapter_spec.rb +0 -32
- data/spec/rspec/rails/view_rendering_spec.rb +0 -111
- data/spec/spec_helper.rb +0 -33
- data/spec/support/ar_classes.rb +0 -42
- data/spec/support/helpers.rb +0 -34
- data/spec/support/matchers.rb +0 -9
- data/spec/support/null_object.rb +0 -6
data/lib/rspec/rails/mocks.rb
DELETED
@@ -1,272 +0,0 @@
|
|
1
|
-
require 'active_support'
|
2
|
-
require 'active_support/deprecation'
|
3
|
-
require 'active_support/core_ext'
|
4
|
-
require 'active_model'
|
5
|
-
|
6
|
-
module RSpec
|
7
|
-
module Rails
|
8
|
-
|
9
|
-
class IllegalDataAccessException < StandardError; end
|
10
|
-
|
11
|
-
module Mocks
|
12
|
-
|
13
|
-
module ActiveModelInstanceMethods
|
14
|
-
# Stubs `persisted?` to return false and `id` to return nil
|
15
|
-
# @return self
|
16
|
-
def as_new_record
|
17
|
-
RSpec::Mocks.allow_message(self, :persisted?).and_return(false)
|
18
|
-
RSpec::Mocks.allow_message(self, :id).and_return(nil)
|
19
|
-
self
|
20
|
-
end
|
21
|
-
|
22
|
-
# Returns true by default. Override with a stub.
|
23
|
-
def persisted?
|
24
|
-
true
|
25
|
-
end
|
26
|
-
|
27
|
-
# Returns false for names matching <tt>/_before_type_cast$/</tt>,
|
28
|
-
# otherwise delegates to super.
|
29
|
-
def respond_to?(message, include_private=false)
|
30
|
-
message.to_s =~ /_before_type_cast$/ ? false : super
|
31
|
-
end
|
32
|
-
end
|
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
|
-
|
47
|
-
module ActiveRecordInstanceMethods
|
48
|
-
# Stubs `persisted?` to return `false` and `id` to return `nil`.
|
49
|
-
def destroy
|
50
|
-
RSpec::Mocks.allow_message(self, :persisted?).and_return(false)
|
51
|
-
RSpec::Mocks.allow_message(self, :id).and_return(nil)
|
52
|
-
end
|
53
|
-
|
54
|
-
# Transforms the key to a method and calls it.
|
55
|
-
def [](key)
|
56
|
-
send(key)
|
57
|
-
end
|
58
|
-
|
59
|
-
# Returns the opposite of `persisted?`
|
60
|
-
def new_record?
|
61
|
-
!persisted?
|
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
|
70
|
-
end
|
71
|
-
|
72
|
-
# Creates a test double representing `string_or_model_class` with common
|
73
|
-
# ActiveModel methods stubbed out. Additional methods may be easily
|
74
|
-
# stubbed (via add_stubs) if `stubs` is passed. This is most useful for
|
75
|
-
# impersonating models that don't exist yet.
|
76
|
-
#
|
77
|
-
# NOTE that only ActiveModel's methods, plus <tt>new_record?</tt>, are
|
78
|
-
# stubbed out implicitly. <tt>new_record?</tt> returns the inverse of
|
79
|
-
# <tt>persisted?</tt>, and is present only for compatibility with
|
80
|
-
# extension frameworks that have yet to update themselves to the
|
81
|
-
# ActiveModel API (which declares <tt>persisted?</tt>, not
|
82
|
-
# <tt>new_record?</tt>).
|
83
|
-
#
|
84
|
-
# `string_or_model_class` can be any of:
|
85
|
-
#
|
86
|
-
# * A String representing a Class that does not exist
|
87
|
-
# * A String representing a Class that extends ActiveModel::Naming
|
88
|
-
# * A Class that extends ActiveModel::Naming
|
89
|
-
def mock_model(string_or_model_class, stubs = {})
|
90
|
-
if String === string_or_model_class
|
91
|
-
if Object.const_defined?(string_or_model_class)
|
92
|
-
model_class = Object.const_get(string_or_model_class)
|
93
|
-
else
|
94
|
-
model_class = Object.const_set(string_or_model_class, Class.new do
|
95
|
-
extend ActiveModel::Naming
|
96
|
-
def self.primary_key; :id; end
|
97
|
-
end)
|
98
|
-
end
|
99
|
-
else
|
100
|
-
model_class = string_or_model_class
|
101
|
-
end
|
102
|
-
|
103
|
-
unless model_class.kind_of? ActiveModel::Naming
|
104
|
-
raise ArgumentError.new <<-EOM
|
105
|
-
The mock_model method can only accept as its first argument:
|
106
|
-
* A String representing a Class that does not exist
|
107
|
-
* A String representing a Class that extends ActiveModel::Naming
|
108
|
-
* A Class that extends ActiveModel::Naming
|
109
|
-
|
110
|
-
It received #{model_class.inspect}
|
111
|
-
EOM
|
112
|
-
end
|
113
|
-
|
114
|
-
stubs = stubs.reverse_merge(:id => next_id)
|
115
|
-
stubs = stubs.reverse_merge(:persisted? => !!stubs[:id],
|
116
|
-
:destroyed? => false,
|
117
|
-
:marked_for_destruction? => false,
|
118
|
-
:valid? => true,
|
119
|
-
:blank? => false)
|
120
|
-
|
121
|
-
double("#{model_class.name}_#{stubs[:id]}", stubs).tap do |m|
|
122
|
-
m.singleton_class.class_eval do
|
123
|
-
include ActiveModelInstanceMethods
|
124
|
-
include ActiveRecordInstanceMethods if defined?(ActiveRecord)
|
125
|
-
include ActiveModel::Conversion
|
126
|
-
include ActiveModel::Validations
|
127
|
-
end
|
128
|
-
if defined?(ActiveRecord)
|
129
|
-
[:save, :update_attributes, :update].each do |key|
|
130
|
-
if stubs[key] == false
|
131
|
-
RSpec::Mocks.allow_message(m.errors, :empty?).and_return(false)
|
132
|
-
end
|
133
|
-
end
|
134
|
-
end
|
135
|
-
|
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?)
|
140
|
-
|
141
|
-
msingleton.__send__(:define_method, :kind_of?) do |other|
|
142
|
-
model_class.ancestors.include?(other)
|
143
|
-
end unless stubs.has_key?(:kind_of?)
|
144
|
-
|
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
|
152
|
-
|
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?)
|
157
|
-
|
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
|
161
|
-
|
162
|
-
msingleton.__send__(:define_method, :class) do
|
163
|
-
model_class
|
164
|
-
end unless stubs.has_key?(:class)
|
165
|
-
|
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)
|
170
|
-
yield m if block_given?
|
171
|
-
end
|
172
|
-
end
|
173
|
-
|
174
|
-
module ActiveModelStubExtensions
|
175
|
-
# Stubs `persisted` to return false and `id` to return nil
|
176
|
-
def as_new_record
|
177
|
-
RSpec::Mocks.allow_message(self, :persisted?).and_return(false)
|
178
|
-
RSpec::Mocks.allow_message(self, :id).and_return(nil)
|
179
|
-
self
|
180
|
-
end
|
181
|
-
|
182
|
-
# Returns `true` by default. Override with a stub.
|
183
|
-
def persisted?
|
184
|
-
true
|
185
|
-
end
|
186
|
-
end
|
187
|
-
|
188
|
-
module ActiveRecordStubExtensions
|
189
|
-
# Stubs `id` (or other primary key method) to return nil
|
190
|
-
def as_new_record
|
191
|
-
self.__send__("#{self.class.primary_key}=", nil)
|
192
|
-
super
|
193
|
-
end
|
194
|
-
|
195
|
-
# Returns the opposite of `persisted?`.
|
196
|
-
def new_record?
|
197
|
-
!persisted?
|
198
|
-
end
|
199
|
-
|
200
|
-
# Raises an IllegalDataAccessException (stubbed models are not allowed to access the database)
|
201
|
-
# @raises IllegalDataAccessException
|
202
|
-
def connection
|
203
|
-
raise RSpec::Rails::IllegalDataAccessException.new("stubbed models are not allowed to access the database")
|
204
|
-
end
|
205
|
-
end
|
206
|
-
|
207
|
-
# Creates an instance of `Model` with `to_param` stubbed using a
|
208
|
-
# generated value that is unique to each object. If `Model` is an
|
209
|
-
# `ActiveRecord` model, it is prohibited from accessing the database*.
|
210
|
-
#
|
211
|
-
# For each key in `stubs`, if the model has a matching attribute
|
212
|
-
# (determined by `respond_to?`) it is simply assigned the submitted values.
|
213
|
-
# If the model does not have a matching attribute, the key/value pair is
|
214
|
-
# assigned as a stub return value using RSpec's mocking/stubbing
|
215
|
-
# framework.
|
216
|
-
#
|
217
|
-
# <tt>persisted?</tt> is overridden to return the result of !id.nil?
|
218
|
-
# This means that by default persisted? will return true. If you want
|
219
|
-
# the object to behave as a new record, sending it `as_new_record` will
|
220
|
-
# set the id to nil. You can also explicitly set :id => nil, in which
|
221
|
-
# case persisted? will return false, but using `as_new_record` makes the
|
222
|
-
# example a bit more descriptive.
|
223
|
-
#
|
224
|
-
# While you can use stub_model in any example (model, view, controller,
|
225
|
-
# helper), it is especially useful in view examples, which are
|
226
|
-
# inherently more state-based than interaction-based.
|
227
|
-
#
|
228
|
-
# @example
|
229
|
-
#
|
230
|
-
# stub_model(Person)
|
231
|
-
# stub_model(Person).as_new_record
|
232
|
-
# stub_model(Person, :to_param => 37)
|
233
|
-
# stub_model(Person) {|person| person.first_name = "David"}
|
234
|
-
def stub_model(model_class, stubs={})
|
235
|
-
model_class.new.tap do |m|
|
236
|
-
m.extend ActiveModelStubExtensions
|
237
|
-
if defined?(ActiveRecord) && model_class < ActiveRecord::Base
|
238
|
-
m.extend ActiveRecordStubExtensions
|
239
|
-
primary_key = model_class.primary_key.to_sym
|
240
|
-
stubs = stubs.reverse_merge(primary_key => next_id)
|
241
|
-
stubs = stubs.reverse_merge(:persisted? => !!stubs[primary_key])
|
242
|
-
else
|
243
|
-
stubs = stubs.reverse_merge(:id => next_id)
|
244
|
-
stubs = stubs.reverse_merge(:persisted? => !!stubs[:id])
|
245
|
-
end
|
246
|
-
stubs = stubs.reverse_merge(:blank? => false)
|
247
|
-
|
248
|
-
stubs.each do |message, return_value|
|
249
|
-
if m.respond_to?("#{message}=")
|
250
|
-
m.__send__("#{message}=", return_value)
|
251
|
-
else
|
252
|
-
RSpec::Mocks.allow_message(m, message).and_return(return_value)
|
253
|
-
end
|
254
|
-
end
|
255
|
-
|
256
|
-
yield m if block_given?
|
257
|
-
end
|
258
|
-
end
|
259
|
-
|
260
|
-
private
|
261
|
-
|
262
|
-
@@model_id = 1000
|
263
|
-
|
264
|
-
def next_id
|
265
|
-
@@model_id += 1
|
266
|
-
end
|
267
|
-
|
268
|
-
end
|
269
|
-
end
|
270
|
-
end
|
271
|
-
|
272
|
-
RSpec.configuration.include RSpec::Rails::Mocks
|
@@ -1,33 +0,0 @@
|
|
1
|
-
begin
|
2
|
-
require 'webrat'
|
3
|
-
rescue LoadError
|
4
|
-
end
|
5
|
-
|
6
|
-
RSpec.configure do |c|
|
7
|
-
if defined?(Webrat)
|
8
|
-
c.include Webrat::Matchers, :type => :request
|
9
|
-
c.include Webrat::Matchers, :type => :controller
|
10
|
-
c.include Webrat::Matchers, :type => :view
|
11
|
-
c.include Webrat::Matchers, :type => :helper
|
12
|
-
c.include Webrat::Matchers, :type => :mailer
|
13
|
-
|
14
|
-
c.include Webrat::Methods, :type => :request
|
15
|
-
c.include Webrat::Methods, :type => :controller
|
16
|
-
|
17
|
-
module RequestInstanceMethods
|
18
|
-
def last_response
|
19
|
-
@response
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
c.include RequestInstanceMethods, :type => :request
|
24
|
-
|
25
|
-
c.before :type => :controller do
|
26
|
-
Webrat.configure {|w| w.mode = :rails}
|
27
|
-
end
|
28
|
-
|
29
|
-
c.before :type => :request do
|
30
|
-
Webrat.configure {|w| w.mode = :rack}
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,97 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
# Generators are not automatically loaded by Rails
|
4
|
-
require 'generators/rspec/controller/controller_generator'
|
5
|
-
|
6
|
-
describe Rspec::Generators::ControllerGenerator do
|
7
|
-
# Tell the generator where to put its output (what it thinks of as Rails.root)
|
8
|
-
destination File.expand_path("../../../../../tmp", __FILE__)
|
9
|
-
|
10
|
-
before { prepare_destination }
|
11
|
-
|
12
|
-
describe 'controller specs' do
|
13
|
-
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
|
-
|
19
|
-
describe 'the spec' do
|
20
|
-
it { is_expected.to exist }
|
21
|
-
it { is_expected.to contain(/require 'spec_helper'/) }
|
22
|
-
it { is_expected.to contain(/describe PostsController/) }
|
23
|
-
end
|
24
|
-
end
|
25
|
-
describe 'skipped with a flag' do
|
26
|
-
before do
|
27
|
-
run_generator %w(posts --no-controller_specs)
|
28
|
-
end
|
29
|
-
it { is_expected.not_to exist }
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
describe 'view specs' do
|
34
|
-
describe 'are not generated' do
|
35
|
-
describe 'with no-view-spec flag' do
|
36
|
-
before do
|
37
|
-
run_generator %w(posts index show --no-view-specs)
|
38
|
-
end
|
39
|
-
describe 'index.html.erb' do
|
40
|
-
subject { file('spec/views/posts/index.html.erb_spec.rb') }
|
41
|
-
it { is_expected.not_to exist }
|
42
|
-
end
|
43
|
-
end
|
44
|
-
describe 'with no actions' do
|
45
|
-
before do
|
46
|
-
run_generator %w(posts)
|
47
|
-
end
|
48
|
-
describe 'index.html.erb' do
|
49
|
-
subject { file('spec/views/posts/index.html.erb_spec.rb') }
|
50
|
-
it { is_expected.not_to exist }
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
describe 'with --no-template-engine' do
|
55
|
-
before do
|
56
|
-
run_generator %w(posts index --no-template-engine)
|
57
|
-
end
|
58
|
-
|
59
|
-
describe 'index.html.erb' do
|
60
|
-
subject { file('spec/views/posts/index.html._spec.rb') }
|
61
|
-
it { is_expected.not_to exist }
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
describe 'are generated' do
|
67
|
-
describe 'with default template engine' do
|
68
|
-
before do
|
69
|
-
run_generator %w(posts index show)
|
70
|
-
end
|
71
|
-
describe 'index.html.erb' do
|
72
|
-
subject { file('spec/views/posts/index.html.erb_spec.rb') }
|
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
|
-
end
|
77
|
-
describe 'show.html.erb' do
|
78
|
-
subject { file('spec/views/posts/show.html.erb_spec.rb') }
|
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
|
-
end
|
83
|
-
end
|
84
|
-
describe 'with haml' do
|
85
|
-
before do
|
86
|
-
run_generator %w(posts index --template_engine haml)
|
87
|
-
end
|
88
|
-
describe 'index.html.haml' do
|
89
|
-
subject { file('spec/views/posts/index.html.haml_spec.rb') }
|
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
|
-
end
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
@@ -1,43 +0,0 @@
|
|
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
|