believer 0.2.22 → 0.2.23

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.
@@ -2,7 +2,12 @@ module Believer
2
2
  module ActAsEnumerable
3
3
 
4
4
  def self.included(base)
5
- base.delegate *(Enumerable.instance_methods(false).map {|enum_method| enum_method.to_sym}), :to => :to_a
5
+ methods_not_delegated_to_array = [:first, :last, :any?, :exists?, :count]
6
+ enumerable_delegate_methods = Enumerable.instance_methods(false).map { |enum_method|
7
+ enum_method.to_sym
8
+ } - methods_not_delegated_to_array
9
+
10
+ base.delegate *enumerable_delegate_methods, :to => :to_a
6
11
  base.delegate :each, :size, :[], :to => :to_a
7
12
  end
8
13
 
@@ -1,5 +1,5 @@
1
1
  module Believer
2
2
  module Version
3
- VERSION = '0.2.22'
3
+ VERSION = '0.2.23'
4
4
  end
5
5
  end
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+
3
+ describe Believer::Query, 'Acting as Enumerable' do
4
+
5
+ [:first, :last, :any?, :exists?, :count].each do |method|
6
+ it "should not execute a query after the initial load in the #{method} method" do
7
+ query = Believer::Query.new(:record_class => Test::Album).where(:artist_name => 'Jethro Tull').order(:name)
8
+ expect(query).to receive(:execute).once.and_return([])
9
+ query.to_a
10
+ query.send(method)
11
+ query.send(method)
12
+ end
13
+ end
14
+
15
+ [:first, :last, :any?, :exists?, :count].each do |method|
16
+ it "should delegate query to a cloned query instance for the #{method} method" do
17
+ query = Believer::Query.new(:record_class => Test::Album).where(:artist_name => 'Jethro Tull').order(:name)
18
+ expect(query).not_to receive(:execute)
19
+ query.send(method)
20
+ end
21
+ end
22
+
23
+ end
@@ -82,11 +82,6 @@ describe Believer::Query do
82
82
  fail
83
83
  rescue Exception => e
84
84
  end
85
- begin
86
- q.pluck(:name, :artist_xxx)
87
- fail
88
- rescue Exception => e
89
- end
90
85
  end
91
86
 
92
- end
87
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: believer
3
3
  version: !ruby/object:Gem::Version
4
- hash: 59
4
+ hash: 57
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 22
10
- version: 0.2.22
9
+ - 23
10
+ version: 0.2.23
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jerphaes van Blijenburgh
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2014-06-05 00:00:00 Z
18
+ date: 2014-06-13 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: activemodel
@@ -173,6 +173,7 @@ files:
173
173
  - lib/believer/where_clause.rb
174
174
  - lib/believer.rb
175
175
  - README.md
176
+ - spec/believer/act_as_enumerable_spec.rb
176
177
  - spec/believer/base_spec.rb
177
178
  - spec/believer/callback_spec.rb
178
179
  - spec/believer/collection_columns_spec.rb
@@ -235,6 +236,7 @@ signing_key:
235
236
  specification_version: 3
236
237
  summary: CQL3 ORM
237
238
  test_files:
239
+ - spec/believer/act_as_enumerable_spec.rb
238
240
  - spec/believer/base_spec.rb
239
241
  - spec/believer/callback_spec.rb
240
242
  - spec/believer/collection_columns_spec.rb