zaypay 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/zaypay/price_setting.rb +5 -2
- data/lib/zaypay/version.rb +1 -1
- data/test/price_setting_test.rb +11 -2
- metadata +2 -2
data/lib/zaypay/price_setting.rb
CHANGED
@@ -102,11 +102,14 @@ module Zaypay
|
|
102
102
|
puts 'Please either specify price_setting id and its API-key as first 2 arguments to #new, or create a config-file (checkout the plugin README)'
|
103
103
|
raise e
|
104
104
|
end
|
105
|
+
|
106
|
+
config_error = Zaypay::Error.new(:config_error, "You did not provide a price_setting id or/and an API-key. You can either pass it to the constructor or create a config file (check out README)")
|
107
|
+
raise config_error unless config
|
108
|
+
|
105
109
|
@price_setting_id = config['default'] unless @price_setting_id
|
106
110
|
@key = config[@price_setting_id]
|
107
111
|
if @key.nil? || @price_setting_id.nil?
|
108
|
-
raise
|
109
|
-
or create a config file (check out README)")
|
112
|
+
raise config_error
|
110
113
|
end
|
111
114
|
end
|
112
115
|
end
|
data/lib/zaypay/version.rb
CHANGED
data/test/price_setting_test.rb
CHANGED
@@ -28,12 +28,21 @@ class PriceSettingTest < Test::Unit::TestCase
|
|
28
28
|
end
|
29
29
|
should "raise Error if yml is blank" do
|
30
30
|
error = assert_raise Zaypay::Error do
|
31
|
-
YAML.expects(:load_file).with('anywhere/config/zaypay.yml').returns(
|
31
|
+
YAML.expects(:load_file).with('anywhere/config/zaypay.yml').returns(false)
|
32
32
|
Zaypay::PriceSetting.new
|
33
33
|
end
|
34
34
|
assert_equal :config_error, error.type
|
35
35
|
assert_match "You did not provide a price_setting id or/and an API-key", error.message
|
36
36
|
end
|
37
|
+
|
38
|
+
should "raise Error if yml only contains value for price_setting but not api-key" do
|
39
|
+
error = assert_raise Zaypay::Error do
|
40
|
+
YAML.expects(:load_file).with('anywhere/config/zaypay.yml').returns({@price_setting_id => nil})
|
41
|
+
ps = Zaypay::PriceSetting.new(@price_setting_id)
|
42
|
+
end
|
43
|
+
assert_equal :config_error, error.type
|
44
|
+
assert_match "You did not provide a price_setting id or/and an API-key", error.message
|
45
|
+
end
|
37
46
|
|
38
47
|
should "raise Error if the yml file is not present" do
|
39
48
|
assert_raise Errno::ENOENT do
|
@@ -63,7 +72,7 @@ class PriceSettingTest < Test::Unit::TestCase
|
|
63
72
|
context "without a valid yml file" do
|
64
73
|
should "raise RuntimeError" do
|
65
74
|
error = assert_raise Zaypay::Error do
|
66
|
-
YAML.expects(:load_file).with('anywhere/config/zaypay.yml').returns(
|
75
|
+
YAML.expects(:load_file).with('anywhere/config/zaypay.yml').returns(false)
|
67
76
|
ps = Zaypay::PriceSetting.new(@price_setting_id)
|
68
77
|
end
|
69
78
|
assert_equal :config_error, error.type
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zaypay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-09-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|