Permalink
Browse files

compatible now with Ruby 1.9 and Ruby 1.8

  • Loading branch information...
1 parent 15cc1cd commit 01ad3cc37dd58dcbc0eaf8885de3cb53859df07f @alto committed Jun 22, 2012
Showing with 61 additions and 51 deletions.
  1. +1 −2 lib/seatbelt/assert_mail.rb
  2. +20 −20 test/assert_json_old_dsl_test.rb
  3. +20 −20 test/assert_json_test.rb
  4. +9 −9 test/assert_mail_test.rb
  5. +11 −0 test/test_helper.rb
@@ -40,8 +40,7 @@ def got_mail?(mail, options={})
end
end
-
-if Module.const_defined?(:ActionMailer)
+if Object.const_defined?(:ActionMailer)
class Test::Unit::TestCase
include Seatbelt::AssertMail
end
@@ -9,7 +9,7 @@ class Seatbelt::AssertJsonTest < Test::Unit::TestCase
# end
# end
# def test_string_crosscheck
- # assert_raises(MiniTest::Assertion) do
+ # assert_assertion_fails do
# assert_json '"key"' do |json|
# json.element 'wrong_key'
# end
@@ -33,14 +33,14 @@ def test_single_hash
end
end
def test_single_hash_crosscheck_for_key
- assert_raises(MiniTest::Assertion) do
+ assert_assertion_fails do
assert_json '{"key":"value"}' do |json|
json.element 'wrong_key', 'value'
end
end
end
def test_single_hash_crosscheck_for_value
- assert_raises(MiniTest::Assertion) do
+ assert_assertion_fails do
assert_json '{"key":"value"}' do |json|
json.element 'key', 'wrong_value'
end
@@ -54,7 +54,7 @@ def test_not_element
end
end
def test_not_element_crosscheck
- assert_raises(MiniTest::Assertion) do
+ assert_assertion_fails do
assert_json '{"key":"value"}' do |json|
json.not_element 'key'
end
@@ -76,21 +76,21 @@ def test_not_element_array
end
end
def test_array_crosscheck_order
- assert_raises(MiniTest::Assertion) do
+ assert_assertion_fails do
assert_json '["value1","value2","value3"]' do |json|
json.element 'value2'
end
end
end
def test_array_crosscheck_for_first_item
- assert_raises(MiniTest::Assertion) do
+ assert_assertion_fails do
assert_json '["value1","value2","value3"]' do |json|
json.element 'wrong_value1'
end
end
end
def test_array_crosscheck_for_second_item
- assert_raises(MiniTest::Assertion) do
+ assert_assertion_fails do
assert_json '["value1","value2","value3"]' do |json|
json.element 'value1'
json.element 'wrong_value2'
@@ -104,12 +104,12 @@ def test_nested_arrays
end
end
def test_nested_arrays_crosscheck
- assert_raises(MiniTest::Assertion) do
+ assert_assertion_fails do
assert_json '[[["deep","another_depp"],["second_deep"]]]' do |json|
json.element [["deep","wrong_another_depp"],["second_deep"]]
end
end
- assert_raises(MiniTest::Assertion) do
+ assert_assertion_fails do
assert_json '[[["deep","another_depp"],["second_deep"]]]' do |json|
json.element [["deep","another_depp"],["wrong_second_deep"]]
end
@@ -122,21 +122,21 @@ def test_hash_with_value_array
end
end
def test_hash_with_value_array_crosscheck_wrong_key
- assert_raises(MiniTest::Assertion) do
+ assert_assertion_fails do
assert_json '{"key":["value1","value2"]}' do |json|
json.element 'wrong_key', ['value1', 'value2']
end
end
end
def test_hash_with_value_array_crosscheck_wrong_value1
- assert_raises(MiniTest::Assertion) do
+ assert_assertion_fails do
assert_json '{"key":["value1","value2"]}' do |json|
json.element 'key', ['wrong_value1', 'value2']
end
end
end
def test_hash_with_value_array_crosscheck_wrong_value2
- assert_raises(MiniTest::Assertion) do
+ assert_assertion_fails do
assert_json '{"key":["value1","value2"]}' do |json|
json.element 'key', ['value1', 'wrong_value2']
end
@@ -152,7 +152,7 @@ def test_hash_with_array_of_hashes
end
end
def test_hash_with_array_of_hashes_crosscheck_inner_key
- assert_raises(MiniTest::Assertion) do
+ assert_assertion_fails do
assert_json '{"key":[{"inner_key1":"value1"},{"inner_key2":"value2"}]}' do |json|
json.element 'key' do
json.element 'wrong_inner_key1', 'value1'
@@ -161,7 +161,7 @@ def test_hash_with_array_of_hashes_crosscheck_inner_key
end
end
def test_hash_with_array_of_hashes_crosscheck_inner_value
- assert_raises(MiniTest::Assertion) do
+ assert_assertion_fails do
assert_json '{"key":[{"inner_key1":"value1"},{"inner_key2":"value2"}]}' do |json|
json.element 'key' do
json.element 'inner_key1', 'wrong_value1'
@@ -184,13 +184,13 @@ def test_array_with_nested_hashes
end
end
def test_array_with_two_hashes_crosscheck
- assert_raises(MiniTest::Assertion) do
+ assert_assertion_fails do
assert_json '[{"key1":"value1"}, {"key2":"value2"}]' do |json|
json.element 'wrong_key1', 'value1'
json.element 'key2', 'value2'
end
end
- assert_raises(MiniTest::Assertion) do
+ assert_assertion_fails do
assert_json '[{"key1":"value1"}, {"key2":"value2"}]' do |json|
json.element 'key1', 'value1'
json.element 'key2', 'wrong_value2'
@@ -208,12 +208,12 @@ def test_nested_hashes
end
end
def test_nested_hashes_crosscheck
- assert_raises(MiniTest::Assertion) do
+ assert_assertion_fails do
assert_json '{"outer_key":{"key":{"inner_key":"value"}}}' do |json|
json.element 'wrong_outer_key'
end
end
- assert_raises(MiniTest::Assertion) do
+ assert_assertion_fails do
assert_json '{"outer_key":{"key":{"inner_key":"value"}}}' do |json|
json.element 'outer_key' do
json.element 'key' do
@@ -245,7 +245,7 @@ def test_real_xws
end
def test_not_enough_elements_in_array
- assert_raises(MiniTest::Assertion) do
+ assert_assertion_fails do
assert_json '["one","two"]' do |json|
json.element "one"
json.element "two"
@@ -255,7 +255,7 @@ def test_not_enough_elements_in_array
end
def test_not_enough_elements_in_hash_array
- assert_raises(MiniTest::Assertion) do
+ assert_assertion_fails do
assert_json '{"key":[{"key1":"value1"}, {"key2":"value2"}]}' do |json|
json.element 'key' do
json.element 'key1', 'value1'
View
@@ -9,7 +9,7 @@ class Seatbelt::AssertJsonNewDslTest < Test::Unit::TestCase
# end
# end
# def test_string_crosscheck
- # assert_raises(MiniTest::Assertion) do
+ # assert_assertion_fails do
# assert_json '"key"' do
# has 'wrong_key'
# end
@@ -38,14 +38,14 @@ def test_single_hash_with_outer_variable
end
end
def test_single_hash_crosscheck_for_key
- assert_raises(MiniTest::Assertion) do
+ assert_assertion_fails do
assert_json '{"key":"value"}' do
has 'wrong_key', 'value'
end
end
end
def test_single_hash_crosscheck_for_value
- assert_raises(MiniTest::Assertion) do
+ assert_assertion_fails do
assert_json '{"key":"value"}' do
has 'key', 'wrong_value'
end
@@ -59,7 +59,7 @@ def test_has_not
end
end
def test_has_not_crosscheck
- assert_raises(MiniTest::Assertion) do
+ assert_assertion_fails do
assert_json '{"key":"value"}' do
has_not 'key'
end
@@ -81,21 +81,21 @@ def test_has_not_array
end
end
def test_array_crosscheck_order
- assert_raises(MiniTest::Assertion) do
+ assert_assertion_fails do
assert_json '["value1","value2","value3"]' do
has 'value2'
end
end
end
def test_array_crosscheck_for_first_item
- assert_raises(MiniTest::Assertion) do
+ assert_assertion_fails do
assert_json '["value1","value2","value3"]' do
has 'wrong_value1'
end
end
end
def test_array_crosscheck_for_second_item
- assert_raises(MiniTest::Assertion) do
+ assert_assertion_fails do
assert_json '["value1","value2","value3"]' do
has 'value1'
has 'wrong_value2'
@@ -109,12 +109,12 @@ def test_nested_arrays
end
end
def test_nested_arrays_crosscheck
- assert_raises(MiniTest::Assertion) do
+ assert_assertion_fails do
assert_json '[[["deep","another_depp"],["second_deep"]]]' do
has [["deep","wrong_another_depp"],["second_deep"]]
end
end
- assert_raises(MiniTest::Assertion) do
+ assert_assertion_fails do
assert_json '[[["deep","another_depp"],["second_deep"]]]' do
has [["deep","another_depp"],["wrong_second_deep"]]
end
@@ -127,21 +127,21 @@ def test_hash_with_value_array
end
end
def test_hash_with_value_array_crosscheck_wrong_key
- assert_raises(MiniTest::Assertion) do
+ assert_assertion_fails do
assert_json '{"key":["value1","value2"]}' do
has 'wrong_key', ['value1', 'value2']
end
end
end
def test_hash_with_value_array_crosscheck_wrong_value1
- assert_raises(MiniTest::Assertion) do
+ assert_assertion_fails do
assert_json '{"key":["value1","value2"]}' do
has 'key', ['wrong_value1', 'value2']
end
end
end
def test_hash_with_value_array_crosscheck_wrong_value2
- assert_raises(MiniTest::Assertion) do
+ assert_assertion_fails do
assert_json '{"key":["value1","value2"]}' do
has 'key', ['value1', 'wrong_value2']
end
@@ -157,7 +157,7 @@ def test_hash_with_array_of_hashes
end
end
def test_hash_with_array_of_hashes_crosscheck_inner_key
- assert_raises(MiniTest::Assertion) do
+ assert_assertion_fails do
assert_json '{"key":[{"inner_key1":"value1"},{"inner_key2":"value2"}]}' do
has 'key' do
has 'wrong_inner_key1', 'value1'
@@ -166,7 +166,7 @@ def test_hash_with_array_of_hashes_crosscheck_inner_key
end
end
def test_hash_with_array_of_hashes_crosscheck_inner_value
- assert_raises(MiniTest::Assertion) do
+ assert_assertion_fails do
assert_json '{"key":[{"inner_key1":"value1"},{"inner_key2":"value2"}]}' do
has 'key' do
has 'inner_key1', 'wrong_value1'
@@ -189,13 +189,13 @@ def test_array_with_nested_hashes
end
end
def test_array_with_two_hashes_crosscheck
- assert_raises(MiniTest::Assertion) do
+ assert_assertion_fails do
assert_json '[{"key1":"value1"}, {"key2":"value2"}]' do
has 'wrong_key1', 'value1'
has 'key2', 'value2'
end
end
- assert_raises(MiniTest::Assertion) do
+ assert_assertion_fails do
assert_json '[{"key1":"value1"}, {"key2":"value2"}]' do
has 'key1', 'value1'
has 'key2', 'wrong_value2'
@@ -213,12 +213,12 @@ def test_nested_hashes
end
end
def test_nested_hashes_crosscheck
- assert_raises(MiniTest::Assertion) do
+ assert_assertion_fails do
assert_json '{"outer_key":{"key":{"inner_key":"value"}}}' do
has 'wrong_outer_key'
end
end
- assert_raises(MiniTest::Assertion) do
+ assert_assertion_fails do
assert_json '{"outer_key":{"key":{"inner_key":"value"}}}' do
has 'outer_key' do
has 'key' do
@@ -250,7 +250,7 @@ def test_real_xws
end
def test_not_enough_hass_in_array
- assert_raises(MiniTest::Assertion) do
+ assert_assertion_fails do
assert_json '["one","two"]' do
has "one"
has "two"
@@ -260,7 +260,7 @@ def test_not_enough_hass_in_array
end
def test_not_enough_hass_in_hash_array
- assert_raises(MiniTest::Assertion) do
+ assert_assertion_fails do
assert_json '{"key":[{"key1":"value1"}, {"key2":"value2"}]}' do
has 'key' do
has 'key1', 'value1'
View
@@ -20,13 +20,13 @@ def test_assert_mail
def test_assert_mail_crosscheck
Mailer.test.deliver
- assert_raises(MiniTest::Assertion) { assert_mail :to => 'unknown@seatbelt.co.nz' }
- assert_raises(MiniTest::Assertion) { assert_mail :cc => 'unknown@seatbelt.co.nz' }
- assert_raises(MiniTest::Assertion) { assert_mail :bcc => 'unknown@seatbelt.co.nz' }
- assert_raises(MiniTest::Assertion) { assert_mail :from => 'unknown@seatbelt.co.nz' }
- assert_raises(MiniTest::Assertion) { assert_mail :subject => 'unknown' }
- assert_raises(MiniTest::Assertion) { assert_mail :body => 'unknown' }
- assert_raises(MiniTest::Assertion) { assert_mail :to => 'unknown@seatbelt.co.nz', :subject => 'unknown', :body => 'unknown' }
+ assert_assertion_fails { assert_mail :to => 'unknown@seatbelt.co.nz' }
+ assert_assertion_fails { assert_mail :cc => 'unknown@seatbelt.co.nz' }
+ assert_assertion_fails { assert_mail :bcc => 'unknown@seatbelt.co.nz' }
+ assert_assertion_fails { assert_mail :from => 'unknown@seatbelt.co.nz' }
+ assert_assertion_fails { assert_mail :subject => 'unknown' }
+ assert_assertion_fails { assert_mail :body => 'unknown' }
+ assert_assertion_fails { assert_mail :to => 'unknown@seatbelt.co.nz', :subject => 'unknown', :body => 'unknown' }
end
def test_assert_mail_with_multiple_mails
@@ -43,7 +43,7 @@ def test_assert_mail_with_block
end
end
def test_assert_mail_with_block_crosscheck
- assert_raises(MiniTest::Assertion) do
+ assert_assertion_fails do
assert_mail :to => 'unknown@seatbelt.co.nz' do
Mailer.test.deliver
end
@@ -68,7 +68,7 @@ def test_assert_no_mail
end
def test_assert_no_mail_crosscheck
- assert_raises(MiniTest::Assertion) do
+ assert_assertion_fails do
assert_no_mail :to => 'test@seatbelt.co.nz' do
Mailer.test.deliver
end
Oops, something went wrong.

0 comments on commit 01ad3cc

Please sign in to comment.