alexvollmer-httparty 0.2.6 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. data/History +34 -0
  2. data/Manifest +25 -2
  3. data/README +2 -2
  4. data/Rakefile +6 -2
  5. data/bin/httparty +39 -44
  6. data/cucumber.yml +1 -0
  7. data/examples/basic.rb +6 -1
  8. data/examples/delicious.rb +1 -0
  9. data/examples/rubyurl.rb +1 -1
  10. data/features/basic_authentication.feature +20 -0
  11. data/features/command_line.feature +7 -0
  12. data/features/deals_with_http_error_codes.feature +26 -0
  13. data/features/handles_multiple_formats.feature +34 -0
  14. data/features/steps/env.rb +15 -0
  15. data/features/steps/httparty_response_steps.rb +26 -0
  16. data/features/steps/httparty_steps.rb +15 -0
  17. data/features/steps/mongrel_helper.rb +55 -0
  18. data/features/steps/remote_service_steps.rb +47 -0
  19. data/features/supports_redirection.feature +22 -0
  20. data/httparty.gemspec +4 -7
  21. data/lib/core_extensions.rb +48 -222
  22. data/lib/httparty/cookie_hash.rb +9 -0
  23. data/lib/httparty/exceptions.rb +3 -0
  24. data/lib/httparty/module_inheritable_attributes.rb +25 -0
  25. data/lib/httparty/parsers/json.rb +74 -0
  26. data/lib/httparty/parsers/xml.rb +209 -0
  27. data/lib/httparty/parsers.rb +4 -0
  28. data/lib/httparty/request.rb +63 -76
  29. data/lib/httparty/response.rb +17 -0
  30. data/lib/httparty/version.rb +2 -2
  31. data/lib/httparty.rb +108 -19
  32. data/spec/fixtures/empty.xml +0 -0
  33. data/spec/fixtures/undefined_method_add_node_for_nil.xml +2 -0
  34. data/spec/hash_spec.rb +49 -0
  35. data/spec/httparty/cookie_hash_spec.rb +38 -0
  36. data/spec/httparty/parsers/json_spec.rb +42 -0
  37. data/spec/httparty/parsers/xml_spec.rb +445 -0
  38. data/spec/httparty/request_spec.rb +219 -80
  39. data/spec/httparty/response_spec.rb +53 -0
  40. data/spec/httparty_spec.rb +125 -64
  41. data/spec/spec_helper.rb +5 -8
  42. data/spec/string_spec.rb +27 -0
  43. metadata +34 -14
  44. data/lib/module_level_inheritable_attributes.rb +0 -25
  45. data/spec/as_buggery_spec.rb +0 -16
data/spec/spec_helper.rb CHANGED
@@ -10,15 +10,12 @@ end
10
10
  def stub_http_response_with(filename)
11
11
  format = filename.split('.').last.intern
12
12
  data = file_fixture(filename)
13
- http = Net::HTTP.new('localhost', 80)
14
-
13
+
15
14
  response = Net::HTTPOK.new("1.1", 200, "Content for you")
16
15
  response.stub!(:body).and_return(data)
17
- http.stub!(:request).and_return(response)
18
-
19
- http_request = HTTParty::Request.new(Net::HTTP::Get, '')
20
- http_request.stub!(:get_response).and_return(response)
21
- http_request.stub!(:format).and_return(format)
22
-
16
+
17
+ http_request = HTTParty::Request.new(Net::HTTP::Get, 'http://localhost', :format => format)
18
+ http_request.stub!(:perform_actual_request).and_return(response)
19
+
23
20
  HTTParty::Request.should_receive(:new).and_return(http_request)
24
21
  end
@@ -0,0 +1,27 @@
1
+ describe String, "#snake_case" do
2
+ it "lowercases one word CamelCase" do
3
+ "Merb".snake_case.should == "merb"
4
+ end
5
+
6
+ it "makes one underscore snake_case two word CamelCase" do
7
+ "MerbCore".snake_case.should == "merb_core"
8
+ end
9
+
10
+ it "handles CamelCase with more than 2 words" do
11
+ "SoYouWantContributeToMerbCore".snake_case.should == "so_you_want_contribute_to_merb_core"
12
+ end
13
+
14
+ it "handles CamelCase with more than 2 capital letter in a row" do
15
+ "CNN".snake_case.should == "cnn"
16
+ "CNNNews".snake_case.should == "cnn_news"
17
+ "HeadlineCNNNews".snake_case.should == "headline_cnn_news"
18
+ end
19
+
20
+ it "does NOT change one word lowercase" do
21
+ "merb".snake_case.should == "merb"
22
+ end
23
+
24
+ it "leaves snake_case as is" do
25
+ "merb_core".snake_case.should == "merb_core"
26
+ end
27
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alexvollmer-httparty
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Nunemaker
@@ -9,20 +9,12 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-01-05 00:00:00 -08:00
12
+ date: 2009-02-10 00:00:00 -08:00
13
13
  default_executable: httparty
14
14
  dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: json
17
- version_requirement:
18
- version_requirements: !ruby/object:Gem::Requirement
19
- requirements:
20
- - - ~>
21
- - !ruby/object:Gem::Version
22
- version: "1.1"
23
- version:
24
15
  - !ruby/object:Gem::Dependency
