wx_pay 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6df0e8b3d430425942000bc1fc37e25938da78ef
4
- data.tar.gz: 867fd2ea5babed3e08b9834f0df7d49879d2a986
3
+ metadata.gz: b0ec7cd89cdcd715c514eff188d209372a1a0d24
4
+ data.tar.gz: 675f41d9b0b406395791238167cc8d53fcefe41b
5
5
  SHA512:
6
- metadata.gz: 992d410cae14544df5f6d22bbffa25cd2869377c1cf8447e22bb34063d1e90ac15c35a4379e0fba35acc1264b2255a4a62ed8227833198890967870dd9f99248
7
- data.tar.gz: 16122e459b3f67f910cbeea658e3bef39f90ddcac8ce95ec36cb50cbf0241535cdba5959c3c5897e77457e935f54b5839928aaba17eba88c759ad4f8ab3dd57b
6
+ metadata.gz: 0090bbbed4b9582e79672c9d5cab77a82790c8f311ace9c0b7ad17eca4a08878ea7942fa8ef86a8fc5e2a576d6197d95b22a328900535aeb28429798354cda54
7
+ data.tar.gz: d4f49e18e29b3164a8418fedfcecb9ca3cae255f32dd5f2b511e3db2a89adaebe06b170bc9dc477bc62acdeb04d478a77dce76cf857356a771d9baa8fc3f9948
data/lib/wx_pay/result.rb CHANGED
@@ -2,16 +2,14 @@ module WxPay
2
2
  class Result < ::Hash
3
3
  SUCCESS_FLAG = 'SUCCESS'.freeze
4
4
 
5
- def self.[] result
6
- hash = self.new
5
+ def initialize(result)
6
+ super
7
7
 
8
8
  if result['xml'].class == Hash
9
9
  result['xml'].each_pair do |k, v|
10
- hash[k] = v
10
+ self[k] = v
11
11
  end
12
12
  end
13
-
14
- hash
15
13
  end
16
14
 
17
15
  def success?
@@ -177,7 +177,7 @@ module WxPay
177
177
  )
178
178
 
179
179
  if r
180
- WxPay::Result[Hash.from_xml(r)]
180
+ WxPay::Result.new(Hash.from_xml(r))
181
181
  else
182
182
  nil
183
183
  end
@@ -1,3 +1,3 @@
1
1
  module WxPay
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
@@ -2,7 +2,7 @@ require 'test_helper'
2
2
 
3
3
  class WxPay::ResultTest < MiniTest::Test
4
4
  def test_success_method_with_true
5
- r = WxPay::Result[
5
+ r = WxPay::Result.new(
6
6
  Hash.from_xml(
7
7
  <<-XML
8
8
  <xml>
@@ -10,39 +10,19 @@ class WxPay::ResultTest < MiniTest::Test
10
10
  <result_code>SUCCESS</result_code>
11
11
  </xml>
12
12
  XML
13
- )
14
- ]
13
+ ))
15
14
 
16
15
  assert_equal r.success?, true
17
16
  end
18
17
 
19
- def test_nonexistent_key
20
- r = WxPay::Result[
21
- Hash.from_xml(
22
- <<-XML
23
- <xml>
24
- <return_code>SUCCESS</return_code>
25
- <code_url>wx_code_url</code_url>
26
- <result_code>SUCCESS</result_code>
27
- </xml>
28
- XML
29
- )
30
- ]
31
-
32
- assert_equal r['return_code'].nil?, false
33
- assert_equal r['prepay_id'].nil?, true
34
- assert_equal r.keys, ['return_code', 'code_url', 'result_code']
35
- end
36
-
37
18
  def test_success_method_with_false
38
- r = WxPay::Result[
19
+ r = WxPay::Result.new(
39
20
  Hash.from_xml(
40
21
  <<-XML
41
22
  <xml>
42
23
  </xml>
43
24
  XML
44
- )
45
- ]
25
+ ))
46
26
 
47
27
  assert_equal r.success?, false
48
28
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wx_pay
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jasl
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-02 00:00:00.000000000 Z
11
+ date: 2015-12-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client