dm-chunked_query 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog.md CHANGED
@@ -1,3 +1,8 @@
1
+ ### 0.1.2 / 2011-03-03
2
+
3
+ * Fixed a typo in {DataMapper::ChunkedQuery::Chunks#[]}.
4
+ * Fixed a typo in {DataMapper::ChunkedQuery::Chunks#at}.
5
+
1
6
  ### 0.1.1 / 2011-03-03
2
7
 
3
8
  * Have {DataMapper::ChunkedQuery::Chunks#at} convert all arguments to Integers.
data/gemspec.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  name: dm-chunked_query
2
- version: 0.1.1
2
+ version: 0.1.2
3
3
  summary: Allows performing chunked queries with DataMapper.
4
4
  description:
5
5
  Allows performing chunked queries on DataMapper Models or Collections.
@@ -42,7 +42,7 @@ module DataMapper
42
42
 
43
43
  chunk_at(index,span)
44
44
  when Integer
45
- chunk_at(index)
45
+ chunk_at(key)
46
46
  end
47
47
  end
48
48
 
@@ -57,7 +57,7 @@ module DataMapper
57
57
  # bounds, `nil` will be returned.
58
58
  #
59
59
  def at(index)
60
- chunk_at(key.to_i)
60
+ chunk_at(index.to_i)
61
61
  end
62
62
 
63
63
  #
data/spec/chunks_spec.rb CHANGED
@@ -17,18 +17,38 @@ describe DataMapper::ChunkedQuery::Chunks do
17
17
  TestModel.chunks(TestModel.count * 0.75).length.should == 2
18
18
  end
19
19
 
20
- it "should allow direct access to individual chunks" do
21
- resources = subject[1]
22
- numbers = resources.map { |resource| resource.number }
20
+ context "#[]" do
21
+ it "should allow direct access to individual chunks" do
22
+ resources = subject[1]
23
+ numbers = resources.map { |resource| resource.number }
23
24
 
24
- numbers.should == (11..20).to_a
25
+ numbers.should == (11..20).to_a
26
+ end
27
+
28
+ it "should allow direct access to a range of chunks" do
29
+ resources = subject[1..2]
30
+ numbers = resources.map { |resource| resource.number }
31
+
32
+ numbers.should == (11..30).to_a
33
+ end
25
34
  end
26
35
 
27
- it "should allow direct access to a range of chunks" do
28
- resources = subject[1..2]
29
- numbers = resources.map { |resource| resource.number }
36
+ context "#at" do
37
+ let(:expected_numbers) { (11..20).to_a }
38
+
39
+ it "should allow accessing chunks at given indices" do
40
+ resources = subject.at(1)
41
+ numbers = resources.map { |resource| resource.number }
42
+
43
+ numbers.should == expected_numbers
44
+ end
45
+
46
+ it "should allow accessing chunks using non-Integer indices" do
47
+ resources = subject.at('1')
48
+ numbers = resources.map { |resource| resource.number }
30
49
 
31
- numbers.should == (11..30).to_a
50
+ numbers.should == expected_numbers
51
+ end
32
52
  end
33
53
 
34
54
  it "should allow enumerating through every chunk" do
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: dm-chunked_query
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.1
5
+ version: 0.1.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Postmodern