spec/lib/shamu/services/lazy_transform_spec.rb in shamu-0.0.13 vs spec/lib/shamu/services/lazy_transform_spec.rb in shamu-0.0.14
- old
+ new
@@ -45,9 +45,23 @@
transformed = Shamu::Services::LazyTransform.new( source, &transformer( &block ) )
transformed.first( 2 )
end.to yield_control.exactly(3)
end
+ it "short-circuits last" do
+ expect do |block|
+ transformed = Shamu::Services::LazyTransform.new( source, &transformer( &block ) )
+ transformed.last
+ end.to yield_control.once
+ end
+
+ it "doesn't short-circuit last(n)" do
+ expect do |block|
+ transformed = Shamu::Services::LazyTransform.new( source, &transformer( &block ) )
+ transformed.last( 2 )
+ end.to yield_control.exactly(3)
+ end
+
it "short-circuits empty?" do
expect do |block|
transformed = Shamu::Services::LazyTransform.new( source, &transformer( &block ) )
expect( transformed ).not_to be_empty
end.not_to yield_control