rspec-rails 4.0.0.beta3 → 4.0.0.beta4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/Capybara.md +1 -1
  5. data/Changelog.md +48 -12
  6. data/README.md +3 -4
  7. data/lib/generators/rspec.rb +0 -6
  8. data/lib/generators/rspec/controller/controller_generator.rb +13 -5
  9. data/lib/generators/rspec/controller/templates/request_spec.rb +14 -0
  10. data/lib/generators/rspec/controller/templates/routing_spec.rb +1 -1
  11. data/lib/generators/rspec/feature/feature_generator.rb +2 -2
  12. data/lib/generators/rspec/generators/generator_generator.rb +1 -1
  13. data/lib/generators/rspec/helper/helper_generator.rb +1 -1
  14. data/lib/generators/rspec/install/install_generator.rb +4 -4
  15. data/lib/generators/rspec/install/templates/spec/rails_helper.rb +2 -15
  16. data/lib/generators/rspec/integration/integration_generator.rb +3 -3
  17. data/lib/generators/rspec/mailer/mailer_generator.rb +1 -1
  18. data/lib/generators/rspec/model/model_generator.rb +4 -4
  19. data/lib/generators/rspec/scaffold/scaffold_generator.rb +10 -10
  20. data/lib/generators/rspec/scaffold/templates/api_controller_spec.rb +0 -36
  21. data/lib/generators/rspec/scaffold/templates/controller_spec.rb +10 -10
  22. data/lib/generators/rspec/scaffold/templates/edit_spec.rb +1 -1
  23. data/lib/generators/rspec/scaffold/templates/index_spec.rb +2 -2
  24. data/lib/generators/rspec/scaffold/templates/new_spec.rb +1 -1
  25. data/lib/generators/rspec/scaffold/templates/routing_spec.rb +8 -10
  26. data/lib/generators/rspec/scaffold/templates/show_spec.rb +1 -1
  27. data/lib/generators/rspec/system/system_generator.rb +1 -1
  28. data/lib/generators/rspec/view/view_generator.rb +2 -2
  29. data/lib/rspec-rails.rb +4 -7
  30. data/lib/rspec/rails/adapters.rb +8 -74
  31. data/lib/rspec/rails/configuration.rb +32 -32
  32. data/lib/rspec/rails/example/controller_example_group.rb +4 -4
  33. data/lib/rspec/rails/example/feature_example_group.rb +5 -7
  34. data/lib/rspec/rails/example/helper_example_group.rb +2 -10
  35. data/lib/rspec/rails/example/rails_example_group.rb +1 -1
  36. data/lib/rspec/rails/example/system_example_group.rb +6 -3
  37. data/lib/rspec/rails/example/view_example_group.rb +38 -48
  38. data/lib/rspec/rails/extensions/active_record/proxy.rb +1 -9
  39. data/lib/rspec/rails/feature_check.rb +1 -28
  40. data/lib/rspec/rails/fixture_file_upload_support.rb +1 -1
  41. data/lib/rspec/rails/fixture_support.rb +8 -13
  42. data/lib/rspec/rails/matchers/action_cable.rb +1 -1
  43. data/lib/rspec/rails/matchers/active_job.rb +124 -14
  44. data/lib/rspec/rails/matchers/base_matcher.rb +4 -10
  45. data/lib/rspec/rails/matchers/have_enqueued_mail.rb +5 -2
  46. data/lib/rspec/rails/matchers/have_http_status.rb +7 -7
  47. data/lib/rspec/rails/matchers/routing_matchers.rb +10 -10
  48. data/lib/rspec/rails/tasks/rspec.rake +3 -13
  49. data/lib/rspec/rails/vendor/capybara.rb +10 -10
  50. data/lib/rspec/rails/version.rb +1 -1
  51. data/lib/rspec/rails/view_path_builder.rb +1 -1
  52. data/lib/rspec/rails/view_rendering.rb +3 -3
  53. metadata +16 -17
  54. metadata.gz.sig +0 -0
  55. data/lib/generators/rspec/observer/observer_generator.rb +0 -13
  56. data/lib/generators/rspec/observer/templates/observer_spec.rb +0 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4ae59820fb98850c1f67442c749ce42e76895fca3a17f952ac36d752903fd986
