b-lazy 0.1.2 → 0.1.3
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/b-lazy.gemspec +1 -1
- data/lib/b-lazy.rb +1 -0
- data/specs/b-lazy_spec.rb +32 -0
- metadata +3 -3
- data/specs/blazy_spec.rb +0 -0
data/b-lazy.gemspec
CHANGED
data/lib/b-lazy.rb
CHANGED
@@ -0,0 +1,32 @@
|
|
1
|
+
|
2
|
+
require 'b-lazy'
|
3
|
+
|
4
|
+
|
5
|
+
describe BLazy do
|
6
|
+
|
7
|
+
context "#when_needed" do
|
8
|
+
|
9
|
+
it "will not execute the block when no enumeration is performed" do
|
10
|
+
BLazy.when_needed{fail; [1, 2, 3]}
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
it "executes the block only once" do
|
16
|
+
exec_count = 0
|
17
|
+
values = BLazy.when_needed{exec_count += 1; [1, 2, 3]}
|
18
|
+
exec_count.should == 0
|
19
|
+
|
20
|
+
values.next.should == 1
|
21
|
+
exec_count.should == 1
|
22
|
+
|
23
|
+
values.next.should == 2
|
24
|
+
exec_count.should == 1
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 3
|
9
|
+
version: 0.1.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Brian Lauber
|
@@ -27,8 +27,8 @@ extensions: []
|
|
27
27
|
extra_rdoc_files: []
|
28
28
|
|
29
29
|
files:
|
30
|
+
- specs/b-lazy_spec.rb
|
30
31
|
- specs/enumerable_spec.rb
|
31
|
-
- specs/blazy_spec.rb
|
32
32
|
- specs/integer_spec.rb
|
33
33
|
- lib/b-lazy.rb
|
34
34
|
- README
|
data/specs/blazy_spec.rb
DELETED
File without changes
|