Skip to content
This repository

Fixed warnings in library and tests #34

Merged
merged 1 commit into from about 1 year ago

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

Showing 1 unique commit by 1 author.

Jan 23, 2012
Joe Van Dyk joevandyk Fixed warnings in library and tests 4a00971
This page is out of date. Refresh to see the latest.
2  lib/crack/json.rb
@@ -10,7 +10,7 @@ module Crack
10 10 class JSON
11 11 def self.parse(json)
12 12 YAML.load(unescape(convert_json_to_yaml(json)))
13   - rescue ArgumentError => e
  13 + rescue ArgumentError
14 14 raise ParseError, "Invalid JSON string"
15 15 end
16 16
2  lib/crack/xml.rb
@@ -189,7 +189,7 @@ def unnormalize_xml_entities value
189 189 end
190 190
191 191 module Crack
192   - class REXMLParser
  192 + class REXMLParser
193 193 def self.parse(xml)
194 194 stack = []
195 195 parser = REXML::Parsers::BaseParser.new(xml)
12 test/parser_test.rb
@@ -6,18 +6,18 @@ class ParserTest < Test::Unit::TestCase
6 6 end
7 7
8 8 context "with a custom Parser" do
9   - class CustomParser
10   - def self.parse(xml)
11   - xml
12   - end
13   - end
  9 + class CustomParser
  10 + def self.parse(xml)
  11 + xml
  12 + end
  13 + end
14 14
15 15 setup do
16 16 Crack::XML.parser = CustomParser
17 17 end
18 18
19 19 should "use the custom Parser" do
20   - Crack::XML.parse("<xml/>").should == "<xml/>"
  20 + Crack::XML.parse("<xml/>").should == "<xml/>"
21 21 end
22 22
23 23 teardown do
6 test/string_test.rb
@@ -15,8 +15,8 @@ class CrackTest < Test::Unit::TestCase
15 15 end
16 16
17 17 should "handles CamelCase with more than 2 capital letter in a row" do
18   - Crack::Util.snake_case("CNN").should == "cnn"
19   - Crack::Util.snake_case("CNNNews").should == "cnn_news"
  18 + Crack::Util.snake_case("CNN").should be == "cnn"
  19 + Crack::Util.snake_case("CNNNews").should be == "cnn_news"
20 20 Crack::Util.snake_case("HeadlineCNNNews").should == "headline_cnn_news"
21 21 end
22 22
@@ -28,4 +28,4 @@ class CrackTest < Test::Unit::TestCase
28 28 Crack::Util.snake_case("merb_core").should == "merb_core"
29 29 end
30 30 end
31   -end
  31 +end
32 test/xml_test.rb
@@ -31,7 +31,7 @@ class XmlTest < Test::Unit::TestCase
31 31 </opt>
32 32 XML
33 33
34   - Crack::XML.parse(xml)['opt']['user'].class.should == Array
  34 + Crack::XML.parse(xml)['opt']['user'].class.should be == Array
35 35
36 36 hash = {
37 37 'opt' => {
@@ -55,7 +55,7 @@ class XmlTest < Test::Unit::TestCase
55 55 </opt>
56 56 XML
57 57
58   - Crack::XML.parse(xml)['opt']['user'].class.should == Hash
  58 + Crack::XML.parse(xml)['opt']['user'].class.should be == Hash
59 59
60 60 hash = {
61 61 'opt' => {
@@ -65,10 +65,10 @@ class XmlTest < Test::Unit::TestCase
65 65 }
66 66 }
67 67 }
68   -
  68 +
69 69 Crack::XML.parse(xml).should == hash
70 70 end
71   -
  71 +
72 72 context "Parsing xml with text and attributes" do
73 73 setup do
74 74 xml =<<-XML
@@ -90,20 +90,20 @@ class XmlTest < Test::Unit::TestCase
90 90 }
91 91 }
92 92 end
93   -
  93 +
94 94 should "be parse attributes for text node if present" do
95 95 @data['opt']['user'][0].attributes.should == {'login' => 'grep'}
96 96 end
97   -
  97 +
98 98 should "default attributes to empty hash if not present" do
99 99 @data['opt']['user'][1].attributes.should == {}
100 100 end
101   -
  101 +
102 102 should "add 'attributes' accessor methods to parsed instances of String" do
103 103 @data['opt']['user'][0].respond_to?(:attributes).should be(true)
104 104 @data['opt']['user'][0].respond_to?(:attributes=).should be(true)
105 105 end
106   -
  106 +
107 107 should "not add 'attributes' accessor methods to all instances of String" do
108 108 "some-string".respond_to?(:attributes).should be(false)
109 109 "some-string".respond_to?(:attributes=).should be(false)
@@ -149,7 +149,7 @@ class XmlTest < Test::Unit::TestCase
149 149 Crack::XML.parse(xml)['tag'].should =~ Regexp.new(k)
150 150 end
151 151 end
152   -
  152 +
153 153 should "should unescape XML entities in attributes" do
154 154 xml_entities.each do |k,v|
155 155 xml = "<tag attr='Some content #{v}'></tag>"
@@ -421,8 +421,8 @@ class XmlTest < Test::Unit::TestCase
421 421 hash['blog'].keys.should include('logo')
422 422
423 423 file = hash['blog']['logo']
424   - file.original_filename.should == 'logo.png'
425   - file.content_type.should == 'image/png'
  424 + file.original_filename.should be == 'logo.png'
  425 + file.content_type.should be == 'image/png'
426 426 end
427 427
428 428 should "should handle file from xml with defaults (ActiveSupport Compatible)" do
@@ -433,8 +433,8 @@ class XmlTest < Test::Unit::TestCase
433 433 </blog>
434 434 XML
435 435 file = Crack::XML.parse(blog_xml)['blog']['logo']
436   - file.original_filename.should == 'untitled'
437   - file.content_type.should == 'application/octet-stream'
  436 + file.original_filename.should be == 'untitled'
  437 + file.content_type.should be == 'application/octet-stream'
438 438 end
439 439
440 440 should "should handle xsd like types from xml (ActiveSupport Compatible)" do
@@ -487,13 +487,13 @@ class XmlTest < Test::Unit::TestCase
487 487
488 488 Crack::XML.parse(xml_string)['person'].should == expected_hash
489 489 end
490   -
  490 +
491 491 should "handle an empty xml string" do
492 492 Crack::XML.parse('').should == {}
493 493 end
494   -
  494 +
495 495 # As returned in the response body by the unfuddle XML API when creating objects
496 496 should "handle an xml string containing a single space" do
497 497 Crack::XML.parse(' ').should == {}
498 498 end
499   -end
  499 +end

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.