-
Notifications
You must be signed in to change notification settings - Fork 21.8k
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
Add ActiveSupport::Testing::FileFixtures
.
#18658
Conversation
@carlosantoniodasilva @rafaelfranca @dhh interested to hear your thoughts. The method names feel a bit awkward to me but it's the best I could come up with. |
🆒 |
Nice. @senny it would be awesome if this could be extended to support passing a file in controller requests in tests. Thoughts? |
Seems good to me. |
class_attribute :file_fixture_directory | ||
end | ||
|
||
# return the contents of the fixture file named +fixture_name+. |
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.
Nit-picky thing but it should be "Returns" here, no ?
@@ -21,6 +21,7 @@ | |||
class ActiveSupport::TestCase | |||
include ActiveRecord::TestFixtures | |||
self.fixture_path = "#{Rails.root}/test/fixtures/" | |||
self.file_fixture_directory = Rails.root + "test/fixtures/files" |
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.
How about: fixture_path + "files"
?
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.
👍
I wonder if we should touch Other than that it seems good to me, good to have something simple builtin to help with that. |
5ae37f7
to
06c7fff
Compare
I changed the configuration option to @carlosantoniodasilva what do you think? |
Cool, I like it better 👍, do you prefer like this? Would you think that leaving the "read" logic for the developers wouldn't be fine? I mean, we could use |
@carlosantoniodasilva 👍 I think we can get rid of |
Alright, great 👍 ❤️ |
@carlosantoniodasilva mind a final 👀? |
@@ -1,3 +1,11 @@ | |||
* Add `file_fixture` to `ActiveSupport::TestCase`. | |||
They provide a simple mechanism to access sample files in your test cases. |
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.
s/they provide/it provides
?
💚💛❤️💙💜 |
It's a thin layer to provide easy access to sample files throughout test-cases. This adds the directory `test/fixtures/files` to newly generated applications.
Add `ActiveSupport::Testing::FileFixtures`.
@carlosantoniodasilva thanks man!!! 💛 |
thank you 👍 💙 |
It's a thin layer to provide easy access to sample files throughout
test-cases. This adds the directory
test/fixtures/files
to newlygenerated applications.
This is something that came up in a discussion with @dhh
Most of our applications have helpers to access some kind of sample files. Possible use-cases are: