Skip to content

Commit

Permalink
Verifies fail_fast is working
Browse files Browse the repository at this point in the history
Fixes #6
  • Loading branch information
searls committed Aug 21, 2016
1 parent bb0497f commit 417a0de
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
4 changes: 4 additions & 0 deletions safe/fixtures/calculator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ def old_add(a,b)
end

def new_add(a,b)
b + a
end

def broken_add(a,b)
(b + a + @eww_gross_state).tap { @eww_gross_state += 1 }
end
end
32 changes: 31 additions & 1 deletion safe/verify_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,38 @@ def test_calculator_add_verify_on_new

assert_raises(Suture::Error::VerificationFailed) {
Suture.verify(:add, {
:subject => @subject.method(:new_add)
:subject => @subject.method(:broken_add)
})
}
end

def test_fail_fast_disabled
@subject.add(1,2)
@subject.add(3,4)
@subject.add(5,6)

error = assert_raises(Suture::Error::VerificationFailed) {
Suture.verify(:add, {
:subject => @subject.method(:broken_add),
:fail_fast => false
})
}
assert_match "- Failed........2", error.message
assert_match "- Skipped.......0", error.message
end

def test_fail_fast_enabled
@subject.add(1,2)
@subject.add(3,4)
@subject.add(5,6)

error = assert_raises(Suture::Error::VerificationFailed) {
Suture.verify(:add, {
:subject => @subject.method(:broken_add),
:fail_fast => true
})
}
assert_match "- Failed........1", error.message
assert_match "- Skipped.......1", error.message
end
end

0 comments on commit 417a0de

Please sign in to comment.