Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed warnings in library and tests #34

Merged
merged 1 commit into from Jun 5, 2013
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.
+27 −27
Diff settings

Always

Just for now

Copy path View file
@@ -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

Copy path View file
@@ -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)
Copy path View file
@@ -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
Copy path View file
@@ -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
Copy path View file
@@ -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
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.