Sha256: 9ad1b862b9b9128d349498b1760d2bf1da490063837c3114f440b09dd0d3fbc9
Contents?: true
Size: 829 Bytes
Versions: 1
Compression:
Stored size: 829 Bytes
Contents
require File.expand_path(File.dirname(__FILE__) + '/spec_helper') describe Counter do before do @path = Pathname('/tmp/count.txt') end after do @path.unlink if @path.exist? end describe '#count_up' do it 'should count up' do open(@path, 'w') do |f| f.write(123) end x = 0; counter = Counter.new(@path.to_s) counter.count_up do |count| x = count end x.should eql(123) open(@path) do |f| f.read.chomp.to_i.should eql(124) end end it 'should count up even if file does not exist' do x = 0; counter = Counter.new(@path.to_s) counter.count_up do |count| x = count end x.should eql(0) open(@path) do |f| f.read.chomp.to_i.should eql(1) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
0xffffff-0.1.0 | spec/counter_spec.rb |