faraday_json 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -5,10 +5,9 @@ gem 'rake', '>= 0.9'
5
5
 
6
6
  group :test do
7
7
  gem 'parallel', '= 1.3.3', :platforms => [:mri_19]
8
- gem 'cane', '>= 2.2.2', :platforms => [:mri_19, :mri_20, :mri_21, :mri_22]
8
+ gem 'cane', '>= 2.2.2', :platforms => [:mri_19, :mri_20, :mri_21]
9
9
  gem 'rspec', '>= 3'
10
10
  gem 'simplecov'
11
- # gem 'webmock'
12
11
  end
13
12
 
14
13
  platforms :ruby_18 do
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- faraday_json (0.1.0)
4
+ faraday_json (0.1.2)
5
5
  faraday (>= 0.7.4, < 0.10)
6
6
 
7
7
  GEM
@@ -88,7 +88,7 @@ if RUBY_VERSION.start_with?("1.8")
88
88
  elsif data.is_a? Array
89
89
  transcoded = []
90
90
  data.each do |value|
91
- transcoded << to_utf8(value, charest, opts)
91
+ transcoded << to_utf8(value, charset, opts)
92
92
  end
93
93
  return transcoded
94
94
  elsif data.is_a? String
@@ -6,5 +6,5 @@
6
6
  # All rights reserved.
7
7
  #
8
8
  module FaradayJSON
9
- VERSION = "0.1.1"
9
+ VERSION = "0.1.2"
10
10
  end
@@ -314,15 +314,7 @@ describe FaradayJSON::EncodeJson do
314
314
  end
315
315
 
316
316
  ### Dealing with files in various encoding should ideally be easy
317
- FILES = {
318
- 'spec/data/iso8859-15_file.json' => 'iso-8859-15',
319
- 'spec/data/utf16be_file.json' => 'utf-16be',
320
- 'spec/data/utf16le_file.json' => 'utf-16le',
321
- 'spec/data/utf8_file.json' => 'utf-8',
322
- }
323
-
324
-
325
- FILES.each do |fname, enc|
317
+ TEST_FILES.each do |fname, enc|
326
318
  context "reading #{enc} encoded file '#{fname}'" do
327
319
  # Read the string from file; read binary/with encoding. Ruby 1.8 will
328
320
  # ignore this, but must still work.
@@ -347,7 +339,7 @@ describe FaradayJSON::EncodeJson do
347
339
  end
348
340
  end
349
341
 
350
- FILES.each do |fname, enc|
342
+ TEST_FILES.each do |fname, enc|
351
343
  context "reading #{enc} encoded file '#{fname}' as binary" do
352
344
  # Read the string from file; read binary/with encoding. Ruby 1.8 will
353
345
  # ignore this, but must still work.
@@ -372,5 +364,5 @@ describe FaradayJSON::EncodeJson do
372
364
  end
373
365
  end
374
366
 
375
- end
367
+ end # Ruby version > 1.8
376
368
  end
data/spec/helper.rb CHANGED
@@ -72,3 +72,10 @@ def test_encode(str, encoding)
72
72
  return str.encode(encoding)
73
73
  end
74
74
  end
75
+
76
+ TEST_FILES = {
77
+ 'spec/data/iso8859-15_file.json' => 'iso-8859-15',
78
+ 'spec/data/utf16be_file.json' => 'utf-16be',
79
+ 'spec/data/utf16le_file.json' => 'utf-16le',
80
+ 'spec/data/utf8_file.json' => 'utf-8',
81
+ }
@@ -0,0 +1,35 @@
1
+ # encoding: utf-8
2
+
3
+ require 'helper'
4
+ require 'faraday_json/encode_json'
5
+
6
+ describe FaradayJSON::EncodeJson do
7
+ let(:middleware) { described_class.new(lambda{|env| env}) }
8
+
9
+ def process(body, content_type = nil)
10
+ env = {:body => body, :request_headers => Faraday::Utils::Headers.new}
11
+ env[:request_headers]['content-type'] = content_type if content_type
12
+ middleware.call(faraday_env(env))
13
+ end
14
+
15
+ def result_body() result[:body] end
16
+ def result_type() result[:request_headers]['content-type'] end
17
+ def result_length() result[:request_headers]['content-length'].to_i end
18
+
19
+
20
+ ### Test cases specifically for filed issues
21
+ context "issue #2: encoding an object with a contained array" do
22
+ data = {
23
+ :some_array => [1, 2, 3],
24
+ }
25
+
26
+ # Passing that data with a charset should do the right thing.
27
+ let(:result) {
28
+ process(data, "application/json; charset=utf-8")
29
+ }
30
+
31
+ it "encodes body" do
32
+ expect(result_body).to eq("{\"some_array\":[1,2,3]}")
33
+ end
34
+ end
35
+ end
@@ -177,15 +177,8 @@ describe FaradayJSON::ParseJson, :type => :response do
177
177
  end
178
178
 
179
179
  ### Dealing with files in various encoding should ideally be easy
180
- FILES = {
181
- 'spec/data/iso8859-15_file.json' => 'iso-8859-15',
182
- 'spec/data/utf16be_file.json' => 'utf-16be',
183
- 'spec/data/utf16le_file.json' => 'utf-16le',
184
- 'spec/data/utf8_file.json' => 'utf-8',
185
- }
186
-
187
180
  if not RUBY_VERSION.start_with?("1.8")
