Skip to content

Commit 4c0c2f0

Browse files
committed
Merge pull request #5 from voke/master
Add config variable for test_mode
2 parents bfa1a09 + 4db1fe5 commit 4c0c2f0

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

README.rdoc

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ You need to configure the gem with your own Payson credentials through the <tt>P
3030

3131
Please note that if <tt>config.api_user_id</tt> is set to 4, the client will go into test mode. Valid test access credentials could be found in {documentation}[https://api.payson.se/#Testing/sandbox].
3232

33+
For more detailed testing you may create your own test agent for use in the test environment. Use <tt>config.test_mode = true</tt>
34+
3335
=== Initiating a payment
3436

3537
return_url = 'http://localhost/payson/success'

lib/payson_api/config.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def config
3535
end
3636

3737
class Configuration
38-
attr_accessor :api_user_id, :api_password
38+
attr_accessor :api_user_id, :api_password, :test_mode
3939
end
4040

4141
configure do |config|
@@ -44,7 +44,7 @@ class Configuration
4444
end
4545

4646
def test?
47-
@config.api_user_id == '4'
47+
@config.test_mode || @config.api_user_id == '4'
4848
end
4949

5050
end

test/integration/config_test.rb

+8
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,12 @@ def test_ensure_expected_config
1212
assert_equal CONFIG[:api_password], PaysonAPI.config.api_password
1313
assert PaysonAPI.test?
1414
end
15+
16+
def test_setting_test_mode
17+
PaysonAPI.config.api_user_id = '123'
18+
assert !PaysonAPI.test?
19+
PaysonAPI.config.test_mode = true
20+
assert PaysonAPI.test?
21+
end
22+
1523
end

0 commit comments

Comments
 (0)