Created
January 13, 2011 18:39
-
-
Save kaipr/778369 to your computer and use it in GitHub Desktop.
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
diff --git a/activerecord/lib/active_record/fixtures.rb b/activerecord/lib/active_record/fixtures.rb | |
index b6f0511..5223ac5 100644 | |
--- a/activerecord/lib/active_record/fixtures.rb | |
+++ b/activerecord/lib/active_record/fixtures.rb | |
@@ -842,8 +842,8 @@ module ActiveRecord | |
def fixtures(*table_names) | |
if table_names.first == :all | |
- table_names = Dir["#{fixture_path}/**/*.{yml,csv}"] | |
- table_names.map! { |f| f[(fixture_path.size + 1)..-5] } | |
+ table_names = Dir[File.join(fixture_path, '**', '*.{yml,csv}'] | |
+ table_names.map! { |f| f.match(/.{#{fixture_path.size}}\/?(.*)\.(yml|csv)/)[1] } | |
else | |
table_names = table_names.flatten.map { |n| n.to_s } | |
end |
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
# This behaves as it should (as MRI does) | |
rbx-head :001 > Dir["testapp/test//fixtures/**/*.{yml,csv}"] | |
=> ["testapp/test//fixtures/bar.yml", "testapp/test//fixtures/foo.yml"] | |
# //** is a problem in current rubinius | |
rbx-head :002 > Dir["testapp/test/fixtures//**/*.{yml,csv}"] | |
=> ["testapp/test/fixtures/bar.yml", "testapp/test/fixtures/foo.yml"] | |
# Current implementation | |
table_names = Dir["#{fixture_path}/**/*.{yml,csv}"] | |
table_names.map! { |f| f[(fixture_path.size + 1)..-5] } | |
# First suggested implementation (needs a trailing slash on fixture_path) | |
table_names = Dir[File.join(fixture_path, '**', '*.{yml,csv}'] | |
table_names.map! { |f| f[(fixture_path.size)..-5] } | |
# Second suggested implementation (kinda clumsy, but works) | |
table_names = Dir[File.join(fixture_path, '**', '*.{yml,csv}'] | |
table_names.map! { |f| f.match(/.{#{fixture_path.size}}\/?(.*)\.(yml|csv)/)[1] } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment