test/progressrus_test.rb in progressrus-0.1.0 vs test/progressrus_test.rb in progressrus-0.1.1
- old
+ new
@@ -108,14 +108,21 @@
@progress.tick(120)
assert_equal 1.2, @progress.percentage
end
- def test_percentage_should_be_0_if_total_0
+ def test_percentage_should_be_0_if_count_0
assert_equal 0, @progress.percentage
end
+ def test_percentage_should_be_1_if_total_0
+ progress = Progressrus.new(total: 0)
+ assert_equal 1, progress.percentage
+ progress.tick
+ assert_equal 1, progress.percentage
+ end
+
def test_elapsed_should_return_the_delta_between_now_and_started_at
time = Time.now
@progress.tick(10, now: time - 10)
elapsed = @progress.elapsed(now: time)
@@ -166,14 +173,13 @@
@progress.complete(now: Time.now)
assert_equal now.to_i, @progress.completed_at.to_i
end
- def test_should_not_be_able_to_set_total_to_0
- assert_raises ArgumentError do
- @progress.total = 0
- end
+ def test_should_be_able_to_set_total_to_0
+ @progress.total = 0
+ assert_equal 0, @progress.total
end
def test_should_not_be_able_to_set_total_to_a_negative_number
assert_raises ArgumentError do
@progress.total = -1
@@ -197,13 +203,12 @@
store.redis.expects(:hset).at_least_once.raises(::Redis::BaseError)
@progress.tick
@progress.complete
end
- def test_should_not_be_able_to_initialize_with_total_0
- assert_raises ArgumentError do
- Progressrus.new(total: 0)
- end
+ def test_should_be_able_to_initialize_with_total_0
+ progress = Progressrus.new(total: 0)
+ assert_equal 0, progress.total
end
def test_should_not_be_able_to_initialize_with_total_as_a_negative_number
assert_raises ArgumentError do
Progressrus.new(total: -1)