Permalink
Browse files

Fixed warnings in library and tests

  • Loading branch information...
1 parent b1b1658 commit 4a00971accfdaf30bf891a1e2a68930bc970f441 Joe Van Dyk committed Jan 23, 2012
Showing with 27 additions and 27 deletions.
  1. +1 −1 lib/crack/json.rb
  2. +1 −1 lib/crack/xml.rb
  3. +6 −6 test/parser_test.rb
  4. +3 −3 test/string_test.rb
  5. +16 −16 test/xml_test.rb
View
@@ -10,7 +10,7 @@ module Crack
class JSON
def self.parse(json)
YAML.load(unescape(convert_json_to_yaml(json)))
- rescue ArgumentError => e
+ rescue ArgumentError
raise ParseError, "Invalid JSON string"
end
View
@@ -189,7 +189,7 @@ def unnormalize_xml_entities value
end
module Crack
- class REXMLParser
+ class REXMLParser
def self.parse(xml)
stack = []
parser = REXML::Parsers::BaseParser.new(xml)
View
@@ -6,18 +6,18 @@ class ParserTest < Test::Unit::TestCase
end
context "with a custom Parser" do
- class CustomParser
- def self.parse(xml)
- xml
- end
- end
+ class CustomParser
+ def self.parse(xml)
+ xml
+ end
+ end
setup do
Crack::XML.parser = CustomParser
end
should "use the custom Parser" do
- Crack::XML.parse("<xml/>").should == "<xml/>"
+ Crack::XML.parse("<xml/>").should == "<xml/>"
end
teardown do
View
@@ -15,8 +15,8 @@ class CrackTest < Test::Unit::TestCase
end
should "handles CamelCase with more than 2 capital letter in a row" do
- Crack::Util.snake_case("CNN").should == "cnn"
- Crack::Util.snake_case("CNNNews").should == "cnn_news"
+ Crack::Util.snake_case("CNN").should be == "cnn"
+ Crack::Util.snake_case("CNNNews").should be == "cnn_news"
Crack::Util.snake_case("HeadlineCNNNews").should == "headline_cnn_news"
end
@@ -28,4 +28,4 @@ class CrackTest < Test::Unit::TestCase
Crack::Util.snake_case("merb_core").should == "merb_core"
end
end
-end
+end
View
@@ -31,7 +31,7 @@ class XmlTest < Test::Unit::TestCase
</opt>
XML
- Crack::XML.parse(xml)['opt']['user'].class.should == Array
+ Crack::XML.parse(xml)['opt']['user'].class.should be == Array
hash = {
'opt' => {
@@ -55,7 +55,7 @@ class XmlTest < Test::Unit::TestCase
</opt>
XML
- Crack::XML.parse(xml)['opt']['user'].class.should == Hash
+ Crack::XML.parse(xml)['opt']['user'].class.should be == Hash
hash = {
'opt' => {
@@ -65,10 +65,10 @@ class XmlTest < Test::Unit::TestCase
}
}
}
-
+
Crack::XML.parse(xml).should == hash
end
-
+
context "Parsing xml with text and attributes" do
setup do
xml =<<-XML
@@ -90,20 +90,20 @@ class XmlTest < Test::Unit::TestCase
}
}
end
-
+
should "be parse attributes for text node if present" do
@data['opt']['user'][0].attributes.should == {'login' => 'grep'}
end
-
+
should "default attributes to empty hash if not present" do
@data['opt']['user'][1].attributes.should == {}
end
-
+
should "add 'attributes' accessor methods to parsed instances of String" do
@data['opt']['user'][0].respond_to?(:attributes).should be(true)
@data['opt']['user'][0].respond_to?(:attributes=).should be(true)
end
-
+
should "not add 'attributes' accessor methods to all instances of String" do
"some-string".respond_to?(:attributes).should be(false)
"some-string".respond_to?(:attributes=).should be(false)
@@ -149,7 +149,7 @@ class XmlTest < Test::Unit::TestCase
Crack::XML.parse(xml)['tag'].should =~ Regexp.new(k)
end
end
-
+
should "should unescape XML entities in attributes" do
xml_entities.each do |k,v|
xml = "<tag attr='Some content #{v}'></tag>"
@@ -421,8 +421,8 @@ class XmlTest < Test::Unit::TestCase
hash['blog'].keys.should include('logo')
file = hash['blog']['logo']
- file.original_filename.should == 'logo.png'
- file.content_type.should == 'image/png'
+ file.original_filename.should be == 'logo.png'
+ file.content_type.should be == 'image/png'
end
should "should handle file from xml with defaults (ActiveSupport Compatible)" do
@@ -433,8 +433,8 @@ class XmlTest < Test::Unit::TestCase
</blog>
XML
file = Crack::XML.parse(blog_xml)['blog']['logo']
- file.original_filename.should == 'untitled'
- file.content_type.should == 'application/octet-stream'
+ file.original_filename.should be == 'untitled'
+ file.content_type.should be == 'application/octet-stream'
end
should "should handle xsd like types from xml (ActiveSupport Compatible)" do
@@ -487,13 +487,13 @@ class XmlTest < Test::Unit::TestCase
Crack::XML.parse(xml_string)['person'].should == expected_hash
end
-
+
should "handle an empty xml string" do
Crack::XML.parse('').should == {}
end
-
+
# As returned in the response body by the unfuddle XML API when creating objects
should "handle an xml string containing a single space" do
Crack::XML.parse(' ').should == {}
end
-end
+end

0 comments on commit 4a00971

Please sign in to comment.