rails-controller-testing 0.0.3 → 1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e2ad2ead8c351b512e7ea312955992514178e426
4
- data.tar.gz: bbeca2041f158018ae7add9479fd1350de896c98
3
+ metadata.gz: c62fa8d9d566950fb4dabf54650920b31a7e255b
4
+ data.tar.gz: 328b13f082656d996ef0efa9452cd58f1b78428a
5
5
  SHA512:
6
- metadata.gz: d20f7cd4b9e9c9d5d1c6cf7feb781567db6d41d4a2554f41d230125d74dda00b1e8a059d70cc9bfed7d110500c94b3f3682f06abff49439956fad29873858314
7
- data.tar.gz: 8f6c42572deaf856083388129f5fdf089a02f21e3acc1a908ca2094701add36b15831824dde55ec2516163c673a68c96608f3b6b1e59c71def87b63483484cc4
6
+ metadata.gz: ff9b2f9b07c5b4658ecd4d39245a01e5af0fc401f58d02de7ec9791d23d9425ede8915a27572735cc0a5361b151dbe5cee2339ca913f33988dac9bed28300c39
7
+ data.tar.gz: 58cc294970673954c53aff30134b34c228eab30afd952f0469e861b7601df4dded68ce9e8dde21b49cb59df70b360a97e8e6318ac7775a4fee236b25d279e0b0
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2015-2016 Alan Guo Xiang Tan
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Rails::Controller::Testing
2
2
 
