-
Notifications
You must be signed in to change notification settings - Fork 133
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
Tradução do tópico 17.1 : Recursos de testes adicionais #764
Open
weslleymurdock
wants to merge
1
commit into
campuscode:main
Choose a base branch
from
weslleymurdock:Testing-Time-Dependent-Code
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+9
−9
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -2030,25 +2030,25 @@ RSpec.describe "Zeitwerk compliance" do | |||||
end | ||||||
``` | ||||||
|
||||||
Additional Testing Resources | ||||||
Recursos de teste adicionais | ||||||
---------------------------- | ||||||
|
||||||
### Testing Time-Dependent Code | ||||||
### Testando código Time-Dependent | ||||||
|
||||||
Rails provides built-in helper methods that enable you to assert that your time-sensitive code works as expected. | ||||||
O Rails fornece métodos auxiliares integrados que permitem garantir que seu código time-sensitive funciona conforme o esperado. | ||||||
|
||||||
Here is an example using the [`travel_to`](https://api.rubyonrails.org/classes/ActiveSupport/Testing/TimeHelpers.html#method-i-travel_to) helper: | ||||||
Aqui está um exemplo utilizando o helper [`travel_to`](https://api.rubyonrails.org/classes/ActiveSupport/Testing/TimeHelpers.html#method-i-travel_to): | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
```ruby | ||||||
# Lets say that a user is eligible for gifting a month after they register. | ||||||
# Digamos que um usuário seja elegível para presentear um mês depois de se registrar. | ||||||
user = User.create(name: "Gaurish", activation_date: Date.new(2004, 10, 24)) | ||||||
assert_not user.applicable_for_gifting? | ||||||
travel_to Date.new(2004, 11, 24) do | ||||||
assert_equal Date.new(2004, 10, 24), user.activation_date # inside the `travel_to` block `Date.current` is mocked | ||||||
assert_equal Date.new(2004, 10, 24), user.activation_date # dentro do bloco `travel_to`, `Date.current` é simulado | ||||||
assert user.applicable_for_gifting? | ||||||
end | ||||||
assert_equal Date.new(2004, 10, 24), user.activation_date # The change was visible only inside the `travel_to` block. | ||||||
assert_equal Date.new(2004, 10, 24), user.activation_date # A mudança era visível apenas dentro do bloco `travel_to`. | ||||||
``` | ||||||
|
||||||
Please see [`ActiveSupport::Testing::TimeHelpers` API Documentation](https://api.rubyonrails.org/classes/ActiveSupport/Testing/TimeHelpers.html) | ||||||
for in-depth information about the available time helpers. | ||||||
Por favor veja a documentação da API [`ActiveSupport::Testing::TimeHelpers`](https://api.rubyonrails.org/classes/ActiveSupport/Testing/TimeHelpers.html) | ||||||
para obter informações detalhadas sobre os time helpers disponíveis. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fiquei pensando aqui em uma tradução de contexto para time-sensitive. Será que temporal faz sentido, pois remete a algo ser transitório ao longo do tempo? O que acham? @weslleymurdock @campuscode/guia-rails-team