rspec-rails 3.0.0.rc1 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. checksums.yaml +14 -6
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/.yardopts +1 -1
  5. data/Changelog.md +19 -1
  6. data/lib/generators/rspec.rb +6 -0
  7. data/lib/generators/rspec/controller/controller_generator.rb +1 -0
  8. data/lib/generators/rspec/controller/templates/controller_spec.rb +2 -2
  9. data/lib/generators/rspec/controller/templates/view_spec.rb +2 -2
  10. data/lib/generators/rspec/feature/feature_generator.rb +1 -0
  11. data/lib/generators/rspec/feature/templates/feature_spec.rb +1 -1
  12. data/lib/generators/rspec/helper/helper_generator.rb +1 -0
  13. data/lib/generators/rspec/helper/templates/helper_spec.rb +2 -2
  14. data/lib/generators/rspec/install/install_generator.rb +24 -4
  15. data/lib/generators/rspec/install/templates/spec/{spec_helper.rb.tt → rails_helper.rb} +4 -17
  16. data/lib/generators/rspec/integration/integration_generator.rb +1 -0
  17. data/lib/generators/rspec/integration/templates/request_spec.rb +2 -2
  18. data/lib/generators/rspec/mailer/mailer_generator.rb +1 -0
  19. data/lib/generators/rspec/mailer/templates/mailer_spec.rb +2 -2
  20. data/lib/generators/rspec/model/model_generator.rb +1 -0
  21. data/lib/generators/rspec/model/templates/model_spec.rb +2 -2
  22. data/lib/generators/rspec/observer/observer_generator.rb +1 -0
  23. data/lib/generators/rspec/observer/templates/observer_spec.rb +2 -2
  24. data/lib/generators/rspec/scaffold/scaffold_generator.rb +8 -33
  25. data/lib/generators/rspec/scaffold/templates/controller_spec.rb +20 -33
  26. data/lib/generators/rspec/scaffold/templates/edit_spec.rb +2 -2
  27. data/lib/generators/rspec/scaffold/templates/index_spec.rb +2 -2
  28. data/lib/generators/rspec/scaffold/templates/new_spec.rb +2 -2
  29. data/lib/generators/rspec/scaffold/templates/routing_spec.rb +2 -2
  30. data/lib/generators/rspec/scaffold/templates/show_spec.rb +3 -3
  31. data/lib/generators/rspec/view/templates/view_spec.rb +2 -2
  32. data/lib/generators/rspec/view/view_generator.rb +1 -0
  33. data/lib/rspec-rails.rb +3 -0
  34. data/lib/rspec/rails/adapters.rb +10 -18
  35. data/lib/rspec/rails/configuration.rb +40 -14
  36. data/lib/rspec/rails/example/controller_example_group.rb +8 -6
  37. data/lib/rspec/rails/example/feature_example_group.rb +5 -0
  38. data/lib/rspec/rails/example/helper_example_group.rb +2 -1
  39. data/lib/rspec/rails/example/mailer_example_group.rb +12 -0
  40. data/lib/rspec/rails/example/model_example_group.rb +2 -0
  41. data/lib/rspec/rails/example/rails_example_group.rb +1 -0
  42. data/lib/rspec/rails/example/request_example_group.rb +2 -0
  43. data/lib/rspec/rails/example/routing_example_group.rb +3 -2
  44. data/lib/rspec/rails/example/view_example_group.rb +5 -4
  45. data/lib/rspec/rails/fixture_support.rb +4 -3
  46. data/lib/rspec/rails/matchers/be_a_new.rb +13 -12
  47. data/lib/rspec/rails/matchers/be_new_record.rb +1 -3
  48. data/lib/rspec/rails/matchers/be_valid.rb +1 -4
  49. data/lib/rspec/rails/matchers/have_rendered.rb +3 -2
  50. data/lib/rspec/rails/matchers/redirect_to.rb +3 -5
  51. data/lib/rspec/rails/matchers/routing_matchers.rb +14 -6
  52. data/lib/rspec/rails/version.rb +3 -1
  53. data/lib/rspec/rails/view_assigns.rb +17 -16
  54. data/lib/rspec/rails/view_rendering.rb +8 -3
  55. metadata +73 -67
  56. metadata.gz.sig +2 -3
  57. data/lib/generators/rspec/install/templates/.rspec +0 -1
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 7a33b97b88c1b74c6ff81f48380f86281847892a
4
- data.tar.gz: 7621acffba98290f0761567e9818300b5b7686a4
5
- SHA512:
6
- metadata.gz: a3488a19517a4b3ee09cf23bc7da4f2bd14292c4a3f15252aebd621bd8b42a94beecc83212ac95188d1c4b0acaf13c5303b9b917cad0a4aed4fbd768cad92d35
7
- data.tar.gz: 97ae5bb4223cd14bcc6357e735db57c08cd5efd2e3e4bf24ee18cae8b712b14fee57bf9cb09bb1b7f98fa31883c9f91d8db3dd34f5d046dd1951b33ca2dc0404
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZWQwZWViNzVjNjdjMDJmODRmM2FlNTIzZmM2YjNkZGEyMjc3YjRjMg==
5
+ data.tar.gz: !binary |-
6
+ ODAwMTJlMTc0Zjk1MjhjYzk4YmU4YjBiODBkMTMzOTM0ZjBmZDJkNw==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ MDMwMDMwNmE5ODQzNDVhOGZkZTAyNjhiNTJhYTkzMWE3NGY1MTBlZmU0YjM0
10
+ MGRiYWI5YjljZTE2MTY3MTU1MTNhMjk5YmU1ZTM0MDcwNmUxZmM3NTFkOWU1
11
+ YzhjMWVlMDM0YTE5YTcwMTBkMGFmYzI1ZWIxOTFjNzg3YzUxYmM=
12
+ data.tar.gz: !binary |-
13
+ OTI1ZmFmYjMwNTA0YWU3NzRjNWFkNjlkNThiYjBmYzI5MDAyYWJiYzA2Y2Y3
14
+ YTFiYzFiZjg0YWFhNTEyNWZhZDgyYTExMmFkZWE1OWQ0YmM4YTA5OGUzNjQz
15
+ MzQ0ZmVhMTVlMDQyYzBkY2JkZmQxYWYzZmZkODU4NGRkZmM3MTY=
Binary file
data.tar.gz.sig CHANGED
Binary file
data/.yardopts CHANGED
@@ -1,6 +1,6 @@
1
1
  --no-private
