Skip to content

Commit

Permalink
fix a lot of annoying ruby warnings
Browse files Browse the repository at this point in the history
Signed-off-by: Jeremy McAnally <jeremymcanally@gmail.com>
  • Loading branch information
technoweenie authored and jm committed Jan 31, 2009
1 parent 55e64c1 commit 1318933
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 19 deletions.
10 changes: 10 additions & 0 deletions lib/matchy/built_in/error_expectations.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
module Matchy
module Expectations
class RaiseErrorExpectation < Base
def initialize(expected, test_case)
@error = nil
super
end

def matches?(receiver)
@receiver = receiver
begin
Expand Down Expand Up @@ -31,6 +36,11 @@ def negative_failure_message
end

class ThrowSymbolExpectation < Base
def initialize(expected, test_case)
@thrown_symbol = nil
super
end

def matches?(receiver)
@receiver = receiver
begin
Expand Down
8 changes: 4 additions & 4 deletions test/test_enumerable_expectations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,27 +65,27 @@ def test_include_fail_message
obj = include(1)
obj.matches?([4,5,6])

obj.failure_message.should be "Expected [4, 5, 6] to include [1]."
obj.failure_message.should be("Expected [4, 5, 6] to include [1].")
end

def test_include_negative_fail_message
obj = include(1)
obj.matches?([4,5,6])

obj.negative_failure_message.should be "Expected [4, 5, 6] to not include [1]."
obj.negative_failure_message.should be("Expected [4, 5, 6] to not include [1].")
end

def test_exclude_fail_message
obj = exclude(4)
obj.matches?([4,5,6])

obj.failure_message.should be "Expected [4, 5, 6] to exclude [4]."
obj.failure_message.should be("Expected [4, 5, 6] to exclude [4].")
end

def test_exclude_negative_fail_message
obj = exclude(4)
obj.matches?([4,5,6])

obj.negative_failure_message.should be "Expected [4, 5, 6] to not exclude [4]."
obj.negative_failure_message.should be("Expected [4, 5, 6] to not exclude [4].")
end
end
30 changes: 15 additions & 15 deletions test/test_truth_expectations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,28 +135,28 @@ def test_equal_fail_message
obj = equal(4)
obj.matches?(5)

obj.failure_message.should be "Expected 5 to equal 4."
obj.failure_message.should be("Expected 5 to equal 4.")
end

def test_equal_negative_fail_message
obj = equal(5)
obj.matches?(5)

obj.negative_failure_message.should be "Expected 5 to not equal 5."
obj.negative_failure_message.should be("Expected 5 to not equal 5.")
end

def test_eql_fail_message
obj = eql(4)
obj.matches?(5)

obj.failure_message.should be "Expected 5 to eql 4."
obj.failure_message.should be("Expected 5 to eql 4.")
end

def test_eql_negative_fail_message
def test_eql_negative_fail_message_for_eql
obj = eql(5)
obj.matches?(5)

obj.negative_failure_message.should be "Expected 5 to not eql 5."
obj.negative_failure_message.should be("Expected 5 to not eql 5.")
end

def test_exist_fail_message
Expand All @@ -177,42 +177,42 @@ def test_be_close_fail_message
obj = be_close(3.0)
obj.matches?(6.0)

obj.failure_message.should be "Expected 6.0 to be close to 3.0 (delta: 0.3)."
obj.failure_message.should be("Expected 6.0 to be close to 3.0 (delta: 0.3).")
end

def test_be_close_negative_fail_message
obj = be_close(5.0)
obj.matches?(5.0)

obj.negative_failure_message.should be "Expected 5.0 to not be close to 5.0 (delta: 0.3)."
obj.negative_failure_message.should be("Expected 5.0 to not be close to 5.0 (delta: 0.3).")
end

def test_be_fail_message
obj = be(4)
obj.matches?(5)

obj.failure_message.should be "Expected 5 to be 4."
obj.failure_message.should be("Expected 5 to be 4.")
end

def test_be_negative_fail_message
obj = be(5)
obj.matches?(5)

obj.negative_failure_message.should be "Expected 5 to not be 5."
obj.negative_failure_message.should be("Expected 5 to not be 5.")
end

def test_satisfy_fail_message
obj = satisfy(lambda {|x| x == 4})
obj.matches?(6)

obj.failure_message.should be "Expected 6 to satisfy given block."
obj.failure_message.should be("Expected 6 to satisfy given block.")
end

def test_eql_negative_fail_message
def test_eql_negative_fail_message_for_matches
obj = satisfy(lambda {|x| x == 4})
obj.matches?(4)

obj.negative_failure_message.should be "Expected 4 to not satisfy given block."
obj.negative_failure_message.should be("Expected 4 to not satisfy given block.")
end

def test_kind_of
Expand All @@ -239,17 +239,17 @@ def test_respond_to
"foo".should respond_to?(:length)
end

def test_kind_of_fail
def test_respond_to_fail
lambda {
"foo".should respond_to?(:nonexistant_method)
}.should raise_error(Test::Unit::AssertionFailedError)
end

def test_negative_kind_of
def test_negative_respond_to
"foo".should_not respond_to?(:nonexistant_method)
end

def test_negative_kind_of_fail
def test_negative_respond_to_fail
lambda {
"foo".should_not respond_to?(:length)
}.should raise_error(Test::Unit::AssertionFailedError)
Expand Down

0 comments on commit 1318933

Please sign in to comment.