25
16
  name: echoe
17
+ type: :development
26
18
  version_requirement:
27
19
  version_requirements: !ruby/object:Gem::Requirement
28
20
  requirements:
@@ -39,14 +31,20 @@ extensions: []
39
31
  extra_rdoc_files:
40
32
  - bin/httparty
41
33
  - lib/core_extensions.rb
34
+ - lib/httparty/cookie_hash.rb
42
35
  - lib/httparty/exceptions.rb
36
+ - lib/httparty/module_inheritable_attributes.rb
37
+ - lib/httparty/parsers/json.rb
38
+ - lib/httparty/parsers/xml.rb
39
+ - lib/httparty/parsers.rb
43
40
  - lib/httparty/request.rb
41
+ - lib/httparty/response.rb
44
42
  - lib/httparty/version.rb
45
43
  - lib/httparty.rb
46
- - lib/module_level_inheritable_attributes.rb
47
44
  - README
48
45
  files:
49
46
  - bin/httparty
47
+ - cucumber.yml
50
48
  - examples/aaws.rb
51
49
  - examples/basic.rb
52
50
  - examples/delicious.rb
@@ -54,28 +52,50 @@ files:
54
52
  - examples/rubyurl.rb
55
53
  - examples/twitter.rb
56
54
  - examples/whoismyrep.rb
55
+ - features/basic_authentication.feature
56
+ - features/command_line.feature
57
+ - features/deals_with_http_error_codes.feature
58
+ - features/handles_multiple_formats.feature
59
+ - features/steps/env.rb
60
+ - features/steps/httparty_response_steps.rb
61
+ - features/steps/httparty_steps.rb
62
+ - features/steps/mongrel_helper.rb
63
+ - features/steps/remote_service_steps.rb
64
+ - features/supports_redirection.feature
57
65
  - History
58
66
  - httparty.gemspec
59
67
  - lib/core_extensions.rb
68
+ - lib/httparty/cookie_hash.rb
60
69
  - lib/httparty/exceptions.rb
70
+ - lib/httparty/module_inheritable_attributes.rb
71
+ - lib/httparty/parsers/json.rb
72
+ - lib/httparty/parsers/xml.rb
73
+ - lib/httparty/parsers.rb
61
74
  - lib/httparty/request.rb
75
+ - lib/httparty/response.rb
62
76
  - lib/httparty/version.rb
63
77
  - lib/httparty.rb
64
- - lib/module_level_inheritable_attributes.rb
65
78
  - Manifest
66
79
  - MIT-LICENSE
67
80
  - Rakefile
68
81
  - README
69
82
  - setup.rb
70
- - spec/as_buggery_spec.rb
71
83
  - spec/fixtures/delicious.xml
84
+ - spec/fixtures/empty.xml
72
85
  - spec/fixtures/google.html
73
86
  - spec/fixtures/twitter.json
74
87
  - spec/fixtures/twitter.xml
88
+ - spec/fixtures/undefined_method_add_node_for_nil.xml
89
+ - spec/hash_spec.rb
90
+ - spec/httparty/cookie_hash_spec.rb
91
+ - spec/httparty/parsers/json_spec.rb
92
+ - spec/httparty/parsers/xml_spec.rb
75
93
  - spec/httparty/request_spec.rb
94
+ - spec/httparty/response_spec.rb
76
95
  - spec/httparty_spec.rb
77
96
  - spec/spec.opts
78
97
  - spec/spec_helper.rb
98
+ - spec/string_spec.rb
79
99
  - website/css/common.css
80
100
  - website/index.html
81
101
  has_rdoc: true
@@ -1,25 +0,0 @@
1
- module ModuleLevelInheritableAttributes
2
- def self.included(base)
3
- base.extend(ClassMethods)
4
- end
5
-
6
- module ClassMethods
7
- def mattr_inheritable(*args)
8
- @mattr_inheritable_attrs ||= [:mattr_inheritable_attrs]
9
- @mattr_inheritable_attrs += args
10
- args.each do |arg|
11
- module_eval %(
12
- class << self; attr_accessor :#{arg} end
13
- )
14
- end
15
- @mattr_inheritable_attrs
16
- end
17
-
18
- def inherited(subclass)
19
- @mattr_inheritable_attrs.each do |inheritable_attribute|
20
- instance_var = "@#{inheritable_attribute}"
21
- subclass.instance_variable_set(instance_var, instance_variable_get(instance_var))
22
- end
23
- end
24
- end
25
- end
@@ -1,16 +0,0 @@
1
- require File.join(File.dirname(__FILE__), 'spec_helper')
2
-
3
- require 'activesupport'
4
-
5
- describe Hash do
6
- describe "#from_xml" do
7
- it "should be able to convert xml with datetimes" do
8
- xml =<<EOL
9
- <?xml version="1.0" encoding="UTF-8"?>
10
- <created-at type="datetime">2008-12-01T20:00:00-05:00</created-at>
11
- EOL
12
- hsh = Hash.from_xml(xml)
13
- hsh["created_at"].should == Time.parse("December 01st, 2008 20:00:00")
14
- end
15
- end
16
- end