aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorRafael França <rafaelmfranca@gmail.com>2016-12-16 10:49:00 -0500
committerGitHub <noreply@github.com>2016-12-16 10:49:00 -0500
commitf98d487f1b736f24cd2348220f3b5f20e1b90a8c (patch)
tree9dd28354de904435b8121a025efaf6a355eb9535 /activerecord/lib
parent8a37ac9264cac407c3c2b368704a5fa9cd9ebaca (diff)
parent3e018eca32dd5bedaefe03845f076849a6fc5e4b (diff)
downloadrails-f98d487f1b736f24cd2348220f3b5f20e1b90a8c.tar.gz
rails-f98d487f1b736f24cd2348220f3b5f20e1b90a8c.tar.bz2
rails-f98d487f1b736f24cd2348220f3b5f20e1b90a8c.zip
Merge pull request #27375 from kirs/fixture-error-message
Throw friendly error message when fixture is not a hash
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/fixture_set/file.rb7
1 files changed, 5 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/fixture_set/file.rb b/activerecord/lib/active_record/fixture_set/file.rb
index 5ba354d758..6cf2e01179 100644
--- a/activerecord/lib/active_record/fixture_set/file.rb
+++ b/activerecord/lib/active_record/fixture_set/file.rb
@@ -66,10 +66,13 @@ module ActiveRecord
# Validate our unmarshalled data.
def validate(data)
unless Hash === data || YAML::Omap === data
- raise Fixture::FormatError, "fixture is not a hash"
+ raise Fixture::FormatError, "fixture is not a hash: #{@file}"
end
- raise Fixture::FormatError unless data.all? { |name, row| Hash === row }
+ invalid = data.reject { |_, row| Hash === row }
+ if invalid.any?
+ raise Fixture::FormatError, "fixture key is not a hash: #{@file}, keys: #{invalid.keys.inspect}"
+ end
data
end
end