rails-controller-testing 0.0.3 → 1.0.2

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: a2012bee519b01179696020eab76322fdf25e678
4
+ data.tar.gz: e885d3464fc5a81efc0332b294b9a28585172fd5
5
5
  SHA512:
6
- metadata.gz: d20f7cd4b9e9c9d5d1c6cf7feb781567db6d41d4a2554f41d230125d74dda00b1e8a059d70cc9bfed7d110500c94b3f3682f06abff49439956fad29873858314
7
- data.tar.gz: 8f6c42572deaf856083388129f5fdf089a02f21e3acc1a908ca2094701add36b15831824dde55ec2516163c673a68c96608f3b6b1e59c71def87b63483484cc4
6
+ metadata.gz: 9b218e233f42c9787bcdf2584392d81d31d13ff96c3316538955a4bf4ea2ddb9ce0bd37a2d0372dc723aa536994097a9cde23ce6b52b999f2877d78464b0e788
7
+ data.tar.gz: e14f775742d2183d822a51a70ffc410a22fcd764c761583167b62c93c2216be269c464f44112a16fb69e006ed10d4ff8b3ac4e40a93c4d7e82a923cb99d94a5f
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,8 +1,5 @@
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)
4
- [![Gem Version](https://badge.fury.io/rb/rails-controller-testing.svg)](http://badge.fury.io/rb/rails-controller-testing)
5
-
6
3
  This gem brings back `assigns` to your controller tests as well as `assert_template`
7
4
  to both controller and integration tests.
8
5
 
@@ -23,6 +20,39 @@ Or install it yourself as:
23
20
 
24
21
  $ gem install rails-controller-testing
25
22
 
23
+ ### RSpec
24
+
25
+ See https://github.com/rspec/rspec-rails/issues/1393.
26
+
27
+ rspec-rails automatically integrates with this gem since version `3.5.0`.
28
+ Adding the gem to your `Gemfile` is sufficient.
29
+
30
+ If you use an older version of rspec-rails, you can manually include the
31
+ modules in your `rails_helper`.
32
+
33
+ ```ruby
34
+ RSpec.configure do |config|
35
+ [:controller, :view, :request].each do |type|
36
+ config.include ::Rails::Controller::Testing::TestProcess, :type => type
37
+ config.include ::Rails::Controller::Testing::TemplateAssertions, :type => type
38
+ config.include ::Rails::Controller::Testing::Integration, :type => type
39
+ end
40
+ end
41
+ ```
42
+
43
+ ## Outside Rails
44
+
45
+ For projects and gems using controller tests outside of a Rails application,
46
+ invoke the `Rails::Controller::Testing.install` method inside your test suite
47
+ setup to include the required modules on controller test cases.
48
+
49
+ ```ruby
50
+ # test/test_helper.rb
51
+
52
+ require 'rails-controller-testing'
53
+ Rails::Controller::Testing.install
54
+ ```
55
+
26
56
  ## Usage
27
57
 
28
58
  ### assigns
@@ -49,7 +79,14 @@ end
49
79
 
50
80
  `assert_template` allows to you assert that certain templates have been rendered.
51
81
 
52
- TODO: Provide examples.
82
+ ```ruby
83
+ class PostControllerTest < ActionController::TestCase
84
+ def test_index
85
+ get :index
86
+ assert_template 'posts/index'
87
+ end
88
+ end
89
+ ```
53
90
 
54
91
  ## Contributing
55
92
 
@@ -0,0 +1,5 @@
1
+ class Rails::Controller::Testing::Railtie < Rails::Railtie
2
+ initializer "rails_controller_testing" do
3
+ Rails::Controller::Testing.install
4
+ end
5
+ end
@@ -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.2"
5
5
  end
6
6
  end
7
7
  end
@@ -0,0 +1,27 @@
1
+ require 'active_support/lazy_load_hooks'
2
+ require 'rails/controller/testing/test_process'
3
+ require 'rails/controller/testing/integration'
4
+ require 'rails/controller/testing/template_assertions'
5
+
6
+ module Rails
7
+ module Controller
8
+ module Testing
9
+ def self.install
10
+ ActiveSupport.on_load(:action_controller_test_case) do
11
+ include Rails::Controller::Testing::TestProcess
12
+ include Rails::Controller::Testing::TemplateAssertions
13
+ end
14
+
15
+ ActiveSupport.on_load(:action_dispatch_integration_test) do
16
+ include Rails::Controller::Testing::TemplateAssertions
17
+ include Rails::Controller::Testing::Integration
18
+ include Rails::Controller::Testing::TestProcess
19
+ end
20
+
21
+ ActiveSupport.on_load(:action_view_test_case) do
22
+ include Rails::Controller::Testing::TemplateAssertions
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -1,23 +1,3 @@
1
- require 'rails/controller/testing/test_process'
2
- require 'rails/controller/testing/integration'
3
- require 'rails/controller/testing/template_assertions'
4
-
5
- module ActionController
6
- class TestCase
7
- include Rails::Controller::Testing::TestProcess
8
- include Rails::Controller::Testing::TemplateAssertions
9
- end
10
- end
11
-
12
- module ActionDispatch
13
- class IntegrationTest
14
- include Rails::Controller::Testing::TemplateAssertions
15
- include Rails::Controller::Testing::Integration
16
- end
17
- end
18
-
19
- module ActionView
20
- class TestCase
21
- include Rails::Controller::Testing::TemplateAssertions
22
- end
23
- end
1
+ require 'rails/controller/testing'
2
+ require 'rails/controller/testing/railtie' if defined?(Rails::Railtie)
3
+ require 'rails/controller/testing/version'
@@ -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
@@ -20,8 +19,8 @@ class AssignsControllerTest < ActionController::TestCase
20
19
  def test_view_assigns
21
20
  @controller = ViewAssignsController.new
22
21
  process :test_assigns
23
- assert_equal nil, assigns(:foo)
24
- assert_equal nil, assigns[:foo]
22
+ assert_nil assigns(:foo)
23
+ assert_nil assigns[:foo]
25
24
  assert_equal "bar", assigns(:bar)
26
25
  assert_equal "bar", assigns[:bar]
27
26
  end
@@ -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