4
- data.tar.gz: 713bb7441b6d66036dc73f2f9fa448419390627890ab0bf6a535c84800758939
3
+ metadata.gz: 51903b359e44b4d8c3323a4af3caa9de3495e02009b61da605af24d7ae588b0b
4
+ data.tar.gz: 11e9ff4ad45a88a32e9f0a4294cd6c8f7c75febd5ba07c1382fed86ebdcd64aa
5
5
  SHA512:
6
- metadata.gz: 691dc937903a8aaac3e23feff435710e521082a0ace9bddc00cba9bd9ecb52610104b66458c900ababcf19a74e341affa78c109eb589faa7c25f7320db82954a
7
- data.tar.gz: 56d7c5dbd4a1e437f5f011274f084a6e1a835b0795d369fe56e53b993dbf4a199067b96f73e2ae2aad7b6c556ee6dcb6b24cd46fd12a967bfe15e50450367bce
6
+ metadata.gz: 8e9b40e1404bb29508e00c460db05b7d499ca86daa332cbe3e517dfd922ec860302023e6f71e15e7445f07c7eb39979306cd98ef296b7794ae2c87e3d5865b59
7
+ data.tar.gz: bb8b7f0411f6d1eff0550b952117bbd58aa59ca082c54d2a145e808fc14a400de0885bb8a8b5503b04baef787527b50a08054e471444123e433d3138c8b45fe1
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -73,5 +73,5 @@ behavior and accepting the risks associated with doing so:
73
73
 
74
74
  # not recommended!
75
75
  RSpec.configure do |c|
76
- c.include Capybara::DSL, :file_path => "spec/requests"
76
+ c.include Capybara::DSL, file_path: "spec/requests"
77
77
  end
