activerecord-futures 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # ActiveRecord::Futures
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/activerecord-futures.png)](http://badge.fury.io/rb/activerecord-futures)
3
4
  [![Build Status](https://travis-ci.org/leoasis/activerecord-futures.png)](https://travis-ci.org/leoasis/activerecord-futures)
4
5
  [![Code Climate](https://codeclimate.com/github/leoasis/activerecord-futures.png)](https://codeclimate.com/github/leoasis/activerecord-futures)
5
6
  [![Coverage Status](https://coveralls.io/repos/leoasis/activerecord-futures/badge.png?branch=master)](https://coveralls.io/r/leoasis/activerecord-futures)
@@ -35,6 +35,10 @@ module ActiveRecord
35
35
  Future.flush unless executed?
36
36
  execute
37
37
  end
38
+
39
+ define_method(:inspect) do
40
+ send(method).inspect
41
+ end
38
42
  end
39
43
  end
40
44
 
@@ -2,10 +2,6 @@ module ActiveRecord
2
2
  module Futures
3
3
  class FutureCalculationValue < FutureCalculation
4
4
  fetch_with(:value)
5
-
6
- def inspect
7
- value.inspect
8
- end
9
5
  end
10
6
  end
11
7
  end
@@ -1,5 +1,5 @@
1
1
  module Activerecord
2
2
  module Futures
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
@@ -0,0 +1,29 @@
1
+ require "spec_helper"
2
+
3
+ module ActiveRecord::Futures
4
+ describe FutureCalculationArray do
5
+ let(:relation) do
6
+ double(ActiveRecord::Relation, {
7
+ connection: double("connection", supports_futures?: true)
8
+ })
9
+ end
10
+
11
+ let(:query) { "select 1" }
12
+ let(:exec_result) { double("exec result", inspect: nil) }
13
+ let(:exec) { ->{ exec_result } }
14
+
15
+ subject { FutureCalculationArray.new(relation, query, exec) }
16
+
17
+ describe "#inspect" do
18
+ before do
19
+ subject.inspect
20
+ end
21
+
22
+ it { should be_executed }
23
+
24
+ it "delegates to exec result's inspect" do
25
+ exec_result.should have_received(:inspect)
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,29 @@
1
+ require "spec_helper"
2
+
3
+ module ActiveRecord::Futures
4
+ describe FutureCalculationValue do
5
+ let(:relation) do
6
+ double(ActiveRecord::Relation, {
7
+ connection: double("connection", supports_futures?: true)
8
+ })
9
+ end
10
+
11
+ let(:query) { "select 1" }
12
+ let(:exec_result) { double("exec result", inspect: nil) }
13
+ let(:exec) { ->{ exec_result } }
14
+
15
+ subject { FutureCalculationValue.new(relation, query, exec) }
16
+
17
+ describe "#inspect" do
18
+ before do
19
+ subject.inspect
20
+ end
21
+
22
+ it { should be_executed }
23
+
24
+ it "delegates to exec result's inspect" do
25
+ exec_result.should have_received(:inspect)
26
+ end
27
+ end
28
+ end
29
+ end
@@ -60,5 +60,22 @@ module ActiveRecord::Futures
60
60
  Future.current.should == nil
61
61
  end
62
62
  end
63
+
64
+ describe "#inspect" do
65
+ let(:resulting_array) { double(Array, inspect: nil) }
66
+
67
+ before do
68
+ relation.stub(loaded?: true)
69
+ relation.stub(:to_a).and_return(resulting_array)
70
+
71
+ subject.inspect
72
+ end
73
+
74
+ it { should be_executed }
75
+
76
+ it "delegates to relation.to_a.inspect" do
77
+ resulting_array.should have_received(:inspect)
78
+ end
79
+ end
63
80
  end
64
81
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-futures
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
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: 2013-04-29 00:00:00.000000000 Z
12
+ date: 2013-04-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -120,6 +120,8 @@ files:
120
120
  - lib/active_record/futures/query_recording.rb
121
121
  - lib/activerecord-futures.rb
122
122
  - lib/activerecord-futures/version.rb
123
+ - spec/active_record/futures/future_calculation_array_spec.rb
124
+ - spec/active_record/futures/future_calculation_value_spec.rb
123
125
  - spec/active_record/futures/future_relation_spec.rb
124
126
  - spec/active_record/futures/future_spec.rb
125
127
  - spec/active_record/futures/proxy_spec.rb
@@ -160,6 +162,8 @@ signing_key:
160
162
  specification_version: 3
161
163
  summary: Fetch all queries at once from the database and save round trips.
162
164
  test_files:
165
+ - spec/active_record/futures/future_calculation_array_spec.rb
166
+ - spec/active_record/futures/future_calculation_value_spec.rb
163
167
  - spec/active_record/futures/future_relation_spec.rb
164
168
  - spec/active_record/futures/future_spec.rb
165
169
  - spec/active_record/futures/proxy_spec.rb