diff options
Diffstat (limited to 'activeresource/test')
-rw-r--r-- | activeresource/test/authorization_test.rb | 8 | ||||
-rw-r--r-- | activeresource/test/base/load_test.rb | 6 | ||||
-rw-r--r-- | activeresource/test/base_errors_test.rb | 6 | ||||
-rw-r--r-- | activeresource/test/base_test.rb | 13 | ||||
-rw-r--r-- | activeresource/test/connection_test.rb | 4 | ||||
-rw-r--r-- | activeresource/test/fixtures/person.rb | 2 |
6 files changed, 21 insertions, 18 deletions
diff --git a/activeresource/test/authorization_test.rb b/activeresource/test/authorization_test.rb index 1a1a681a59..58bd36cb77 100644 --- a/activeresource/test/authorization_test.rb +++ b/activeresource/test/authorization_test.rb @@ -20,7 +20,7 @@ class AuthorizationTest < Test::Unit::TestCase end def test_authorization_header - authorization_header = @authenticated_conn.send(:authorization_header) + authorization_header = @authenticated_conn.send!(:authorization_header) assert_equal @authorization_request_header['Authorization'], authorization_header['Authorization'] authorization = authorization_header["Authorization"].to_s.split @@ -30,7 +30,7 @@ class AuthorizationTest < Test::Unit::TestCase def test_authorization_header_with_username_but_no_password @conn = ActiveResource::Connection.new("http://david:@localhost") - authorization_header = @conn.send(:authorization_header) + authorization_header = @conn.send!(:authorization_header) authorization = authorization_header["Authorization"].to_s.split assert_equal "Basic", authorization[0] @@ -39,7 +39,7 @@ class AuthorizationTest < Test::Unit::TestCase def test_authorization_header_with_password_but_no_username @conn = ActiveResource::Connection.new("http://:test123@localhost") - authorization_header = @conn.send(:authorization_header) + authorization_header = @conn.send!(:authorization_header) authorization = authorization_header["Authorization"].to_s.split assert_equal "Basic", authorization[0] @@ -76,7 +76,7 @@ class AuthorizationTest < Test::Unit::TestCase protected def assert_response_raises(klass, code) assert_raise(klass, "Expected response code #{code} to raise #{klass}") do - @conn.send(:handle_response, Response.new(code)) + @conn.send!(:handle_response, Response.new(code)) end end end diff --git a/activeresource/test/base/load_test.rb b/activeresource/test/base/load_test.rb index 28f1cfc97c..622afb2fdf 100644 --- a/activeresource/test/base/load_test.rb +++ b/activeresource/test/base/load_test.rb @@ -61,7 +61,7 @@ class BaseLoadTest < Test::Unit::TestCase end def test_load_collection_with_unknown_resource - Person.send(:remove_const, :Address) if Person.const_defined?(:Address) + Person.send!(:remove_const, :Address) if Person.const_defined?(:Address) assert !Person.const_defined?(:Address), "Address shouldn't exist until autocreated" addresses = silence_warnings { @person.load(:addresses => @addresses).addresses } assert Person.const_defined?(:Address), "Address should have been autocreated" @@ -77,7 +77,7 @@ class BaseLoadTest < Test::Unit::TestCase end def test_load_collection_with_single_unknown_resource - Person.send(:remove_const, :Address) if Person.const_defined?(:Address) + Person.send!(:remove_const, :Address) if Person.const_defined?(:Address) assert !Person.const_defined?(:Address), "Address shouldn't exist until autocreated" addresses = silence_warnings { @person.load(:addresses => [ @first_address ]).addresses } assert Person.const_defined?(:Address), "Address should have been autocreated" @@ -108,4 +108,4 @@ class BaseLoadTest < Test::Unit::TestCase n = Highrise::Note.new(:comments => [{ :name => "1" }]) assert_kind_of Highrise::Comment, n.comments.first end -end
\ No newline at end of file +end diff --git a/activeresource/test/base_errors_test.rb b/activeresource/test/base_errors_test.rb index f9aa58016d..8706326b13 100644 --- a/activeresource/test/base_errors_test.rb +++ b/activeresource/test/base_errors_test.rb @@ -29,13 +29,13 @@ class BaseErrorsTest < Test::Unit::TestCase def test_should_iterate_over_errors errors = [] @person.errors.each { |attribute, message| errors << [attribute, message] } - assert_equal ["name", "can't be blank"], errors.first + assert errors.include?(["name", "can't be blank"]) end def test_should_iterate_over_full_errors errors = [] @person.errors.each_full { |message| errors << message } - assert_equal "Name can't be blank", errors.first + assert errors.include?("Name can't be blank") end def test_should_format_full_errors @@ -45,4 +45,4 @@ class BaseErrorsTest < Test::Unit::TestCase assert full.include?("Name must start with a letter") assert full.include?("Person quota full for today.") end -end
\ No newline at end of file +end diff --git a/activeresource/test/base_test.rb b/activeresource/test/base_test.rb index a1051e5875..f97b08295a 100644 --- a/activeresource/test/base_test.rb +++ b/activeresource/test/base_test.rb @@ -181,7 +181,7 @@ class BaseTest < Test::Unit::TestCase def test_prefix assert_equal "/", Person.prefix - assert_equal Set.new, Person.send(:prefix_parameters) + assert_equal Set.new, Person.send!(:prefix_parameters) end def test_set_prefix @@ -208,7 +208,7 @@ class BaseTest < Test::Unit::TestCase def test_custom_prefix assert_equal '/people//', StreetAddress.prefix assert_equal '/people/1/', StreetAddress.prefix(:person_id => 1) - assert_equal [:person_id].to_set, StreetAddress.send(:prefix_parameters) + assert_equal [:person_id].to_set, StreetAddress.send!(:prefix_parameters) end def test_find_by_id @@ -305,10 +305,10 @@ class BaseTest < Test::Unit::TestCase def test_id_from_response p = Person.new resp = {'Location' => '/foo/bar/1'} - assert_equal '1', p.send(:id_from_response, resp) + assert_equal '1', p.send!(:id_from_response, resp) resp['Location'] << '.xml' - assert_equal '1', p.send(:id_from_response, resp) + assert_equal '1', p.send!(:id_from_response, resp) end def test_create_with_custom_prefix @@ -439,6 +439,9 @@ class BaseTest < Test::Unit::TestCase def test_to_xml matz = Person.find(1) - assert_equal "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<person>\n <name>Matz</name>\n <id type=\"integer\">1</id>\n</person>\n", matz.to_xml + xml = matz.to_xml + assert xml.starts_with?('<?xml version="1.0" encoding="UTF-8"?>') + assert xml.include?('<name>Matz</name>') + assert xml.include?('<id type="integer">1</id>') end end diff --git a/activeresource/test/connection_test.rb b/activeresource/test/connection_test.rb index 68d57018bf..09e80f95c1 100644 --- a/activeresource/test/connection_test.rb +++ b/activeresource/test/connection_test.rb @@ -13,7 +13,7 @@ class ConnectionTest < Test::Unit::TestCase @people_empty = [ ].to_xml(:root => 'people-empty-elements') @matz = @matz.to_xml(:root => 'person') @david = @david.to_xml(:root => 'person') - @header = {'key' => 'value'} + @header = {'key' => 'value'}.freeze @default_request_headers = { 'Content-Type' => 'application/xml' } ActiveResource::HttpMock.respond_to do |mock| @@ -156,6 +156,6 @@ class ConnectionTest < Test::Unit::TestCase end def handle_response(response) - @conn.send(:handle_response, response) + @conn.send!(:handle_response, response) end end diff --git a/activeresource/test/fixtures/person.rb b/activeresource/test/fixtures/person.rb index 8e5768586a..e88bb69310 100644 --- a/activeresource/test/fixtures/person.rb +++ b/activeresource/test/fixtures/person.rb @@ -1,3 +1,3 @@ class Person < ActiveResource::Base self.site = "http://37s.sunrise.i:3000" -end
\ No newline at end of file +end |