188
- FILES.each do |fname, enc|
181
+ TEST_FILES.each do |fname, enc|
189
182
  context "reading #{enc} encoded file '#{fname}'" do
190
183
  # Read the string from file; read binary/with encoding. Ruby 1.8 will
191
184
  # ignore this, but must still work.
@@ -200,7 +193,7 @@ if not RUBY_VERSION.start_with?("1.8")
200
193
  end
201
194
  end
202
195
 
203
- FILES.each do |fname, enc|
196
+ TEST_FILES.each do |fname, enc|
204
197
  context "reading #{enc} encoded file '#{fname}' as binary" do
205
198
  # Read the string from file; read binary/with encoding. Ruby 1.8 will
206
199
  # ignore this, but must still work.
metadata CHANGED
@@ -1,61 +1,68 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: faraday_json
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Jens Finkhaeuser
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2015-06-02 00:00:00.000000000 Z
12
+ date: 2015-06-05 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: bundler
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
- - - "~>"
19
+ - - ~>
18
20
  - !ruby/object:Gem::Version
19
21
  version: '1.6'
20
22
  type: :development
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
- - - "~>"
27
+ - - ~>
25
28
  - !ruby/object:Gem::Version
26
29
  version: '1.6'
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: rake
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
- - - ">="
35
+ - - ! '>='
32
36
  - !ruby/object:Gem::Version
33
37
  version: '0'
34
38
  type: :development
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
- - - ">="
43
+ - - ! '>='
39
44
  - !ruby/object:Gem::Version
40
45
  version: '0'
41
46
  - !ruby/object:Gem::Dependency
42
47
  name: faraday
43
48
  requirement: !ruby/object:Gem::Requirement
49
+ none: false
44
50
  requirements:
45
- - - ">="
51
+ - - ! '>='
46
52
  - !ruby/object:Gem::Version
47
53
  version: 0.7.4
48
- - - "<"
54
+ - - <
49
55
  - !ruby/object:Gem::Version
50
56
  version: '0.10'
51
57
  type: :runtime
52
58
  prerelease: false
53
59
  version_requirements: !ruby/object:Gem::Requirement
60
+ none: false
54
61
  requirements:
55
- - - ">="
62
+ - - ! '>='
56
63
  - !ruby/object:Gem::Version
57
64
  version: 0.7.4
58
- - - "<"
65
+ - - <
59
66
  - !ruby/object:Gem::Version
60
67
  version: '0.10'
61
68
  description: This is a character encoding-aware JSON middleware for Faraday.
@@ -65,8 +72,8 @@ executables: []
65
72
  extensions: []
66
73
  extra_rdoc_files: []
67
74
  files:
68
- - ".gitignore"
69
- - ".travis.yml"
75
+ - .gitignore
76
+ - .travis.yml
70
77
  - Gemfile
71
78
  - Gemfile-0.7.rb
72
79
  - Gemfile-0.7.rb.lock
@@ -88,30 +95,32 @@ files:
88
95
  - spec/data/utf8_file.json
89
96
  - spec/encode_json_spec.rb
90
97
  - spec/helper.rb
98
+ - spec/issues_spec.rb
91
99
  - spec/parse_json_spec.rb
92
100
  homepage: https://github.com/spriteCloud/faraday_json
93
101
  licenses:
94
102
  - MITNFA
95
- metadata: {}
96
103
  post_install_message:
97
104
  rdoc_options: []
98
105
  require_paths:
99
106
  - lib
100
107
  required_ruby_version: !ruby/object:Gem::Requirement
108
+ none: false
101
109
  requirements:
102
- - - ">="
110
+ - - ! '>='
103
111
  - !ruby/object:Gem::Version
104
112
  version: '0'
105
113
  required_rubygems_version: !ruby/object:Gem::Requirement
114
+ none: false
106
115
  requirements:
107
- - - ">="
116
+ - - ! '>='
108
117
  - !ruby/object:Gem::Version
109
118
  version: '0'
110
119
  requirements: []
111
120
  rubyforge_project:
112
- rubygems_version: 2.4.5
121
+ rubygems_version: 1.8.23
113
122
  signing_key:
114
- specification_version: 4
123
+ specification_version: 3
115
124
  summary: This is a character encoding-aware JSON middleware for Faraday.
116
125
  test_files:
117
126
  - spec/data/iso8859-15_file.json
@@ -120,4 +129,5 @@ test_files:
120
129
  - spec/data/utf8_file.json
121
130
  - spec/encode_json_spec.rb
122
131
  - spec/helper.rb
132
+ - spec/issues_spec.rb
123
133
  - spec/parse_json_spec.rb
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: c77a32170d967ebaa3950cda3adda8697a1408e1
4
- data.tar.gz: 229a0bd27bc9a29873ecc20e80e24d67835cdaa2
5
- SHA512:
6
- metadata.gz: 8a1d60bda56f2465d32d22a8be678b691b11e8401f7d7deb791da725efb5fa1938667eaf2bd5348ee28c3abc9b1ddd4d66689dcdb44e577484189f464fd35566
7
- data.tar.gz: 22b9691239581d61629c4a263960f4f24370d9ad2fadc4b059b17a7812a8a47429ca1fe9ef67c8fac7bd61eb2218158533d1d6730171b0b7c49fe9c74ee2a059