Skip to content
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
2 changes: 1 addition & 1 deletion .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Style/EachWithObject:

# ruby 1.8.7 only had support for hash rockets
Style/HashSyntax:
EnforcedStyle: hash_rockets # default: ruby19
EnforcedStyle: ruby19 # default: ruby19

# the new lambda syntax was not supported in ruby 1.8.7
Style/Lambda:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Use **[`rspec-rails` 1.x][]** for Rails 2.x.
# (requires master-branch versions of all related RSpec libraries)
group :development, :test do
%w[rspec-core rspec-expectations rspec-mocks rspec-rails rspec-support].each do |lib|
gem lib, :git => "https://github.com/rspec/#{lib}.git", :branch => 'master'
gem lib, git: "https://github.com/rspec/#{lib}.git", branch: 'master'
end
end
```
Expand Down
4 changes: 2 additions & 2 deletions features/step_definitions/additional_cli_steps.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
begin
require "active_job"
rescue LoadError # rubocop:disable Lint/HandleExceptions
rescue LoadError # rubocop:disable Lint/SuppressedException
end
begin
require "action_cable"
rescue LoadError # rubocop:disable Lint/HandleExceptions
rescue LoadError # rubocop:disable Lint/SuppressedException
end

require "rails/version"
Expand Down
10 changes: 5 additions & 5 deletions lib/generators/rspec/controller/controller_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ module Rspec
module Generators
# @private
class ControllerGenerator < Base
argument :actions, :type => :array, :default => [], :banner => "action action"
argument :actions, type: :array, default: [], banner: "action action"

class_option :template_engine, :desc => "Template engine to generate view files"
class_option :controller_specs, :type => :boolean, :default => true, :desc => "Generate controller specs"
class_option :view_specs, :type => :boolean, :default => true, :desc => "Generate view specs"
class_option :routing_specs, :type => :boolean, :default => false, :desc => "Generate routing specs"
class_option :template_engine, desc: "Template engine to generate view files"
class_option :controller_specs, type: :boolean, default: true, desc: "Generate controller specs"
class_option :view_specs, type: :boolean, default: true, desc: "Generate view specs"
class_option :routing_specs, type: :boolean, default: false, desc: "Generate routing specs"

def generate_controller_spec
return unless options[:controller_specs]
Expand Down
2 changes: 1 addition & 1 deletion lib/generators/rspec/controller/templates/routing_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
describe 'routing' do
<% for action in actions -%>
it 'routes to #<%= action %>' do
expect(:get => "/<%= class_name.underscore %>/<%= action %>").to route_to("<%= class_name.underscore %>#<%= action %>")
expect(get: "/<%= class_name.underscore %>/<%= action %>").to route_to("<%= class_name.underscore %>#<%= action %>")
end
<% end -%>
end
Expand Down
4 changes: 2 additions & 2 deletions lib/generators/rspec/feature/feature_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ module Rspec
module Generators
# @private
class FeatureGenerator < Base
class_option :feature_specs, :type => :boolean, :default => true, :desc => "Generate feature specs"
class_option :singularize, :type => :boolean, :default => false, :desc => "Singularize the generated feature"
class_option :feature_specs, type: :boolean, default: true, desc: "Generate feature specs"
class_option :singularize, type: :boolean, default: false, desc: "Singularize the generated feature"

def generate_feature_spec
return unless options[:feature_specs]
Expand Down
2 changes: 1 addition & 1 deletion lib/generators/rspec/generators/generator_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Rspec
module Generators
# @private
class GeneratorsGenerator < Base
class_option :generator_specs, :type => :boolean, :default => false, :desc => "Generate generator specs"
class_option :generator_specs, type: :boolean, default: false, desc: "Generate generator specs"

def generate_generator_spec
return unless options[:generator_specs]
Expand Down
2 changes: 1 addition & 1 deletion lib/generators/rspec/helper/helper_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Rspec
module Generators
# @private
class HelperGenerator < Base
class_option :helper_specs, :type => :boolean, :default => true
class_option :helper_specs, type: :boolean, default: true

def generate_helper_spec
return unless options[:helper_specs]
Expand Down
8 changes: 4 additions & 4 deletions lib/generators/rspec/install/install_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ def copy_rails_files

def generate_rspec_init(tmpdir)
initializer = ::RSpec::Core::ProjectInitializer.new(
:destination => tmpdir,
:report_stream => StringIO.new
destination: tmpdir,
report_stream: StringIO.new
)
initializer.run

Expand All @@ -47,7 +47,7 @@ def replace_generator_command(spec_helper_path)
gsub_file spec_helper_path,
'rspec --init',
'rails generate rspec:install',
:verbose => false
verbose: false
end

def remove_warnings_configuration(spec_helper_path)
Expand All @@ -56,7 +56,7 @@ def remove_warnings_configuration(spec_helper_path)
gsub_file spec_helper_path,
/#{empty_line}(#{comment_line})+\s+config\.warnings = true\n/,
'',
:verbose => false
verbose: false
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
# You can disable this behaviour by removing the line below, and instead
# explicitly tag your specs with their type, e.g.:
#
# RSpec.describe UsersController, :type => :controller do
# RSpec.describe UsersController, type: :controller do
# # ...
# end
#
Expand Down
6 changes: 3 additions & 3 deletions lib/generators/rspec/integration/integration_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ 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"
type: :boolean,
default: true,
desc: "Generate request specs"

def generate_request_spec
return unless options[:request_specs]
Expand Down
2 changes: 1 addition & 1 deletion lib/generators/rspec/mailer/mailer_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Rspec
module Generators
# @private
class MailerGenerator < Base
argument :actions, :type => :array, :default => [], :banner => "method method"
argument :actions, type: :array, default: [], banner: "method method"

def generate_mailer_spec
template "mailer_spec.rb", File.join('spec/mailers', class_path, "#{file_name}_spec.rb")
Expand Down
8 changes: 4 additions & 4 deletions lib/generators/rspec/model/model_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ module Generators
# @private
class ModelGenerator < Base
argument :attributes,
:type => :array,
:default => [],
:banner => "field:type field:type"
class_option :fixture, :type => :boolean
type: :array,
default: [],
banner: "field:type field:type"
class_option :fixture, type: :boolean

def create_model_spec
template_file = File.join(
Expand Down
20 changes: 10 additions & 10 deletions lib/generators/rspec/scaffold/scaffold_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ module Generators
class ScaffoldGenerator < Base
include ::Rails::Generators::ResourceHelpers
source_paths << File.expand_path('../helper/templates', __dir__)
argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
argument :attributes, type: :array, default: [], banner: "field:type field:type"

class_option :orm, :desc => "ORM used to generate the controller"
class_option :template_engine, :desc => "Template engine to generate view files"
class_option :singleton, :type => :boolean, :desc => "Supply to create a singleton controller"
class_option :api, :type => :boolean, :desc => "Skip specs unnecessary for API-only apps"
class_option :orm, desc: "ORM used to generate the controller"
class_option :template_engine, desc: "Template engine to generate view files"
class_option :singleton, type: :boolean, desc: "Supply to create a singleton controller"
class_option :api, type: :boolean, desc: "Skip specs unnecessary for API-only apps"

class_option :controller_specs, :type => :boolean, :default => true, :desc => "Generate controller specs"
class_option :view_specs, :type => :boolean, :default => true, :desc => "Generate view specs"
class_option :helper_specs, :type => :boolean, :default => true, :desc => "Generate helper specs"
class_option :routing_specs, :type => :boolean, :default => true, :desc => "Generate routing specs"
class_option :controller_specs, type: :boolean, default: true, desc: "Generate controller specs"
class_option :view_specs, type: :boolean, default: true, desc: "Generate view specs"
class_option :helper_specs, type: :boolean, default: true, desc: "Generate helper specs"
class_option :routing_specs, type: :boolean, default: true, desc: "Generate routing specs"

def initialize(*args, &blk)
@generator_args = args.first
Expand Down Expand Up @@ -60,7 +60,7 @@ def generate_routing_spec
template 'routing_spec.rb', template_file
end

hook_for :integration_tool, :as => :integration
hook_for :integration_tool, as: :integration

protected

Expand Down
16 changes: 8 additions & 8 deletions lib/generators/rspec/scaffold/templates/api_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
it "returns a success response" do
<%= file_name %> = <%= class_name %>.create! valid_attributes
<% if RUBY_VERSION < '1.9.3' -%>
get :show, {:id => <%= file_name %>.to_param}, valid_session
get :show, {id: <%= file_name %>.to_param}, valid_session
<% else -%>
get :show, params: {id: <%= file_name %>.to_param}, session: valid_session
<% end -%>
Expand All @@ -73,7 +73,7 @@
it "creates a new <%= class_name %>" do
expect {
<% if RUBY_VERSION < '1.9.3' -%>
post :create, {:<%= ns_file_name %> => valid_attributes}, valid_session
post :create, {<%= ns_file_name %>: valid_attributes}, valid_session
<% else -%>
post :create, params: {<%= ns_file_name %>: valid_attributes}, session: valid_session
<% end -%>
Expand All @@ -82,7 +82,7 @@

it "renders a JSON response with the new <%= ns_file_name %>" do
<% if RUBY_VERSION < '1.9.3' -%>
post :create, {:<%= ns_file_name %> => valid_attributes}, valid_session
post :create, {<%= ns_file_name %>: valid_attributes}, valid_session
<% else %>
post :create, params: {<%= ns_file_name %>: valid_attributes}, session: valid_session
<% end -%>
Expand All @@ -95,7 +95,7 @@
context "with invalid params" do
it "renders a JSON response with errors for the new <%= ns_file_name %>" do
<% if RUBY_VERSION < '1.9.3' -%>
post :create, {:<%= ns_file_name %> => invalid_attributes}, valid_session
post :create, {<%= ns_file_name %>: invalid_attributes}, valid_session
<% else %>
post :create, params: {<%= ns_file_name %>: invalid_attributes}, session: valid_session
<% end -%>
Expand All @@ -114,7 +114,7 @@
it "updates the requested <%= ns_file_name %>" do
<%= file_name %> = <%= class_name %>.create! valid_attributes
<% if RUBY_VERSION < '1.9.3' -%>
put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => new_attributes}, valid_session
put :update, {id: <%= file_name %>.to_param, <%= ns_file_name %>: new_attributes}, valid_session
<% else -%>
put :update, params: {id: <%= file_name %>.to_param, <%= ns_file_name %>: new_attributes}, session: valid_session
<% end -%>
Expand All @@ -125,7 +125,7 @@
it "renders a JSON response with the <%= ns_file_name %>" do
<%= file_name %> = <%= class_name %>.create! valid_attributes
<% if RUBY_VERSION < '1.9.3' -%>
put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => valid_attributes}, valid_session
put :update, {id: <%= file_name %>.to_param, <%= ns_file_name %>: valid_attributes}, valid_session
<% else %>
put :update, params: {id: <%= file_name %>.to_param, <%= ns_file_name %>: valid_attributes}, session: valid_session
<% end -%>
Expand All @@ -138,7 +138,7 @@
it "renders a JSON response with errors for the <%= ns_file_name %>" do
<%= file_name %> = <%= class_name %>.create! valid_attributes
<% if RUBY_VERSION < '1.9.3' -%>
put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => invalid_attributes}, valid_session
put :update, {id: <%= file_name %>.to_param, <%= ns_file_name %>: invalid_attributes}, valid_session
<% else %>
put :update, params: {id: <%= file_name %>.to_param, <%= ns_file_name %>: invalid_attributes}, session: valid_session
<% end -%>
Expand All @@ -153,7 +153,7 @@
<%= file_name %> = <%= class_name %>.create! valid_attributes
expect {
<% if RUBY_VERSION < '1.9.3' -%>
delete :destroy, {:id => <%= file_name %>.to_param}, valid_session
delete :destroy, {id: <%= file_name %>.to_param}, valid_session
<% else -%>
delete :destroy, params: {id: <%= file_name %>.to_param}, session: valid_session
<% end -%>
Expand Down
20 changes: 10 additions & 10 deletions lib/generators/rspec/scaffold/templates/controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
it "returns a success response" do
<%= file_name %> = <%= class_name %>.create! valid_attributes
<% if Rails::VERSION::STRING < '5.0' -%>
get :show, {:id => <%= file_name %>.to_param}, valid_session
get :show, {id: <%= file_name %>.to_param}, valid_session
<% else -%>
get :show, params: {id: <%= file_name %>.to_param}, session: valid_session
<% end -%>
Expand All @@ -83,7 +83,7 @@
it "returns a success response" do
<%= file_name %> = <%= class_name %>.create! valid_attributes
<% if Rails::VERSION::STRING < '5.0' -%>
get :edit, {:id => <%= file_name %>.to_param}, valid_session
get :edit, {id: <%= file_name %>.to_param}, valid_session
<% else -%>
get :edit, params: {id: <%= file_name %>.to_param}, session: valid_session
<% end -%>
Expand All @@ -96,7 +96,7 @@
it "creates a new <%= class_name %>" do
expect {
<% if Rails::VERSION::STRING < '5.0' -%>
post :create, {:<%= ns_file_name %> => valid_attributes}, valid_session
post :create, {<%= ns_file_name %>: valid_attributes}, valid_session
<% else -%>
post :create, params: {<%= ns_file_name %>: valid_attributes}, session: valid_session
<% end -%>
Expand All @@ -105,7 +105,7 @@

it "redirects to the created <%= ns_file_name %>" do
<% if Rails::VERSION::STRING < '5.0' -%>
post :create, {:<%= ns_file_name %> => valid_attributes}, valid_session
post :create, {<%= ns_file_name %>: valid_attributes}, valid_session
<% else -%>
post :create, params: {<%= ns_file_name %>: valid_attributes}, session: valid_session
<% end -%>
Expand All @@ -116,7 +116,7 @@
context "with invalid params" do
it "returns a success response (i.e. to display the 'new' template)" do
<% if Rails::VERSION::STRING < '5.0' -%>
post :create, {:<%= ns_file_name %> => invalid_attributes}, valid_session
post :create, {<%= ns_file_name %>: invalid_attributes}, valid_session
<% else -%>
post :create, params: {<%= ns_file_name %>: invalid_attributes}, session: valid_session
<% end -%>
Expand All @@ -134,7 +134,7 @@
it "updates the requested <%= ns_file_name %>" do
<%= file_name %> = <%= class_name %>.create! valid_attributes
<% if Rails::VERSION::STRING < '5.0' -%>
put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => new_attributes}, valid_session
put :update, {id: <%= file_name %>.to_param, <%= ns_file_name %>: new_attributes}, valid_session
<% else -%>
put :update, params: {id: <%= file_name %>.to_param, <%= ns_file_name %>: new_attributes}, session: valid_session
<% end -%>
Expand All @@ -145,7 +145,7 @@
it "redirects to the <%= ns_file_name %>" do
<%= file_name %> = <%= class_name %>.create! valid_attributes
<% if Rails::VERSION::STRING < '5.0' -%>
put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => valid_attributes}, valid_session
put :update, {id: <%= file_name %>.to_param, <%= ns_file_name %>: valid_attributes}, valid_session
<% else -%>
put :update, params: {id: <%= file_name %>.to_param, <%= ns_file_name %>: valid_attributes}, session: valid_session
<% end -%>
Expand All @@ -157,7 +157,7 @@
it "returns a success response (i.e. to display the 'edit' template)" do
<%= file_name %> = <%= class_name %>.create! valid_attributes
<% if Rails::VERSION::STRING < '5.0' -%>
put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => invalid_attributes}, valid_session
put :update, {id: <%= file_name %>.to_param, <%= ns_file_name %>: invalid_attributes}, valid_session
<% else -%>
put :update, params: {id: <%= file_name %>.to_param, <%= ns_file_name %>: invalid_attributes}, session: valid_session
<% end -%>
Expand All @@ -171,7 +171,7 @@
<%= file_name %> = <%= class_name %>.create! valid_attributes
expect {
<% if Rails::VERSION::STRING < '5.0' -%>
delete :destroy, {:id => <%= file_name %>.to_param}, valid_session
delete :destroy, {id: <%= file_name %>.to_param}, valid_session
<% else -%>
delete :destroy, params: {id: <%= file_name %>.to_param}, session: valid_session
<% end -%>
Expand All @@ -181,7 +181,7 @@
it "redirects to the <%= table_name %> list" do
<%= file_name %> = <%= class_name %>.create! valid_attributes
<% if Rails::VERSION::STRING < '5.0' -%>
delete :destroy, {:id => <%= file_name %>.to_param}, valid_session
delete :destroy, {id: <%= file_name %>.to_param}, valid_session
<% else -%>
delete :destroy, params: {id: <%= file_name %>.to_param}, session: valid_session
<% end -%>
Expand Down
2 changes: 1 addition & 1 deletion lib/generators/rspec/scaffold/templates/edit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
before(:each) do
@<%= ns_file_name %> = assign(:<%= ns_file_name %>, <%= class_name %>.create!(<%= '))' if output_attributes.empty? %>
<% output_attributes.each_with_index do |attribute, attribute_index| -%>
:<%= attribute.name %> => <%= attribute.default.inspect %><%= attribute_index == output_attributes.length - 1 ? '' : ','%>
<%= attribute.name %>: <%= attribute.default.inspect %><%= attribute_index == output_attributes.length - 1 ? '' : ','%>
<% end -%>
<%= output_attributes.empty? ? "" : " ))\n" -%>
end
Expand Down
4 changes: 2 additions & 2 deletions lib/generators/rspec/scaffold/templates/index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<% [1,2].each_with_index do |id, model_index| -%>
<%= class_name %>.create!(<%= output_attributes.empty? ? (model_index == 1 ? ')' : '),') : '' %>
<% output_attributes.each_with_index do |attribute, attribute_index| -%>
:<%= attribute.name %> => <%= value_for(attribute) %><%= attribute_index == output_attributes.length - 1 ? '' : ','%>
<%= attribute.name %>: <%= value_for(attribute) %><%= attribute_index == output_attributes.length - 1 ? '' : ','%>
<% end -%>
<% if !output_attributes.empty? -%>
<%= model_index == 1 ? ')' : '),' %>
Expand All @@ -19,7 +19,7 @@
it "renders a list of <%= ns_table_name %>" do
render
<% for attribute in output_attributes -%>
assert_select "tr>td", :text => <%= value_for(attribute) %>.to_s, :count => 2
assert_select "tr>td", text: <%= value_for(attribute) %>.to_s, :count => 2
<% end -%>
end
end
2 changes: 1 addition & 1 deletion lib/generators/rspec/scaffold/templates/new_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
before(:each) do
assign(:<%= ns_file_name %>, <%= class_name %>.new(<%= '))' if output_attributes.empty? %>
<% output_attributes.each_with_index do |attribute, attribute_index| -%>
:<%= attribute.name %> => <%= attribute.default.inspect %><%= attribute_index == output_attributes.length - 1 ? '' : ','%>
<%= attribute.name %>: <%= attribute.default.inspect %><%= attribute_index == output_attributes.length - 1 ? '' : ','%>
<% end -%>
<%= !output_attributes.empty? ? " ))\n end" : " end" %>

Expand Down
Loading