@@ -1,9 +1,28 @@
1
- ### Development
2
- [Full Changelog](https://github.com/rspec/rspec-rails/compare/v3.9.0...master)
1
+ ### 4.0.0.beta4
2
+ [Full Changelog](https://github.com/rspec/rspec-rails/compare/v4.0.0.beta3...v4.0.0.beta4)
3
+
4
+ Enhancements:
5
+
6
+ * Add argument matcher support to `have_enqueued_*` matchers. (Phil Pirozhkov, #2206)
7
+ * Switch generated templates to use ruby 1.9 hash keys. (Tanbir Hasan, #2224)
8
+ * Add `have_been_performed`/`have_performed_job`/`perform_job` ActiveJob
9
+ matchers (Isaac Seymour, #1785)
10
+ * Default to generating request specs rather than controller specs when
11
+ generating a controller (Luka Lüdicke, #2222)
12
+
13
+ Bug Fixes:
14
+
15
+ * Prevent `driven_by(:selenium)` being called due to hook precedence.
16
+ (Takumi Shotoku, #2188)
17
+ * Prevent a `WrongScopeError` being thrown during loading fixtures on Rails
18
+ 6.1 development version. (Edouard Chin, #2215)
19
+ * Fix Mocha mocking support with `should`. (Phil Pirozhkov, #2256)
20
+
21
+ ### 4.0.0.beta3
22
+ [Full Changelog](https://github.com/rspec/rspec-rails/compare/v4.0.0.beta2...v4.0.0.beta3)
3
23
 
4
24
  Enhancements:
5
25
 
6
- * Adds support for Rails 6. (Penelope Phippen, Benoit Tigeot, Jon Rowe, #2071)
7
26
  * Adds support for JRuby on Rails 5.2 and 6
8
27
  * Add support for parameterised mailers (Ignatius Reza, #2125)
9
28
  * Add ActionMailbox spec helpers and test type (James Dabbs, #2119)
@@ -17,17 +36,34 @@ Enhancements:
17
36
 
18
37
  Bug Fixes:
19
38
 
39
+ * Replace `before_teardown` as well as `after_teardown` to ensure screenshots
40
+ are generated correctly. (Jon Rowe, #2164)
41
+ * `ActionView::FixtureResolver#hash` has been renamed to `ActionView::FixtureResolver#data`.
42
+ (Penelope Phippen, #2076)
43
+ * Add missing require for `have_enqueued_mail` matcher. (Ignatius Reza, #2117)
44
+
45
+ ### 4.0.0.beta2
46
+ [Full Changelog](https://github.com/rspec/rspec-rails/compare/v4.0.0.beta1...v4.0.0.beta2)
47
+
48
+ Bug Fixes:
49
+
50
+ * Fix version dependencies in gemspec.
51
+
52
+ ### 4.0.0.beta1
53
+ [Full Changelog](https://github.com/rspec/rspec-rails/compare/v3.9.0...v4.0.0.beta1)
54
+
55
+ Enhancements:
56
+
57
+ * Adds support for Rails 6. (Penelope Phippen, Benoit Tigeot, Jon Rowe, #2071)
58
+
59
+ Bug Fixes:
60
+
20
61
  * `EmptyTemplateHandler.call` now needs to support an additional argument in
21
62
  Rails 6. (Pavel Rosický, #2089)
22
63
  * Suppress warning from `SQLite3Adapter.represent_boolean_as_integer` which is
23
64
  deprecated. (Pavel Rosický, #2092)
24
65
  * `ActionView::Template#formats` has been deprecated and replaced by
25
66
  `ActionView::Template#format`(Seb Jacobs, #2100)
26
- * Replace `before_teardown` as well as `after_teardown` to ensure screenshots
27
- are generated correctly. (Jon Rowe, #2164)
28
- * `ActionView::FixtureResolver#hash` has been renamed to `ActionView::FixtureResolver#data`.
29
- (Penelope Phippen, #2076)
30
- * Add missing require for `have_enqueued_mail` matcher. (Ignatius Reza, #2117)
31
67
 
32
68
  Breaking Changes:
33
69
 
@@ -341,10 +377,10 @@ Enhancements:
341
377
  * Improve controller and routing spec calls to `routes` by using `yield`
342
378
  instead of `call`. (Anton Davydov, #1308)
343
379
  * Add support for `ActiveJob` specs as standard `RSpec::Rails::RailsExampleGoup`s
344
- via both `:type => :job` and inferring type from spec directory `spec/jobs`.
380
+ via both `type: :job` and inferring type from spec directory `spec/jobs`.
345
381
  (Gabe Martin-Dempesy, #1361)
346
382
  * Include `RSpec::Rails::FixtureSupport` into example groups using metadata
347
- `:use_fixtures => true`. (Aaron Kromer, #1372)
383
+ `use_fixtures: true`. (Aaron Kromer, #1372)
348
384
  * Include `rspec:request` generator for generating request specs; this is an
349
385
  alias of `rspec:integration` (Aaron Kromer, #1378)
350
386
  * Update `rails_helper` generator with a default check to abort the spec run
@@ -485,7 +521,7 @@ Enhancements:
485
521
  Bug Fixes:
486
522
 
487
523
  * Fix an inconsistency in the generated scaffold specs for a controller. (Andy Waite)
488
- * Ensure `config.before(:all, :type => <type>)` hooks run before groups
524
+ * Ensure `config.before(:all, type: <type>)` hooks run before groups
489
525
  of the given type, even when the type is inferred by the file
490
526
  location. (Jon Rowe, Myron Marston)
491
527
  * Switch to parsing params with `Rack::Utils::parse_nested_query` to match Rails.
@@ -935,7 +971,7 @@ This release is compatible with rails-3.1.0.rc1, but not rails-3.1.0.beta1
935
971
  * Enhancements
936
972
  * include ApplicationHelper in helper object in helper specs
937
973
  * include request spec extensions in files in spec/integration
938
- * include controller spec extensions in groups that use :type => :controller
974
+ * include controller spec extensions in groups that use type: :controller
939
975
  * same for :model, :view, :helper, :mailer, :request, :routing
940
976
 
941
977
  * Bug fixes
data/README.md CHANGED
@@ -28,14 +28,14 @@ Use **[`rspec-rails` 1.x][]** for Rails 2.x.
28
28
  ```ruby
29
29
  # Run against the latest stable release
30
30
  group :development, :test do
31
- gem 'rspec-rails', '~> 3.8'
31
+ gem 'rspec-rails', '~> 4.0'
32
32
  end
33
33
 
34
34
  # Or, run against the master branch
35
35
  # (requires master-branch versions of all related RSpec libraries)
36
36
  group :development, :test do
37
37
  %w[rspec-core rspec-expectations rspec-mocks rspec-rails rspec-support].each do |lib|
38
- gem lib, :git => "https://github.com/rspec/#{lib}.git", :branch => 'master'
38
+ gem lib, git: "https://github.com/rspec/#{lib}.git", branch: 'master'
39
39
  end
40
40
  end
41
41
  ```
@@ -119,8 +119,7 @@ $ bundle exec rspec --help
119
119
  ```
120
120
 
121
121
  **Optional:** If `bundle exec rspec` is too verbose for you,
122
- you can generate a binstub at `bin/rspec`
123
- and use that instead (Rails 4+ only):
122
+ you can generate a binstub at `bin/rspec` and use that instead:
124
123
 
125
124
  ```sh
126
125
  $ bundle binstubs rspec-core
@@ -18,12 +18,6 @@ module Rspec
18
18
  @_rspec_source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'rspec', generator_name, 'templates'))
19
19
  end
20
20
  end
21
-
22
- if ::Rails::VERSION::STRING < '3.1'
23
- def module_namespacing
24
- yield if block_given?
25
- end
26
- end
27
21
  end
28
22
  end
29
23
  end
@@ -4,12 +4,20 @@ module Rspec
4
4
  module Generators
5
5
  # @private
6
6
  class ControllerGenerator < Base
7
- argument :actions, :type => :array, :default => [], :banner => "action action"
7
+ argument :actions, type: :array, default: [], banner: "action action"
8
8
 
9
- class_option :template_engine, :desc => "Template engine to generate view files"
10
- class_option :controller_specs, :type => :boolean, :default => true, :desc => "Generate controller specs"
11
- class_option :view_specs, :type => :boolean, :default => true, :desc => "Generate view specs"
12
- class_option :routing_specs, :type => :boolean, :default => false, :desc => "Generate routing specs"
9
+ class_option :template_engine, desc: "Template engine to generate view files"
10
+ class_option :request_specs, type: :boolean, default: true, desc: "Generate request specs"
11
+ class_option :controller_specs, type: :boolean, default: false, desc: "Generate controller specs"
12
+ class_option :view_specs, type: :boolean, default: true, desc: "Generate view specs"
13
+ class_option :routing_specs, type: :boolean, default: false, desc: "Generate routing specs"
14
+
15
+ def generate_request_spec
16
+ return unless options[:request_specs]
17
+
18
+ template 'request_spec.rb',
19
+ File.join('spec/requests', class_path, "#{file_name}_request_spec.rb")
20
+ end
13
21
 
14
22
  def generate_controller_spec
15
23
  return unless options[:controller_specs]
@@ -0,0 +1,14 @@
1
+ require 'rails_helper'
2
+
3
+ RSpec.describe "<%= class_name.pluralize %>", <%= type_metatag(:request) %> do
4
+ <% namespaced_path = regular_class_path.join('/') %>
5
+ <% for action in actions -%>
6
+ describe "GET /<%= action %>" do
7
+ it "returns http success" do
8
+ get "<%= "/#{namespaced_path}" if namespaced_path != '' %>/<%= file_name %>/<%= action %>"
9
+ expect(response).to have_http_status(:success)
10
+ end
11
+ end
12
+
13
+ <% end -%>
14
+ end
@@ -5,7 +5,7 @@ RSpec.describe '<%= class_name %>Controller', <%= type_metatag(:routing) %> do
5
5
  describe 'routing' do
6
6
  <% for action in actions -%>
7
7
  it 'routes to #<%= action %>' do
8
- expect(:get => "/<%= class_name.underscore %>/<%= action %>").to route_to("<%= class_name.underscore %>#<%= action %>")
8
+ expect(get: "/<%= class_name.underscore %>/<%= action %>").to route_to("<%= class_name.underscore %>#<%= action %>")
9
9
  end
10
10
  <% end -%>
11
11
  end
@@ -4,8 +4,8 @@ module Rspec
4
4
  module Generators
5
5
  # @private
6
6
  class FeatureGenerator < Base
7
- class_option :feature_specs, :type => :boolean, :default => true, :desc => "Generate feature specs"
8
- class_option :singularize, :type => :boolean, :default => false, :desc => "Singularize the generated feature"
7
+ class_option :feature_specs, type: :boolean, default: true, desc: "Generate feature specs"
8
+ class_option :singularize, type: :boolean, default: false, desc: "Singularize the generated feature"
9
9
 
10
10
  def generate_feature_spec
11
11
  return unless options[:feature_specs]
@@ -4,7 +4,7 @@ module Rspec
4
4
  module Generators
5
5
  # @private
6
6
  class GeneratorsGenerator < Base
7
- class_option :generator_specs, :type => :boolean, :default => false, :desc => "Generate generator specs"
7
+ class_option :generator_specs, type: :boolean, default: false, desc: "Generate generator specs"
8
8
 
9
9
  def generate_generator_spec
10
10
  return unless options[:generator_specs]
@@ -4,7 +4,7 @@ module Rspec
4
4
  module Generators
5
5
  # @private
6
6
  class HelperGenerator < Base
7
- class_option :helper_specs, :type => :boolean, :default => true
7
+ class_option :helper_specs, type: :boolean, default: true
8
8
 
9
9
  def generate_helper_spec
10
10
  return unless options[:helper_specs]
@@ -32,8 +32,8 @@ DESC
32
32
 
33
33
  def generate_rspec_init(tmpdir)
34
34
  initializer = ::RSpec::Core::ProjectInitializer.new(
35
- :destination => tmpdir,
36
- :report_stream => StringIO.new
35
+ destination: tmpdir,
36
+ report_stream: StringIO.new
37
37
  )
38
38
  initializer.run
39
39
 
@@ -47,7 +47,7 @@ DESC
47
47
  gsub_file spec_helper_path,
48
48
  'rspec --init',
49
49
  'rails generate rspec:install',
50
- :verbose => false
50
+ verbose: false
51
51
  end
52
52
 
53
53
  def remove_warnings_configuration(spec_helper_path)
@@ -56,7 +56,7 @@ DESC
56
56
  gsub_file spec_helper_path,
57
57
  /#{empty_line}(#{comment_line})+\s+config\.warnings = true\n/,
58
58
  '',
59
- :verbose => false
59
+ verbose: false
60
60
  end
61
61
  end
62
62
  end
@@ -1,11 +1,7 @@
1
1
  # This file is copied to spec/ when you run 'rails generate rspec:install'
2
2
  require 'spec_helper'
3
3
  ENV['RAILS_ENV'] ||= 'test'
4
- <% if RUBY_VERSION >= '2.0.0' %>
5
4
  require File.expand_path('../config/environment', __dir__)
6
- <% else %>
7
- require File.expand_path('../../config/environment', __FILE__)
8
- <% end %>
9
5
  # Prevent database truncation if the environment is production
10
6
  abort("The Rails environment is running in production mode!") if Rails.env.production?
11
7
  require 'rspec/rails'
@@ -26,7 +22,7 @@ require 'rspec/rails'
26
22
  #
27
23
  # Dir[Rails.root.join('spec', 'support', '**', '*.rb')].each { |f| require f }
28
24
 
29
- <% if RSpec::Rails::FeatureCheck.can_maintain_test_schema? -%>
25
+ <% if RSpec::Rails::FeatureCheck.has_active_record_migration? -%>
30
26
  # Checks for pending migrations and applies them before tests are run.
31
27
  # If you are not using ActiveRecord, you can remove these lines.
32
28
  begin
@@ -35,15 +31,6 @@ rescue ActiveRecord::PendingMigrationError => e
35
31
  puts e.to_s.strip
36
32
  exit 1
37
33
  end
38
- <% elsif RSpec::Rails::FeatureCheck.can_check_pending_migrations? -%>
39
- # Checks for pending migrations before tests are run.
40
- # If you are not using ActiveRecord, you can remove these lines.
41
- begin
42
- ActiveRecord::Migration.check_pending!
43
- rescue ActiveRecord::PendingMigrationError => e
44
- puts e.to_s.strip
45
- exit 1
46
- end
47
34
  <% end -%>
48
35
  RSpec.configure do |config|
49
36
  <% if RSpec::Rails::FeatureCheck.has_active_record? -%>
@@ -63,7 +50,7 @@ RSpec.configure do |config|
63
50
  # You can disable this behaviour by removing the line below, and instead
64
51
  # explicitly tag your specs with their type, e.g.:
65
52
  #
66
- # RSpec.describe UsersController, :type => :controller do
53
+ # RSpec.describe UsersController, type: :controller do
67
54
  # # ...
68
55
  # end
69
56
  #
@@ -7,9 +7,9 @@ module Rspec
7
7
  # Add a deprecation for this class, before rspec-rails 4, to use the
8
8
  # `RequestGenerator` instead
9
9
  class_option :request_specs,
10
- :type => :boolean,
11
- :default => true,
12
- :desc => "Generate request specs"
10
+ type: :boolean,
11
+ default: true,
12
+ desc: "Generate request specs"
13
13
 
14
14
  def generate_request_spec
15
15
  return unless options[:request_specs]
@@ -5,7 +5,7 @@ module Rspec
5
5
  module Generators
6
6
  # @private
7
7
  class MailerGenerator < Base
8
- argument :actions, :type => :array, :default => [], :banner => "method method"
8
+ argument :actions, type: :array, default: [], banner: "method method"
9
9
 
10
10
  def generate_mailer_spec
11
11
  template "mailer_spec.rb", File.join('spec/mailers', class_path, "#{file_name}_spec.rb")
@@ -5,10 +5,10 @@ module Rspec
5
5
  # @private
6
6
  class ModelGenerator < Base
7
7
  argument :attributes,
8
- :type => :array,
9
- :default => [],
10
- :banner => "field:type field:type"
11
- class_option :fixture, :type => :boolean
8
+ type: :array,
9
+ default: [],
10
+ banner: "field:type field:type"
11
+ class_option :fixture, type: :boolean
12
12
 
13
13
  def create_model_spec
14
14
  template_file = File.join(
@@ -7,17 +7,17 @@ module Rspec
7
7
  class ScaffoldGenerator < Base
8
8
  include ::Rails::Generators::ResourceHelpers
9
9
  source_paths << File.expand_path('../helper/templates', __dir__)
10
- argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
10
+ argument :attributes, type: :array, default: [], banner: "field:type field:type"
11
11
 
12
- class_option :orm, :desc => "ORM used to generate the controller"
13
- class_option :template_engine, :desc => "Template engine to generate view files"
14
- class_option :singleton, :type => :boolean, :desc => "Supply to create a singleton controller"
15
- class_option :api, :type => :boolean, :desc => "Skip specs unnecessary for API-only apps"
12
+ class_option :orm, desc: "ORM used to generate the controller"
13
+ class_option :template_engine, desc: "Template engine to generate view files"
14
+ class_option :singleton, type: :boolean, desc: "Supply to create a singleton controller"
15
+ class_option :api, type: :boolean, desc: "Skip specs unnecessary for API-only apps"
16
16
 
17
- class_option :controller_specs, :type => :boolean, :default => true, :desc => "Generate controller specs"
18
- class_option :view_specs, :type => :boolean, :default => true, :desc => "Generate view specs"
19
- class_option :helper_specs, :type => :boolean, :default => true, :desc => "Generate helper specs"
20
- class_option :routing_specs, :type => :boolean, :default => true, :desc => "Generate routing specs"
17
+ class_option :controller_specs, type: :boolean, default: true, desc: "Generate controller specs"
18
+ class_option :view_specs, type: :boolean, default: true, desc: "Generate view specs"
19
+ class_option :helper_specs, type: :boolean, default: true, desc: "Generate helper specs"
20
+ class_option :routing_specs, type: :boolean, default: true, desc: "Generate routing specs"
21
21
 
22
22
  def initialize(*args, &blk)
23
23
  @generator_args = args.first
@@ -60,7 +60,7 @@ module Rspec
60
60
  template 'routing_spec.rb', template_file
61
61
  end
62
62
 
63
- hook_for :integration_tool, :as => :integration
63
+ hook_for :integration_tool, as: :integration
64
64
 
65
65
  protected
66
66
 
@@ -46,11 +46,7 @@ RSpec.describe <%= controller_class_name %>Controller, <%= type_metatag(:control
46
46
  describe "GET #index" do
47
47
  it "returns a success response" do
48
48
  <%= file_name %> = <%= class_name %>.create! valid_attributes
49
- <% if RUBY_VERSION < '1.9.3' -%>
50
- get :index, {}, valid_session
51
- <% else -%>
52
49
  get :index, params: {}, session: valid_session
53
- <% end -%>
54
50
  expect(response).to be_successful
55
51
  end
56
52
  end
@@ -59,11 +55,7 @@ RSpec.describe <%= controller_class_name %>Controller, <%= type_metatag(:control
59
55
  describe "GET #show" do
60
56
  it "returns a success response" do
61
57
  <%= file_name %> = <%= class_name %>.create! valid_attributes
62
- <% if RUBY_VERSION < '1.9.3' -%>
63
- get :show, {:id => <%= file_name %>.to_param}, valid_session
64
- <% else -%>
65
58
  get :show, params: {id: <%= file_name %>.to_param}, session: valid_session
66
- <% end -%>
67
59
  expect(response).to be_successful
68
60
  end
69
61
  end
@@ -72,20 +64,12 @@ RSpec.describe <%= controller_class_name %>Controller, <%= type_metatag(:control
72
64
  context "with valid params" do
73
65
  it "creates a new <%= class_name %>" do
74
66
  expect {
75
- <% if RUBY_VERSION < '1.9.3' -%>
76
- post :create, {:<%= ns_file_name %> => valid_attributes}, valid_session
77
- <% else -%>
78
67
  post :create, params: {<%= ns_file_name %>: valid_attributes}, session: valid_session
79
- <% end -%>
80
68
  }.to change(<%= class_name %>, :count).by(1)
81
69
  end
82
70
 
83
71
  it "renders a JSON response with the new <%= ns_file_name %>" do
84
- <% if RUBY_VERSION < '1.9.3' -%>
85
- post :create, {:<%= ns_file_name %> => valid_attributes}, valid_session
86
- <% else %>
87
72
  post :create, params: {<%= ns_file_name %>: valid_attributes}, session: valid_session
88
- <% end -%>
89
73
  expect(response).to have_http_status(:created)
90
74
  expect(response.content_type).to eq('application/json')
91
75
  expect(response.location).to eq(<%= ns_file_name %>_url(<%= class_name %>.last))
@@ -94,11 +78,7 @@ RSpec.describe <%= controller_class_name %>Controller, <%= type_metatag(:control
94
78
 
95
79
  context "with invalid params" do
96
80
  it "renders a JSON response with errors for the new <%= ns_file_name %>" do
97
- <% if RUBY_VERSION < '1.9.3' -%>
98
- post :create, {:<%= ns_file_name %> => invalid_attributes}, valid_session
99
- <% else %>
100
81
  post :create, params: {<%= ns_file_name %>: invalid_attributes}, session: valid_session
101
- <% end -%>
102
82
  expect(response).to have_http_status(:unprocessable_entity)
103
83
  expect(response.content_type).to eq('application/json')
104
84
  end
@@ -113,22 +93,14 @@ RSpec.describe <%= controller_class_name %>Controller, <%= type_metatag(:control
113
93
 
114
94
  it "updates the requested <%= ns_file_name %>" do
115
95
  <%= file_name %> = <%= class_name %>.create! valid_attributes
116
- <% if RUBY_VERSION < '1.9.3' -%>
117
- put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => new_attributes}, valid_session
118
- <% else -%>
119
96
  put :update, params: {id: <%= file_name %>.to_param, <%= ns_file_name %>: new_attributes}, session: valid_session
120
- <% end -%>
121
97
  <%= file_name %>.reload
122
98
  skip("Add assertions for updated state")
123
99
  end
124
100
 
125
101
  it "renders a JSON response with the <%= ns_file_name %>" do
126
102
  <%= file_name %> = <%= class_name %>.create! valid_attributes
127
- <% if RUBY_VERSION < '1.9.3' -%>
128
- put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => valid_attributes}, valid_session
129
- <% else %>
130
103
  put :update, params: {id: <%= file_name %>.to_param, <%= ns_file_name %>: valid_attributes}, session: valid_session
131
- <% end -%>
132
104
  expect(response).to have_http_status(:ok)
133
105
  expect(response.content_type).to eq('application/json')
134
106
  end
@@ -137,11 +109,7 @@ RSpec.describe <%= controller_class_name %>Controller, <%= type_metatag(:control
137
109
  context "with invalid params" do
138
110
  it "renders a JSON response with errors for the <%= ns_file_name %>" do
139
111
  <%= file_name %> = <%= class_name %>.create! valid_attributes
140
- <% if RUBY_VERSION < '1.9.3' -%>
141
- put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => invalid_attributes}, valid_session
142
- <% else %>
143
112
  put :update, params: {id: <%= file_name %>.to_param, <%= ns_file_name %>: invalid_attributes}, session: valid_session
144
- <% end -%>
145
113
  expect(response).to have_http_status(:unprocessable_entity)
146
114
  expect(response.content_type).to eq('application/json')
147
115
  end
@@ -152,11 +120,7 @@ RSpec.describe <%= controller_class_name %>Controller, <%= type_metatag(:control
152
120
  it "destroys the requested <%= ns_file_name %>" do
153
121
  <%= file_name %> = <%= class_name %>.create! valid_attributes
154
122
  expect {
155
- <% if RUBY_VERSION < '1.9.3' -%>
156
- delete :destroy, {:id => <%= file_name %>.to_param}, valid_session
157
- <% else -%>
158
123
  delete :destroy, params: {id: <%= file_name %>.to_param}, session: valid_session
159
- <% end -%>
160
124
  }.to change(<%= class_name %>, :count).by(-1)
161
125
  end
162
126
  end