2
2
  --exclude features
3
- --exclude lib/generators/**/*_spec.rb
3
+ --exclude lib/generators/([^/]+/)*.*_spec.rb
4
4
  --markup markdown
5
5
  --template-path yard/template/
6
6
  -
@@ -1,3 +1,16 @@
1
+ ### 3.0.0 / 2014-06-01
2
+ [Full Changelog](http://github.com/rspec/rspec-rails/compare/v3.0.0.rc1...v3.0.0)
3
+
4
+ Enhancements:
5
+
6
+ * Separate RSpec configuration in generated `spec_helper` from Rails setup
7
+ and associated configuration options. Moving Rails specific settings and
8
+ options to `rails_helper`. (Aaron Kromer)
9
+
10
+ Bug Fixes:
11
+
12
+ * Fix an issue with fixture support when `ActiveRecord` isn't loaded. (Jon Rowe)
13
+
1
14
  ### 3.0.0.rc1 / 2014-05-18
2
15
  [Full Changelog](http://github.com/rspec/rspec-rails/compare/v3.0.0.beta2...v3.0.0.rc1)
3
16
 
@@ -63,13 +76,18 @@ Bug Fixes:
63
76
  * Require `rspec/collection_matchers` when `rspec/rails` is required. (Yuji Nakayama)
64
77
 
65
78
  ### 3.0.0.beta1 / 2013-11-07
66
- [Full Changelog](http://github.com/rspec/rspec-rails/compare/v2.99.0.rc1...v3.0.0.beta1)
79
+ [Full Changelog](http://github.com/rspec/rspec-rails/compare/v2.99.0...v3.0.0.beta1)
67
80
 
68
81
  Breaking Changes for 3.0.0:
69
82
 
70
83
  * Extracts `autotest` and `autotest-rails` support to `rspec-autotest` gem.
71
84
  (Andy Lindeman)
72
85
 
86
+ ### 2.99.0 / 2014-06-01
87
+ [Full Changelog](http://github.com/rspec/rspec-rails/compare/v2.99.0.rc1...v2.99.0)
88
+
89
+ No changes. Just taking it out of pre-release.
90
+
73
91
  ### 2.99.0.rc1 / 2014-05-18
74
92
  [Full Changelog](http://github.com/rspec/rspec-rails/compare/v2.99.0.beta2...v2.99.0.rc1)
75
93
 
@@ -1,7 +1,11 @@
1
1
  require 'rails/generators/named_base'
2
2
 
3
+ # Weirdly named generators namespace (should be `RSpec`) for compatability with
4
+ # rails loading.
3
5
  module Rspec
6
+ # @private
4
7
  module Generators
8
+ # @private
5
9
  class Base < ::Rails::Generators::NamedBase
6
10
  def self.source_root
7
11
  @_rspec_source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'rspec', generator_name, 'templates'))
@@ -16,8 +20,10 @@ module Rspec
16
20
  end
17
21
  end
18
22
 
23
+ # @private
19
24
  module Rails
20
25
  module Generators
26
+ # @private
21
27
  class GeneratedAttribute
22
28
  def input_type
23
29
  @input_type ||= if type == :text
@@ -2,6 +2,7 @@ require 'generators/rspec'
2
2
 
3
3
  module Rspec
4
4
  module Generators
5
+ # @private
5
6
  class ControllerGenerator < Base
6
7
  argument :actions, :type => :array, :default => [], :banner => "action action"
7
8
 
@@ -1,7 +1,7 @@
1
- require 'spec_helper'
1
+ require 'rails_helper'
2
2
 
3
3
  <% module_namespacing do -%>
4
- describe <%= class_name %>Controller, :type => :controller do
4
+ RSpec.describe <%= class_name %>Controller, :type => :controller do
5
5
 
6
6
  <% for action in actions -%>
7
7
  describe "GET '<%= action %>'" do
@@ -1,5 +1,5 @@
1
- require 'spec_helper'
1
+ require 'rails_helper'
2
2
 
3
- describe "<%= file_name %>/<%= @action %>.html.<%= options[:template_engine] %>", :type => :view do
3
+ RSpec.describe "<%= file_name %>/<%= @action %>.html.<%= options[:template_engine] %>", :type => :view do
4
4
  pending "add some examples to (or delete) #{__FILE__}"
5
5
  end
@@ -2,6 +2,7 @@ require 'generators/rspec'
2
2
 
3
3
  module Rspec
4
4
  module Generators
5
+ # @private
5
6
  class FeatureGenerator < Base
6
7
  class_option :feature_specs, :type => :boolean, :default => true, :desc => "Generate feature specs"
7
8
 
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require 'rails_helper'
2
2
 
3
3
  feature "<%= class_name.pluralize %>", :type => :feature do
4
4
  pending "add some scenarios (or delete) #{__FILE__}"
@@ -2,6 +2,7 @@ require 'generators/rspec'
2
2
 
3
3
  module Rspec
4
4
  module Generators
5
+ # @private
5
6
  class HelperGenerator < Base
6
7
  class_option :helper_specs, :type => :boolean, :default => true
7
8
 
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require 'rails_helper'
2
2
 
3
3
  # Specs in this file have access to a helper object that includes
4
4
  # the <%= class_name %>Helper. For example:
@@ -11,7 +11,7 @@ require 'spec_helper'
11
11
  # end
12
12
  # end
13
13
  <% module_namespacing do -%>
14
- describe <%= class_name %>Helper, :type => :helper do
14
+ RSpec.describe <%= class_name %>Helper, :type => :helper do
15
15
  pending "add some examples to (or delete) #{__FILE__}"
16
16
  end
17
17
  <% end -%>
@@ -1,5 +1,8 @@
1
+ RSpec::Support.require_rspec_core "project_initializer"
2
+
1
3
  module Rspec
2
4
  module Generators
5
+ # @private
3
6
  class InstallGenerator < ::Rails::Generators::Base
4
7
 
5
8
  desc <<DESC
@@ -11,14 +14,31 @@ DESC
11
14
  @source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
12
15
  end
13
16
 
14
- def copy_dot_rspec
15
- template '.rspec'
17
+ def copy_spec_files
18
+ Dir.mktmpdir do |dir|
19
+ generate_rspec_init dir
20
+ template File.join(dir, '.rspec'), '.rspec'
21
+ directory File.join(dir, 'spec'), 'spec'
22
+ end
16
23
  end
17
24
 
18
- def copy_spec_files
19
- directory 'spec'
25
+ def copy_rails_files
26
+ template 'spec/rails_helper.rb'
20
27
  end
21
28
 
29
+ private
30
+
31
+ def generate_rspec_init(tmpdir)
32
+ initializer = ::RSpec::Core::ProjectInitializer.new(
33
+ :destination => tmpdir,
34
+ :report_stream => StringIO.new
35
+ )
36
+ initializer.run
37
+ gsub_file File.join(tmpdir, 'spec', 'spec_helper.rb'),
38
+ 'rspec --init',
39
+ 'rails generate rspec:install',
40
+ :verbose => false
41
+ end
22
42
  end
23
43
  end
24
44
  end
@@ -1,5 +1,6 @@
1
1
  # This file is copied to spec/ when you run 'rails generate rspec:install'
2
2
  ENV["RAILS_ENV"] ||= 'test'
3
+ require 'spec_helper'
3
4
  require File.expand_path("../../config/environment", __FILE__)
4
5
  require 'rspec/rails'
5
6
 
@@ -24,14 +25,6 @@ ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
24
25
 
25
26
  <% end -%>
26
27
  RSpec.configure do |config|
27
- # ## Mock Framework
28
- #
29
- # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
30
- #
31
- # config.mock_with :mocha
32
- # config.mock_with :flexmock
33
- # config.mock_with :rr
34
-
35
28
  # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
36
29
  config.fixture_path = "#{::Rails.root}/spec/fixtures"
37
30
 
@@ -40,24 +33,18 @@ RSpec.configure do |config|
40
33
  # instead of true.
41
34
  config.use_transactional_fixtures = true
42
35
 
43
- # Run specs in random order to surface order dependencies. If you find an
44
- # order dependency and want to debug it, you can fix the order by providing
45
- # the seed, which is printed after each run.
46
- # --seed 1234
47
- config.order = "random"
48
-
49
36
  # RSpec Rails can automatically mix in different behaviours to your tests
50
37
  # based on their file location, for example enabling you to call `get` and
51
38
  # `post` in specs under `spec/controllers`.
52
39
  #
53
40
  # You can disable this behaviour by removing the line below, and instead
54
- # explictly tag your specs with their type, e.g.:
41
+ # explicitly tag your specs with their type, e.g.:
55
42
  #
56
- # describe UsersController, :type => :controller do
43
+ # RSpec.describe UsersController, :type => :controller do
57
44
  # # ...
58
45
  # end
59
46
  #
60
47
  # The different available types are documented in the features, such as in
61
- # https://relishapp.com/rspec/rspec-rails/v/3-0/docs
48
+ # https://relishapp.com/rspec/rspec-rails/docs
62
49
  config.infer_spec_type_from_file_location!
63
50
  end
@@ -2,6 +2,7 @@ require 'generators/rspec'
2
2
 
3
3
  module Rspec
4
4
  module Generators
5
+ # @private
5
6
  class IntegrationGenerator < Base
6
7
  class_option :request_specs, :type => :boolean, :default => true, :desc => "Generate request specs"
7
8
 
@@ -1,6 +1,6 @@
1
- require 'spec_helper'
1
+ require 'rails_helper'
2
2
 
3
- describe "<%= class_name.pluralize %>", :type => :request do
3
+ RSpec.describe "<%= class_name.pluralize %>", :type => :request do
4
4
  describe "GET /<%= table_name %>" do
5
5
  it "works! (now write some real specs)" do
6
6
  get <%= index_helper %>_path
@@ -2,6 +2,7 @@ require 'generators/rspec'
2
2
 
3
3
  module Rspec
4
4
  module Generators
5
+ # @private
5
6
  class MailerGenerator < Base
6
7
  argument :actions, :type => :array, :default => [], :banner => "method method"
7
8
 
@@ -1,7 +1,7 @@
1
- require "spec_helper"
1
+ require "rails_helper"
2
2
 
3
3
  <% module_namespacing do -%>
4
- describe <%= class_name %>, :type => :mailer do
4
+ RSpec.describe <%= class_name %>, :type => :mailer do
5
5
  <% for action in actions -%>
6
6
  describe "<%= action %>" do
7
7
  let(:mail) { <%= class_name %>.<%= action %> }
@@ -2,6 +2,7 @@ require 'generators/rspec'
2
2
 
3
3
  module Rspec
4
4
  module Generators
5
+ # @private
5
6
  class ModelGenerator < Base
6
7
  argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
7
8
  class_option :fixture, :type => :boolean
@@ -1,7 +1,7 @@
1
- require 'spec_helper'
1
+ require 'rails_helper'
2
2
 
3
3
  <% module_namespacing do -%>
4
- describe <%= class_name %>, :type => :model do
4
+ RSpec.describe <%= class_name %>, :type => :model do
5
5
  pending "add some examples to (or delete) #{__FILE__}"
6
6
  end
7
7
  <% end -%>
@@ -2,6 +2,7 @@ require 'generators/rspec'
2
2
 
3
3
  module Rspec
4
4
  module Generators
5
+ # @private
5
6
  class ObserverGenerator < Base
6
7
  def generate_observer_spec
7
8
  template 'observer_spec.rb',
@@ -1,7 +1,7 @@
1
- require 'spec_helper'
1
+ require 'rails_helper'
2
2
 
3
3
  <% module_namespacing do -%>
4
- describe <%= class_name %>Observer, :type => :observer do
4
+ RSpec.describe <%= class_name %>Observer, :type => :observer do
5
5
  pending "add some examples to (or delete) #{__FILE__}"
6
6
  end
7
7
  <% end -%>
@@ -3,6 +3,7 @@ require 'rails/generators/resource_helpers'
3
3
 
4
4
  module Rspec
5
5
  module Generators
6
+ # @private
6
7
  class ScaffoldGenerator < Base
7
8
  include ::Rails::Generators::ResourceHelpers
8
9
  source_paths << File.expand_path("../../helper/templates", __FILE__)
@@ -49,36 +50,6 @@ module Rspec
49
50
  File.join("spec/views", controller_file_path, "#{view}.html.#{options[:template_engine]}_spec.rb")
50
51
  end
51
52
 
52
- def example_valid_attributes
53
- # Only take the first attribute so this hash does not become unweildy and large in the
54
- # generated controller spec. It is the responsibility of the user to keep the the valid
55
- # attributes method up-to-date as they add validations.
56
- @example_valid_attributes ||=
57
- if attributes.any?
58
- { attributes.first.name => attributes.first.default.to_s }
59
- else
60
- { }
61
- end
62
- end
63
-
64
- def example_invalid_attributes
65
- @example_invalid_attributes ||=
66
- if attributes.any?
67
- { attributes.first.name => "invalid value" }
68
- else
69
- { }
70
- end
71
- end
72
-
73
- def example_params_for_update
74
- @example_params_for_update ||=
75
- if example_valid_attributes.any?
76
- example_valid_attributes
77
- else
78
- { "these" => "params" }
79
- end
80
- end
81
-
82
53
  def formatted_hash(hash)
83
54
  formatted = hash.inspect
84
55
  formatted.gsub!("{", "{ ")
@@ -164,14 +135,18 @@ module Rspec
164
135
  end
165
136
 
166
137
  def value_for(attribute)
138
+ raw_value_for(attribute).inspect
139
+ end
140
+
141
+ def raw_value_for(attribute)
167
142
  case attribute.type
168
143
  when :string
169
- "#{attribute.name.titleize}".inspect
144
+ attribute.name.titleize
170
145
  when :integer
171
146
  @attribute_id_map ||= {}
172
- @attribute_id_map[attribute] ||= @attribute_id_map.keys.size.next.to_s
147
+ @attribute_id_map[attribute] ||= @attribute_id_map.keys.size.next
173
148
  else
174
- attribute.default.inspect
149
+ attribute.default
175
150
  end
176
151
  end
177
152
 
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require 'rails_helper'
2
2
 
3
3
  # This spec was generated by rspec-rails when you ran the scaffold generator.
4
4
  # It demonstrates how one might use RSpec to specify the controller code that
@@ -19,12 +19,18 @@ require 'spec_helper'
19
19
  # that an instance is receiving a specific message.
20
20
 
21
21
  <% module_namespacing do -%>
22
- describe <%= controller_class_name %>Controller, :type => :controller do
22
+ RSpec.describe <%= controller_class_name %>Controller, :type => :controller do
23
23
 
24
24
  # This should return the minimal set of attributes required to create a valid
25
25
  # <%= class_name %>. As you add validations to <%= class_name %>, be sure to
26
26
  # adjust the attributes here as well.
27
- let(:valid_attributes) { <%= formatted_hash(example_valid_attributes) %> }
27
+ let(:valid_attributes) {
28
+ skip("Add a hash of attributes valid for your model")
29
+ }
30
+
31
+ let(:invalid_attributes) {
32
+ skip("Add a hash of attributes invalid for your model")
33
+ }
28
34
 
29
35
  # This should return the minimal set of values that should be in the session
30
36
  # in order to pass any filters (e.g. authentication) defined in
@@ -86,16 +92,12 @@ describe <%= controller_class_name %>Controller, :type => :controller do
86
92
 
87
93
  describe "with invalid params" do
88
94
  it "assigns a newly created but unsaved <%= ns_file_name %> as @<%= ns_file_name %>" do
89
- # Trigger the behavior that occurs when invalid params are submitted
90
- allow_any_instance_of(<%= class_name %>).to receive(:save).and_return(false)
91
- post :create, {:<%= ns_file_name %> => <%= formatted_hash(example_invalid_attributes) %>}, valid_session
95
+ post :create, {:<%= ns_file_name %> => invalid_attributes}, valid_session
92
96
  expect(assigns(:<%= ns_file_name %>)).to be_a_new(<%= class_name %>)
93
97
  end
94
98
 
95
99
  it "re-renders the 'new' template" do
96
- # Trigger the behavior that occurs when invalid params are submitted
97
- allow_any_instance_of(<%= class_name %>).to receive(:save).and_return(false)
98
- post :create, {:<%= ns_file_name %> => <%= formatted_hash(example_invalid_attributes) %>}, valid_session
100
+ post :create, {:<%= ns_file_name %> => invalid_attributes}, valid_session
99
101
  expect(response).to render_template("new")
100
102
  end
101
103
  end
@@ -103,18 +105,15 @@ describe <%= controller_class_name %>Controller, :type => :controller do
103
105
 
104
106
  describe "PUT update" do
105
107
  describe "with valid params" do
108
+ let(:new_attributes) {
109
+ skip("Add a hash of attributes valid for your model")
110
+ }
111
+
106
112
  it "updates the requested <%= ns_file_name %>" do
107
113
  <%= file_name %> = <%= class_name %>.create! valid_attributes
108
- # Assuming there are no other <%= table_name %> in the database, this
109
- # specifies that the <%= class_name %> created on the previous line
110
- # receives the :update_attributes message with whatever params are
111
- # submitted in the request.
112
- <%- if ::Rails::VERSION::STRING >= '4' -%>
113
- expect_any_instance_of(<%= class_name %>).to receive(:update).with(<%= formatted_hash(example_params_for_update) %>)
114
- <%- else -%>
115
- expect_any_instance_of(<%= class_name %>).to receive(:update_attributes).with(<%= formatted_hash(example_params_for_update) %>)
116
- <%- end -%>
117
- put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => <%= formatted_hash(example_params_for_update) %>}, valid_session
114
+ put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => new_attributes}, valid_session
115
+ <%= file_name %>.reload
116
+ skip("Add assertions for updated state")
118
117
  end
119
118
 
120
119
  it "assigns the requested <%= ns_file_name %> as @<%= ns_file_name %>" do
@@ -133,25 +132,13 @@ describe <%= controller_class_name %>Controller, :type => :controller do
133
132
  describe "with invalid params" do
134
133
  it "assigns the <%= ns_file_name %> as @<%= ns_file_name %>" do
135
134
  <%= file_name %> = <%= class_name %>.create! valid_attributes
136
- # Trigger the behavior that occurs when invalid params are submitted
137
- <%- if ::Rails::VERSION::STRING >= '4' -%>
138
- allow_any_instance_of(<%= class_name %>).to receive(:update).and_return(false)
139
- <%- else -%>
140
- allow_any_instance_of(<%= class_name %>).to receive(:update_attributes).and_return(false)
141
- <%- end -%>
142
- put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => <%= formatted_hash(example_invalid_attributes) %>}, valid_session
135
+ put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => invalid_attributes}, valid_session
143
136
  expect(assigns(:<%= ns_file_name %>)).to eq(<%= file_name %>)
144
137
  end
145
138
 
146
139
  it "re-renders the 'edit' template" do
147
140
  <%= file_name %> = <%= class_name %>.create! valid_attributes
148
- # Trigger the behavior that occurs when invalid params are submitted
149
- <%- if ::Rails::VERSION::STRING >= '4' -%>
150
- allow_any_instance_of(<%= class_name %>).to receive(:update).and_return(false)
151
- <%- else -%>
152
- allow_any_instance_of(<%= class_name %>).to receive(:update_attributes).and_return(false)
153
- <%- end -%>
154
- put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => <%= formatted_hash(example_invalid_attributes) %>}, valid_session
141
+ put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => invalid_attributes}, valid_session
155
142
  expect(response).to render_template("edit")
156
143
  end
157
144
  end