zilkey-active_hash 0.6.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.0
1
+ 0.6.1
data/active_hash.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{active_hash}
5
- s.version = "0.6.0"
5
+ s.version = "0.6.1"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Jeff Dean", "Mike Dalessio", "Corey Innis", "Peter Jaros"]
@@ -65,10 +65,9 @@ module ActiveHash
65
65
  end
66
66
 
67
67
  def method_missing(method_name, *args)
68
- config = configuration_for_custom_finder(method_name)
69
-
70
- return super unless config
68
+ return super unless respond_to? method_name
71
69
 
70
+ config = configuration_for_custom_finder(method_name)
72
71
  attribute_pairs = config[:fields].zip(args)
73
72
  matches = all.select { |base| attribute_pairs.all? { |field, value| base.send(field) == value } }
74
73
  config[:all?] ? matches : matches.first
@@ -219,7 +219,7 @@ describe ActiveHash, "Base" do
219
219
 
220
220
  describe "custom finders" do
221
221
  before do
222
- Country.fields :name, :monarch
222
+ Country.fields :name, :monarch, :language
223
223
 
224
224
  # Start ids above 4 lest we get nil and think it's an AH::Base model with id=4.
225
225
  Country.data = [
@@ -294,6 +294,14 @@ describe ActiveHash, "Base" do
294
294
  Country.find_by_name_and_monarch("US", "The Crown of England").should be_nil
295
295
  end
296
296
  end
297
+
298
+ describe "for fields the class doesn't have" do
299
+ it "raises a NoMethodError" do
300
+ lambda {
301
+ Country.find_by_name_and_shoe_size("US", 10)
302
+ }.should raise_error(NoMethodError, "undefined method `find_by_name_and_shoe_size' for Country:Class")
303
+ end
304
+ end
297
305
  end
298
306
 
299
307
  describe "find_all_by_<field_one>_and_<field_two>" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zilkey-active_hash
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Dean