Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fixed warnings in library and tests #34

Merged
merged 1 commit into from

3 participants

Joe Van Dyk Kenichi Kamiya John Nunemaker
Joe Van Dyk

No description provided.

Joe Van Dyk

BTW, tests on master are failing for me. Using Ruby 1.9.3.

John Nunemaker jnunemaker merged commit c8bf525 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 23, 2012
  1. Joe Van Dyk
This page is out of date. Refresh to see the latest.
2  lib/crack/json.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
2  lib/crack/xml.rb
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)
12 test/parser_test.rb
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
6 test/string_test.rb
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
32 test/xml_test.rb
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
Something went wrong with that request. Please try again.