3
- [![Build Status](https://travis-ci.org/tgxworld/rails-controller-testing.svg?branch=master)](https://travis-ci.org/tgxworld/rails-controller-testing)
3
+ [![Build Status](https://travis-ci.org/rails/rails-controller-testing.svg?branch=master)](https://travis-ci.org/rails/rails-controller-testing)
4
4
  [![Gem Version](https://badge.fury.io/rb/rails-controller-testing.svg)](http://badge.fury.io/rb/rails-controller-testing)
5
5
 
6
6
  This gem brings back `assigns` to your controller tests as well as `assert_template`
@@ -23,6 +23,26 @@ Or install it yourself as:
23
23
 
24
24
  $ gem install rails-controller-testing
25
25
 
26
+ ### RSpec
27
+
28
+ See https://github.com/rspec/rspec-rails/issues/1393.
29
+
30
+ rspec-rails will automatically integrate with this gem once `3.5.0` and Rails 5 are released.
31
+ Adding the gem to your `Gemfile` is sufficient.
32
+
33
+ To work around the issue right now, use a beta version of rspec-rails or
34
+ manually you'll have to include the modules in your `rails_helper`.
35
+
36
+ ```ruby
37
+ RSpec.configure do |config|
38
+ [:controller, :view, :request].each do |type|
39
+ config.include ::Rails::Controller::Testing::TestProcess, :type => type
40
+ config.include ::Rails::Controller::Testing::TemplateAssertions, :type => type
41
+ config.include ::Rails::Controller::Testing::Integration, :type => type
42
+ end
43
+ end
44
+ ```
45
+
26
46
  ## Usage
27
47
 
28
48
  ### assigns
@@ -49,7 +69,14 @@ end
49
69
 
50
70
  `assert_template` allows to you assert that certain templates have been rendered.
51
71
 
52
- TODO: Provide examples.
72
+ ```ruby
73
+ class PostControllerTest < ActionController::TestCase
74
+ def test_index
75
+ get :index
76
+ assert_template 'posts/index'
77
+ end
78
+ end
79
+ ```
53
80
 
54
81
  ## Contributing
55
82
 
@@ -1,7 +1,7 @@
1
1
  module Rails
2
2
  module Controller
3
3
  module Testing
4
- VERSION = "0.0.3"
4
+ VERSION = "1.0.0"
5
5
  end
6
6
  end
7
7
  end
@@ -1,23 +1,22 @@
1
+ require 'active_support/lazy_load_hooks'
1
2
  require 'rails/controller/testing/test_process'
2
3
  require 'rails/controller/testing/integration'
3
4
  require 'rails/controller/testing/template_assertions'
5
+ require 'rails/controller/testing/version'
4
6
 
5
- module ActionController
6
- class TestCase
7
- include Rails::Controller::Testing::TestProcess
8
- include Rails::Controller::Testing::TemplateAssertions
9
- end
10
- end
7
+ class Rails::Controller::Testing::Railtie < Rails::Railtie
8
+ initializer "rails_controller_testing" do
9
+ ActiveSupport.on_load(:action_controller) do
10
+ ActionController::TestCase.include Rails::Controller::Testing::TestProcess
11
+ ActionController::TestCase.include Rails::Controller::Testing::TemplateAssertions
11
12
 
12
- module ActionDispatch
13
- class IntegrationTest
14
- include Rails::Controller::Testing::TemplateAssertions
15
- include Rails::Controller::Testing::Integration
16
- end
17
- end
13
+ ActionDispatch::IntegrationTest.include Rails::Controller::Testing::TemplateAssertions
14
+ ActionDispatch::IntegrationTest.include Rails::Controller::Testing::Integration
15
+ ActionDispatch::IntegrationTest.include Rails::Controller::Testing::TestProcess
16
+ end
18
17
 
19
- module ActionView
20
- class TestCase
21
- include Rails::Controller::Testing::TemplateAssertions
18
+ ActiveSupport.on_load(:action_view) do
19
+ ActionView::TestCase.include Rails::Controller::Testing::TemplateAssertions
20
+ end
22
21
  end
23
22
  end
@@ -1,5 +1,4 @@
1
1
  require 'test_helper'
2
- require 'rails-controller-testing'
3
2
 
4
3
  class AssignsControllerTest < ActionController::TestCase
5
4
  def test_assigns
@@ -1,5 +1,4 @@
1
1
  require 'test_helper'
2
- require 'rails-controller-testing'
3
2
 
4
3
  class TemplateAssertionsControllerTest < ActionController::TestCase
5
4
  def test_with_invalid_hash_keys_raises_argument_error
@@ -2,6 +2,6 @@ class AssignsController < ActionController::Base
2
2
  def test_assigns
3
3
  @foo = "foo"
4
4
  @foo_hash = { foo: :bar }
5
- render nothing: true
5
+ head :ok
6
6
  end
7
7
  end
@@ -1,7 +1,7 @@
1
1
  class ViewAssignsController < ActionController::Base
2
2
  def test_assigns
3
3
  @foo = "foo"
4
- render nothing: true
4
+ head :ok
5
5
  end
6
6
 
7
7
  def view_assigns
@@ -18,9 +18,5 @@ module Dummy
18
18
  # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
19
19
  # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
20
20
  # config.i18n.default_locale = :de
21
-
22
- # Do not swallow errors in after_commit/after_rollback callbacks.
23
- config.active_record.raise_in_transactional_callbacks = true
24
21
  end
25
22
  end
26
-
@@ -13,15 +13,9 @@ Rails.application.configure do
13
13
  config.consider_all_requests_local = true
14
14
  config.action_controller.perform_caching = false
15
15
 
16
- # Don't care if the mailer can't send.
17
- config.action_mailer.raise_delivery_errors = false
18
-
19
16
  # Print deprecation notices to the Rails logger.
20
17
  config.active_support.deprecation = :log
21
18
 
22
- # Raise an error on page load if there are pending migrations.
23
- config.active_record.migration_error = :page_load
24
-
25
19
  # Debug mode disables concatenation and preprocessing of assets.
26
20
  # This option may cause significant delays in view rendering with a large
27
21
  # number of complex assets.
@@ -12,9 +12,11 @@ Rails.application.configure do
12
12
  # preloads Rails for running tests, you may have to set it to true.
13
13
  config.eager_load = false
14
14
 
15
- # Configure static file server for tests with Cache-Control for performance.
16
- config.serve_static_files = true
17
- config.static_cache_control = 'public, max-age=3600'
15
+ # Configure public file server for tests with Cache-Control for performance.
16
+ config.public_file_server.enabled = true
17
+ config.public_file_server.headers = {
18
+ 'Cache-Control' => 'public, max-age=3600'
19
+ }
18
20
 
19
21
  # Show full error reports and disable caching.
20
22
  config.consider_all_requests_local = true
@@ -26,11 +28,6 @@ Rails.application.configure do
26
28
  # Disable request forgery protection in test environment.
27
29
  config.action_controller.allow_forgery_protection = false
28
30
 
29
- # Tell Action Mailer not to deliver emails to the real world.
30
- # The :test delivery method accumulates sent emails in the
31
- # ActionMailer::Base.deliveries array.
32
- config.action_mailer.delivery_method = :test
33
-
34
31
  # Randomize the order test cases are executed.
35
32
  config.active_support.test_order = :random
36
33
 
@@ -1,7 +1,7 @@
1
1
  # Be sure to restart your server when you modify this file.
2
2
 
3
3
  # Version of your assets, change this if you want to expire all your assets.
4
- Rails.application.config.assets.version = '1.0'
4
+ # Rails.application.config.assets.version = '1.0'
5
5
 
6
6
  # Add additional assets to the asset load path
7
7
  # Rails.application.config.assets.paths << Emoji.images_path
@@ -1,5 +1,4 @@
1
1
  require 'test_helper'
2
- require 'rails-controller-testing'
3
2
 
4
3
  class RenderTemplateTest < ActionView::TestCase
5
4
  test "supports specifying templates with a Regexp" do
data/test/test_helper.rb CHANGED
@@ -2,7 +2,6 @@
2
2
  ENV["RAILS_ENV"] = "test"
3
3
 
4
4
  require File.expand_path("../../test/dummy/config/environment.rb", __FILE__)
5
- ActiveRecord::Migrator.migrations_paths = [File.expand_path("../../test/dummy/db/migrate", __FILE__)]
6
5
  require "rails/test_help"
7
6
  require 'rails-controller-testing'
8
7
 
metadata CHANGED
@@ -1,29 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-controller-testing
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
- - Alan Guo Xiang Tan
7
+ - Rails Core Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-28 00:00:00.000000000 Z
11
+ date: 2016-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rails
14
+ name: actionpack
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '4.2'
19
+ version: 5.x
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 5.x
27
+ - !ruby/object:Gem::Dependency
28
+ name: actionview
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 5.x
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 5.x
41
+ - !ruby/object:Gem::Dependency
42
+ name: activesupport
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
25
46
  - !ruby/object:Gem::Version
26
- version: '4.2'
47
+ version: 5.x
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 5.x
55
+ - !ruby/object:Gem::Dependency
56
+ name: railties
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 5.x
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 5.x
27
69
  - !ruby/object:Gem::Dependency
28
70
  name: sqlite3
29
71
  requirement: !ruby/object:Gem::Requirement
@@ -39,12 +81,12 @@ dependencies:
39
81
  - !ruby/object:Gem::Version
40
82
  version: '0'
41
83
  description:
42
- email:
43
- - tgx_world@hotmail.com
84
+ email:
44
85
  executables: []
45
86
  extensions: []
46
87
  extra_rdoc_files: []
47
88
  files:
89
+ - LICENSE
48
90
  - README.md
49
91
  - Rakefile
50
92
  - lib/rails-controller-testing.rb
@@ -56,8 +98,6 @@ files:
56
98
  - test/controllers/template_assertions_test.rb
57
99
  - test/dummy/README.rdoc
58
100
  - test/dummy/Rakefile
59
- - test/dummy/app/assets/javascripts/application.js
60
- - test/dummy/app/assets/stylesheets/application.css
61
101
  - test/dummy/app/controllers/assigns_controller.rb
62
102
  - test/dummy/app/controllers/template_assertions_controller.rb
63
103
  - test/dummy/app/controllers/view_assigns_controller.rb
@@ -97,8 +137,6 @@ files:
97
137
  - test/dummy/config/locales/en.yml
98
138
  - test/dummy/config/routes.rb
99
139
  - test/dummy/config/secrets.yml
100
- - test/dummy/db/test.sqlite3
101
- - test/dummy/log/test.log
102
140
  - test/dummy/public/404.html
103
141
  - test/dummy/public/422.html
104
142
  - test/dummy/public/500.html
@@ -106,7 +144,7 @@ files:
106
144
  - test/helpers/template_assertions_test.rb
107
145
  - test/integration/template_assertions_test.rb
108
146
  - test/test_helper.rb
109
- homepage: https://github.com/tgxworld/rails-controller-testing
147
+ homepage: https://github.com/rails/rails-controller-testing
110
148
  licenses:
111
149
  - MIT
112
150
  metadata: {}
@@ -118,7 +156,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
118
156
  requirements:
119
157
  - - ">="
120
158
  - !ruby/object:Gem::Version
121
- version: '0'
159
+ version: 2.2.1
122
160
  required_rubygems_version: !ruby/object:Gem::Requirement
123
161
  requirements:
124
162
  - - ">="
@@ -126,63 +164,58 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
164
  version: '0'
127
165
  requirements: []
128
166
  rubyforge_project:
129
- rubygems_version: 2.4.5
167
+ rubygems_version: 2.6.6
130
168
  signing_key:
131
169
  specification_version: 4
132
170
  summary: Extracting `assigns` and `assert_template` from ActionDispatch.
133
171
  test_files:
134
- - test/dummy/public/422.html
135
- - test/dummy/public/500.html
136
- - test/dummy/public/404.html
137
- - test/dummy/public/favicon.ico
138
- - test/dummy/log/test.log
139
- - test/dummy/config.ru
172
+ - test/controllers/assigns_test.rb
173
+ - test/controllers/template_assertions_test.rb
174
+ - test/dummy/app/controllers/assigns_controller.rb
175
+ - test/dummy/app/controllers/template_assertions_controller.rb
176
+ - test/dummy/app/controllers/view_assigns_controller.rb
177
+ - test/dummy/app/helpers/application_helper.rb
178
+ - test/dummy/app/views/layouts/application.html.erb
179
+ - test/dummy/app/views/layouts/standard.html.erb
180
+ - test/dummy/app/views/test/_directory/_partial_with_locales.html.erb
181
+ - test/dummy/app/views/test/_layout_for_partial.html.erb
182
+ - test/dummy/app/views/test/_partial.html.erb
183
+ - test/dummy/app/views/test/_partial_for_use_in_layout.html.erb
184
+ - test/dummy/app/views/test/calling_partial_with_layout.html.erb
185
+ - test/dummy/app/views/test/hello/hello.html.erb
186
+ - test/dummy/app/views/test/hello_world.html.erb
187
+ - test/dummy/app/views/test/hello_world_with_partial.html.erb
188
+ - test/dummy/app/views/test/render_partial_inside_directory.html.erb
189
+ - test/dummy/app/views/test/render_two_partials.html.erb
190
+ - test/dummy/bin/bundle
191
+ - test/dummy/bin/rails
192
+ - test/dummy/bin/rake
193
+ - test/dummy/bin/setup
194
+ - test/dummy/config/application.rb
140
195
  - test/dummy/config/boot.rb
141
- - test/dummy/config/initializers/cookies_serializer.rb
142
- - test/dummy/config/initializers/backtrace_silencers.rb
196
+ - test/dummy/config/database.yml
197
+ - test/dummy/config/environment.rb
198
+ - test/dummy/config/environments/development.rb
199
+ - test/dummy/config/environments/production.rb
200
+ - test/dummy/config/environments/test.rb
143
201
  - test/dummy/config/initializers/assets.rb
144
- - test/dummy/config/initializers/session_store.rb
145
- - test/dummy/config/initializers/wrap_parameters.rb
146
- - test/dummy/config/initializers/mime_types.rb
202
+ - test/dummy/config/initializers/backtrace_silencers.rb
203
+ - test/dummy/config/initializers/cookies_serializer.rb
147
204
  - test/dummy/config/initializers/filter_parameter_logging.rb
148
205
  - test/dummy/config/initializers/inflections.rb
149
- - test/dummy/config/environments/production.rb
150
- - test/dummy/config/environments/development.rb
151
- - test/dummy/config/environments/test.rb
152
- - test/dummy/config/environment.rb
206
+ - test/dummy/config/initializers/mime_types.rb
207
+ - test/dummy/config/initializers/session_store.rb
208
+ - test/dummy/config/initializers/wrap_parameters.rb
209
+ - test/dummy/config/locales/en.yml
153
210
  - test/dummy/config/routes.rb
154
- - test/dummy/config/database.yml
155
- - test/dummy/config/application.rb
156
211
  - test/dummy/config/secrets.yml
157
- - test/dummy/config/locales/en.yml
158
- - test/dummy/db/test.sqlite3
212
+ - test/dummy/config.ru
213
+ - test/dummy/public/404.html
214
+ - test/dummy/public/422.html
215
+ - test/dummy/public/500.html
216
+ - test/dummy/public/favicon.ico
159
217
  - test/dummy/Rakefile
160
- - test/dummy/app/assets/stylesheets/application.css
161
- - test/dummy/app/assets/javascripts/application.js
162
- - test/dummy/app/views/test/_partial_for_use_in_layout.html.erb
163
- - test/dummy/app/views/test/render_partial_inside_directory.html.erb
164
- - test/dummy/app/views/test/hello_world_with_partial.html.erb
165
- - test/dummy/app/views/test/render_two_partials.html.erb
166
- - test/dummy/app/views/test/_layout_for_partial.html.erb
167
- - test/dummy/app/views/test/calling_partial_with_layout.html.erb
168
- - test/dummy/app/views/test/hello_world.html.erb
169
- - test/dummy/app/views/test/_directory/_partial_with_locales.html.erb
170
- - test/dummy/app/views/test/_partial.html.erb
171
- - test/dummy/app/views/test/hello/hello.html.erb
172
- - test/dummy/app/views/layouts/application.html.erb
173
- - test/dummy/app/views/layouts/standard.html.erb
174
- - test/dummy/app/controllers/template_assertions_controller.rb
175
- - test/dummy/app/controllers/view_assigns_controller.rb
176
- - test/dummy/app/controllers/assigns_controller.rb
177
- - test/dummy/app/helpers/application_helper.rb
178
- - test/dummy/bin/rails
179
- - test/dummy/bin/setup
180
- - test/dummy/bin/rake
181
- - test/dummy/bin/bundle
182
218
  - test/dummy/README.rdoc
183
- - test/test_helper.rb
184
- - test/controllers/assigns_test.rb
185
- - test/controllers/template_assertions_test.rb
186
219
  - test/helpers/template_assertions_test.rb
187
220
  - test/integration/template_assertions_test.rb
188
- has_rdoc:
221
+ - test/test_helper.rb
@@ -1,13 +0,0 @@
1
- // This is a manifest file that'll be compiled into application.js, which will include all the files
2
- // listed below.
3
- //
4
- // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
- // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
- //
7
- // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
- // compiled file.
9
- //
10
- // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
- // about supported directives.
12
- //
13
- //= require_tree .
@@ -1,15 +0,0 @@
1
- /*
2
- * This is a manifest file that'll be compiled into application.css, which will include all the files
3
- * listed below.
4
- *
5
- * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
- * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
- *
8
- * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
- * compiled file so the styles you add here take precedence over styles defined in any styles
10
- * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
- * file per style scope.
12
- *
13
- *= require_tree .
14
- *= require_self
15
- */
File without changes