dynamic_finders_plus 0.0.5 → 0.0.6

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/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dynamic_finders_plus (0.0.4)
4
+ dynamic_finders_plus (0.0.5)
5
5
  activemodel (~> 3.2.0)
6
6
  activesupport
7
7
 
@@ -20,8 +20,8 @@ module ActiveRecord
20
20
  class Relation
21
21
  alias a39c8f8aecf84ae4a83e86415d111cc8 method_missing
22
22
  def method_missing name, *args, &block
23
- if (new_methods = DynamicFindersPlus::Finder.define_for @klass) && (method = new_methods[name])
24
- method.call *args, &block
23
+ if (new_methods = DynamicFindersPlus::Finder.define_for @klass) && new_methods[name]
24
+ self.send(name, *args, &block)
25
25
  else
26
26
  a39c8f8aecf84ae4a83e86415d111cc8 name, *args, &block
27
27
  end
@@ -1,3 +1,3 @@
1
1
  module DynamicFindersPlus
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
data/spec/definer_spec.rb CHANGED
@@ -4,14 +4,39 @@ describe SimpleModel do
4
4
 
5
5
  subject { SimpleModel }
6
6
 
7
- before(:all) do
8
- begin SimpleModel.foo
9
- rescue
7
+ context "The first query on the model" do
8
+ around do |e|
9
+ ActiveRecord::Base.connection.execute <<-SQL
10
+ CREATE TABLE users(
11
+ id INTEGER PRIMARY KEY,
12
+ name VARCHAR(255),
13
+ age INTEGER,
14
+ active BOOLEAN,
15
+ date_of_birth DATETIME
16
+ )
17
+ SQL
18
+
19
+ e.run
20
+
21
+ ActiveRecord::Base.connection.execute "DROP TABLE users"
22
+ end
23
+
24
+ class User < ActiveRecord::Base
25
+ end
26
+
27
+ subject { User.where(active: true).name_contains("foo") }
28
+
29
+ it "should maintain the original scope" do
30
+ active = User.create active: true, name: "foo"
31
+ inactive = User.create active: false, name: "foo"
32
+
33
+ should include active
34
+ should_not include inactive
10
35
  end
11
36
  end
12
37
 
13
- it { should respond_to :name_contains }
14
- it { should respond_to :is_active }
15
- it { should respond_to :is_not_active }
38
+ it { expect { SimpleModel.name }.to_not raise_error(NameError) }
39
+ it { expect { SimpleModel.is_active }.to_not raise_error(NameError) }
40
+ it { expect { SimpleModel.is_not_active }.to_not raise_error(NameError) }
16
41
 
17
42
  end
data/spec/spec_helper.rb CHANGED
@@ -22,7 +22,6 @@ class SimpleModel < ActiveRecord::Base
22
22
  end
23
23
 
24
24
 
25
-
26
25
  RSpec.configure do |config|
27
26
  config.before(:all) do
28
27
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynamic_finders_plus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-30 00:00:00.000000000 Z
12
+ date: 2012-10-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activemodel