-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Test::Unit assert_serializer implemented #596
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
steveklabnik
merged 5 commits into
rails-api:master
from
bolshakov:feature/instumentation
Aug 22, 2014
Merged
Test::Unit assert_serializer implemented #596
steveklabnik
merged 5 commits into
rails-api:master
from
bolshakov:feature/instumentation
Aug 22, 2014
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
So you can assert specific serializer to be used.
steveklabnik
added a commit
that referenced
this pull request
Aug 22, 2014
Test::Unit assert_serializer implemented
Thank you! |
bf4
pushed a commit
to bf4/active_model_serializers
that referenced
this pull request
Dec 22, 2015
The `assert_serializer` test helper was added in 0.9.0.apha1[1], and was not included in 0.10. This patch brings back the `assert_serializer` test helper. This is the last revision[2] that has the helper. The original helper was used as base. [1]: rails-api#596 [2]: https://github.com/rails-api/active_model_serializers/tree/610aeb2e9297fa31b8d561f0be9a4597f0258f8c - Create the AssertSerializer - Use the Test namespace - Make the tests pass on the Rails master - Rails 5 does not include `assert_template` but we need this on the tests of the helper. - This add the `rails-controller-testing` to keep support on `assert_template`. - Only load test helpers in the test environment
bf4
pushed a commit
to bf4/active_model_serializers
that referenced
this pull request
Dec 23, 2015
The `assert_serializer` test helper was added in 0.9.0.apha1[1], and was not included in 0.10. This patch brings back the `assert_serializer` test helper. This is the last revision[2] that has the helper. The original helper was used as base. [1]: rails-api#596 [2]: https://github.com/rails-api/active_model_serializers/tree/610aeb2e9297fa31b8d561f0be9a4597f0258f8c - Create the AssertSerializer - Use the Test namespace - Make the tests pass on the Rails master - Rails 5 does not include `assert_template` but we need this on the tests of the helper. - This add the `rails-controller-testing` to keep support on `assert_template`. - Only load test helpers in the test environment
bf4
added a commit
to bf4/active_model_serializers
that referenced
this pull request
Dec 23, 2015
In 0.9 (which this implementation is based on), the instrumentation was `!serialize.active_model_serializers`. rails-api#596 The '!' in the event name meant the event wasn't meant for production. https://github.com/rails/rails/pull/10446/files#r4075679 Since we intend the event for production and have a log subscriber, if we unsubscribe from `render.active_model_serializers`, we'll break other tests that are relying on that event being subscribed.
bf4
added a commit
to bf4/active_model_serializers
that referenced
this pull request
Dec 23, 2015
This commit revises 0ce4ad3 `Remove unused/unusable unsubscribe since we don't want to unsubscribe` Looking at Rails implementation of assert_template which was likely the inspiration for assert_serializer: https://github.com/rails/rails-controller-testing/blob/f756b33c138c593eabe37f6085f8bac477b99bfe/lib/rails/controller/testing/template_assertions.rb Ref: - rails-api#596 - rails-api#620 - rails-api#616
bf4
added a commit
to bf4/active_model_serializers
that referenced
this pull request
Dec 23, 2015
This commit revises 0ce4ad3 `Remove unused/unusable unsubscribe since we don't want to unsubscribe` Looking at Rails implementation of assert_template which was likely the inspiration for assert_serializer: https://github.com/rails/rails-controller-testing/blob/f756b33c138c593eabe37f6085f8bac477b99bfe/lib/rails/controller/testing/template_assertions.rb Ref: - rails-api#596 - rails-api#620 - rails-api#616
bf4
pushed a commit
to bf4/active_model_serializers
that referenced
this pull request
Jan 4, 2016
The `assert_serializer` test helper was added in 0.9.0.apha1[1], and was not included in 0.10. This patch brings back the `assert_serializer` test helper. This is the last revision[2] that has the helper. The original helper was used as base. [1]: rails-api#596 [2]: https://github.com/rails-api/active_model_serializers/tree/610aeb2e9297fa31b8d561f0be9a4597f0258f8c - Create the AssertSerializer - Use the Test namespace - Make the tests pass on the Rails master - Rails 5 does not include `assert_template` but we need this on the tests of the helper. - This add the `rails-controller-testing` to keep support on `assert_template`. - Only load test helpers in the test environment
bf4
added a commit
to bf4/active_model_serializers
that referenced
this pull request
Jan 4, 2016
In 0.9 (which this implementation is based on), the instrumentation was `!serialize.active_model_serializers`. rails-api#596 The '!' in the event name meant the event wasn't meant for production. https://github.com/rails/rails/pull/10446/files#r4075679 Since we intend the event for production and have a log subscriber, if we unsubscribe from `render.active_model_serializers`, we'll break other tests that are relying on that event being subscribed.
bf4
added a commit
to bf4/active_model_serializers
that referenced
this pull request
Jan 4, 2016
This commit revises 0ce4ad3 `Remove unused/unusable unsubscribe since we don't want to unsubscribe` Looking at Rails implementation of assert_template which was likely the inspiration for assert_serializer: https://github.com/rails/rails-controller-testing/blob/f756b33c138c593eabe37f6085f8bac477b99bfe/lib/rails/controller/testing/template_assertions.rb Ref: - rails-api#596 - rails-api#620 - rails-api#616
bf4
added a commit
to bf4/active_model_serializers
that referenced
this pull request
Jan 4, 2016
This commit revises 0ce4ad3 `Remove unused/unusable unsubscribe since we don't want to unsubscribe` Looking at Rails implementation of assert_template which was likely the inspiration for assert_serializer: https://github.com/rails/rails-controller-testing/blob/f756b33c138c593eabe37f6085f8bac477b99bfe/lib/rails/controller/testing/template_assertions.rb Ref: - rails-api#596 - rails-api#620 - rails-api#616
bf4
pushed a commit
to bf4/active_model_serializers
that referenced
this pull request
Jan 13, 2016
The `assert_serializer` test helper was added in 0.9.0.apha1[1], and was not included in 0.10. This patch brings back the `assert_serializer` test helper. This is the last revision[2] that has the helper. The original helper was used as base. [1]: rails-api#596 [2]: https://github.com/rails-api/active_model_serializers/tree/610aeb2e9297fa31b8d561f0be9a4597f0258f8c - Create the AssertSerializer - Use the Test namespace - Make the tests pass on the Rails master - Rails 5 does not include `assert_template` but we need this on the tests of the helper. - This add the `rails-controller-testing` to keep support on `assert_template`. - Only load test helpers in the test environment
bf4
added a commit
to bf4/active_model_serializers
that referenced
this pull request
Jan 13, 2016
In 0.9 (which this implementation is based on), the instrumentation was `!serialize.active_model_serializers`. rails-api#596 The '!' in the event name meant the event wasn't meant for production. https://github.com/rails/rails/pull/10446/files#r4075679 Since we intend the event for production and have a log subscriber, if we unsubscribe from `render.active_model_serializers`, we'll break other tests that are relying on that event being subscribed.
bf4
added a commit
to bf4/active_model_serializers
that referenced
this pull request
Jan 13, 2016
This commit revises 0ce4ad3 `Remove unused/unusable unsubscribe since we don't want to unsubscribe` Looking at Rails implementation of assert_template which was likely the inspiration for assert_serializer: https://github.com/rails/rails-controller-testing/blob/f756b33c138c593eabe37f6085f8bac477b99bfe/lib/rails/controller/testing/template_assertions.rb Ref: - rails-api#596 - rails-api#620 - rails-api#616
bf4
pushed a commit
to bf4/active_model_serializers
that referenced
this pull request
Jan 14, 2016
The `assert_serializer` test helper was added in 0.9.0.apha1[1], and was not included in 0.10. This patch brings back the `assert_serializer` test helper. This is the last revision[2] that has the helper. The original helper was used as base. [1]: rails-api#596 [2]: https://github.com/rails-api/active_model_serializers/tree/610aeb2e9297fa31b8d561f0be9a4597f0258f8c - Create the AssertSerializer - Use the Test namespace - Make the tests pass on the Rails master - Rails 5 does not include `assert_template` but we need this on the tests of the helper. - This add the `rails-controller-testing` to keep support on `assert_template`. - Only load test helpers in the test environment
bf4
added a commit
to bf4/active_model_serializers
that referenced
this pull request
Jan 14, 2016
In 0.9 (which this implementation is based on), the instrumentation was `!serialize.active_model_serializers`. rails-api#596 The '!' in the event name meant the event wasn't meant for production. https://github.com/rails/rails/pull/10446/files#r4075679 Since we intend the event for production and have a log subscriber, if we unsubscribe from `render.active_model_serializers`, we'll break other tests that are relying on that event being subscribed.
bf4
added a commit
to bf4/active_model_serializers
that referenced
this pull request
Jan 14, 2016
This commit revises 0ce4ad3 `Remove unused/unusable unsubscribe since we don't want to unsubscribe` Looking at Rails implementation of assert_template which was likely the inspiration for assert_serializer: https://github.com/rails/rails-controller-testing/blob/f756b33c138c593eabe37f6085f8bac477b99bfe/lib/rails/controller/testing/template_assertions.rb Ref: - rails-api#596 - rails-api#620 - rails-api#616
bf4
added a commit
to bf4/active_model_serializers
that referenced
this pull request
Jan 14, 2016
This commit revises 0ce4ad3 `Remove unused/unusable unsubscribe since we don't want to unsubscribe` Looking at Rails implementation of assert_template which was likely the inspiration for assert_serializer: https://github.com/rails/rails-controller-testing/blob/f756b33c138c593eabe37f6085f8bac477b99bfe/lib/rails/controller/testing/template_assertions.rb Ref: - rails-api#596 - rails-api#620 - rails-api#616
bf4
added a commit
to bf4/active_model_serializers
that referenced
this pull request
Jan 14, 2016
This commit revises 0ce4ad3 `Remove unused/unusable unsubscribe since we don't want to unsubscribe` Looking at Rails implementation of assert_template which was likely the inspiration for assert_serializer: https://github.com/rails/rails-controller-testing/blob/f756b33c138c593eabe37f6085f8bac477b99bfe/lib/rails/controller/testing/template_assertions.rb Ref: - rails-api#596 - rails-api#620 - rails-api#616
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Rails uses
ActiveSupport::Notifications
to collect information about rendered views. So its possible to implementassert_templete
method to test that template specified have been rendered.In order to test integration between controller and serializers we implemented same feature for
ActiveModel::Serializer
.We wrapped
as_json
method withActiveSupport::Notifications.instrument
and collect information about rendered serializers for each test case.assert_serializer
method uses this information to make assertions.In case of failure it generate useful message: