Skip to content

Integration generator deprecation #2387

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ Breaking Changes:
* Change the order of `after_teardown` from `after` to `around` in system
specs to improve compatibility with extensions and Capybara. (Tim Diggins, #2596)

Deprecations:

* Deprecates integration spec generator (`rspec:integration`)
which was an alias of request spec generator (`rspec:request`)
(Luka Lüdicke, #2374)

### 6.0.0.rc1

Enhancements:
Expand Down
2 changes: 1 addition & 1 deletion example_app_generator/generate_stuff.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def using_source_path(path)
# request specs are now the default
generate('rspec:controller wombats --no-request-specs --controller-specs --no-view-specs')

generate('integration_test widgets')
generate('integration_test widgets') # deprecated
generate('mailer Notifications signup')

generate('model thing name:string')
Expand Down
11 changes: 9 additions & 2 deletions lib/generators/rspec/integration/integration_generator.rb
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
require 'generators/rspec'
require 'rspec/core/warnings'

module Rspec
module Generators
# @private
class IntegrationGenerator < Base
# Add a deprecation for this class, before rspec-rails 4, to use the
# `RequestGenerator` instead
class_option :request_specs,
type: :boolean,
default: true,
desc: "Generate request specs"

source_paths << File.expand_path('../request/templates', __dir__)

def generate_request_spec
return unless options[:request_specs]

RSpec.warn_deprecation <<-WARNING.gsub(/\s*\|/, ' ')
|The integration generator is deprecated
|and will be deleted in RSpec-Rails 7.
|Please use the request generator instead.
WARNING

template 'request_spec.rb',
File.join('spec/requests', "#{name.underscore.pluralize}_spec.rb")
end
Expand Down
13 changes: 10 additions & 3 deletions lib/generators/rspec/request/request_generator.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
require 'generators/rspec/integration/integration_generator'
require 'generators/rspec'

module Rspec
module Generators
# @private
class RequestGenerator < IntegrationGenerator
source_paths << File.expand_path('../integration/templates', __dir__)
class RequestGenerator < Base
class_option :request_specs, type: :boolean, default: true, desc: 'Generate request specs'

def generate_request_spec
return unless options[:request_specs]

template 'request_spec.rb',
File.join('spec/requests', "#{name.underscore.pluralize}_spec.rb")
end
end
end
end
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
# Generators are not automatically loaded by Rails
require 'generators/rspec/integration/integration_generator'
require 'support/generators'
require 'rspec/core/warnings'

RSpec.describe Rspec::Generators::IntegrationGenerator, type: :generator do
setup_default_destination
it_behaves_like "a request spec generator"

it 'is deprecated' do
expect(RSpec).to receive(:warn_deprecation)
run_generator %w[posts]
end
end