espago 0.1.8 → 0.1.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +5 -5
  2. data/.travis.yml +15 -8
  3. data/Gemfile +2 -0
  4. data/Gemfile.lock +254 -130
  5. data/README.md +13 -15
  6. data/app/views/espago_secure_web_page/_form.html.haml +3 -2
  7. data/espago.gemspec +13 -12
  8. data/lib/espago/api_connection/charges_complete_post.rb +1 -1
  9. data/lib/espago/api_connection/refunds_post.rb +9 -0
  10. data/lib/espago/api_connection/secure_web_page_register_post.rb +9 -0
  11. data/lib/espago/api_connection/tokens_post.rb +1 -1
  12. data/lib/espago/api_connection/visacheckout_post.rb +9 -0
  13. data/lib/espago/api_connection.rb +4 -2
  14. data/lib/espago/client.rb +5 -6
  15. data/lib/espago/secure_web_page.rb +13 -10
  16. data/lib/espago/version.rb +1 -1
  17. data/spec/espago/api_connection_spec.rb +1 -1
  18. data/spec/espago/back_request_spec.rb +11 -11
  19. data/spec/espago/client_spec.rb +8 -8
  20. data/spec/espago/error_spec.rb +4 -3
  21. data/spec/espago/response_spec.rb +10 -10
  22. data/spec/espago/router_spec.rb +5 -6
  23. data/spec/features/apis_spec.rb +2 -2
  24. data/spec/features/charges_spec.rb +19 -19
  25. data/spec/features/charges_spec_with_params_spec.rb +22 -22
  26. data/spec/features/clients_spec.rb +28 -28
  27. data/spec/features/dcc_decision_spec.rb +7 -7
  28. data/spec/features/invoice_items_spec.rb +9 -9
  29. data/spec/features/invoices_spec.rb +6 -6
  30. data/spec/features/line_items_spec.rb +5 -5
  31. data/spec/features/plans_spec.rb +14 -14
  32. data/spec/features/secure_web_page_register_spec.rb +23 -0
  33. data/spec/features/subscriptions_spec.rb +13 -13
  34. data/spec/features/tokens_spec.rb +15 -16
  35. data/spec/fixtures/cassettes/api_2.yml +1 -1
  36. data/spec/fixtures/cassettes/api_3.yml +1 -1
  37. data/spec/fixtures/cassettes/charges_complete.yml +1 -1
  38. data/spec/fixtures/cassettes/charges_complete_deprecation.yml +1 -1
  39. data/spec/fixtures/cassettes/charges_destroy.yml +1 -1
  40. data/spec/fixtures/cassettes/charges_get.yml +1 -1
  41. data/spec/fixtures/cassettes/charges_get_pay_mTOngouLTJWZ0w.yml +3 -1
  42. data/spec/fixtures/cassettes/charges_post.yml +3 -1
  43. data/spec/fixtures/cassettes/charges_refund.yml +3 -1
  44. data/spec/fixtures/cassettes/clients_authorize.yml +3 -1
  45. data/spec/fixtures/cassettes/clients_delete.yml +3 -1
  46. data/spec/fixtures/cassettes/clients_get.yml +3 -1
  47. data/spec/fixtures/cassettes/clients_get_cli_w0Se2smYwyQ0Uw.yml +3 -1
  48. data/spec/fixtures/cassettes/clients_invoices.yml +3 -1
  49. data/spec/fixtures/cassettes/clients_post.yml +3 -1
  50. data/spec/fixtures/cassettes/clients_put.yml +3 -1
  51. data/spec/fixtures/cassettes/clients_subscriptions.yml +3 -1
  52. data/spec/fixtures/cassettes/dcc_decision_post.yml +3 -1
  53. data/spec/fixtures/cassettes/error_400.yml +3 -1
  54. data/spec/fixtures/cassettes/error_401.yml +3 -1
  55. data/spec/fixtures/cassettes/error_500.yml +3 -1
  56. data/spec/fixtures/cassettes/invoice_items_delete_ii_WDzszvhTshe78Xd.yml +3 -1
  57. data/spec/fixtures/cassettes/invoice_items_get_ii_5LS-YR7S1QaJBl3.yml +3 -1
  58. data/spec/fixtures/cassettes/invoice_items_post_ii_5LS-YR7S1QaJBl3.yml +3 -1
  59. data/spec/fixtures/cassettes/invoices_get.yml +3 -1
  60. data/spec/fixtures/cassettes/invoices_get_in_tUCMhwlg2nkvAaL.yml +3 -1
  61. data/spec/fixtures/cassettes/line_items_get.yml +1 -1
  62. data/spec/fixtures/cassettes/plans_delete.yml +1 -1
  63. data/spec/fixtures/cassettes/plans_get.yml +1 -1
  64. data/spec/fixtures/cassettes/plans_get_pl_12345.yml +1 -1
  65. data/spec/fixtures/cassettes/plans_post.yml +3 -1
  66. data/spec/fixtures/cassettes/plans_put.yml +3 -1
  67. data/spec/fixtures/cassettes/secure_web_page_register_post.yml +56 -0
  68. data/spec/fixtures/cassettes/subscriptions_delete_sub_8yYuCBKdywr7e2.yml +3 -1
  69. data/spec/fixtures/cassettes/subscriptions_get.yml +1 -1
  70. data/spec/fixtures/cassettes/subscriptions_get_sub_8yYuCBKdywr7e2.yml +1 -1
  71. data/spec/fixtures/cassettes/subscriptions_post.yml +3 -1
  72. data/spec/fixtures/cassettes/tokens_get.yml +3 -1
  73. data/spec/fixtures/cassettes/tokens_post.yml +3 -1
  74. data/spec/spec_helper.rb +4 -7
  75. metadata +58 -23
@@ -0,0 +1,9 @@
1
+ module Espago
2
+ class ApiConnection
3
+ class VisacheckoutPost < ApiPost
4
+ def request(params = {})
5
+ super("visacheckout", params)
6
+ end
7
+ end
8
+ end
9
+ end
@@ -22,8 +22,6 @@ end
22
22
 
23
23
  module Espago
24
24
  class ApiConnection
25
- extend Forwardable
26
- def_delegator :@connection, :basic_auth, :authenticate
27
25
 
28
26
  def initialize(enviroment,headers)
29
27
  @connection = Faraday.new(enviroment)
@@ -38,6 +36,10 @@ module Espago
38
36
  handle_response response
39
37
  end
40
38
 
39
+ def authenticate(username, password)
40
+ @connection.request(:authorization, :basic, username, password)
41
+ end
42
+
41
43
  private
42
44
 
43
45
  def handle_response(response)
data/lib/espago/client.rb CHANGED
@@ -12,13 +12,13 @@ module Espago
12
12
  end
13
13
 
14
14
  def send_request(path, method, params = {})
15
-
15
+
16
16
  app_id = params[:app_id].present? ? params.delete(:app_id) : @app_id
17
- app_password = params[:app_password].present? ? params.delete(:app_password) : @app_password
18
- production_param = !params[:production].nil? ? params.delete(:production) : production
19
-
17
+ app_password = params[:app_password].present? ? params.delete(:app_password) : @app_password
18
+ production_param = !params[:production].nil? ? params.delete(:production) : production
19
+
20
20
  raise NotAuthenticated unless valid?(app_id, app_password)
21
-
21
+
22
22
  connection = @connection.new(enviroment(production_param),api_version_header)
23
23
  connection.authenticate(app_id, app_password)
24
24
  connection.create(path, method, params)
@@ -30,7 +30,6 @@ module Espago
30
30
 
31
31
  private
32
32
  def enviroment(production_param)
33
- # "http://127.0.0.1:3007/api"
34
33
  production_param ? "https://secure.espago.com/api" : "https://sandbox.espago.com/api"
35
34
  end
36
35
 
@@ -1,28 +1,31 @@
1
- require "forwardable"
1
+ # frozen_string_literal: true
2
+
3
+ require 'forwardable'
2
4
  module Espago
3
5
  class SecureWebPage
4
6
  attr_accessor :production
5
7
 
6
- def self.calculate_checksum(app_id, kind, session_id,amount,currency,ts,checksum_key)
7
- Digest::MD5.hexdigest(
8
+ def self.calculate_checksum(app_id, kind, session_id, amount, currency, ts, service_client_id, checksum_key)
9
+ return Digest::MD5.hexdigest(
8
10
  [app_id.to_s, kind, session_id.to_s, amount.to_s, currency.to_s, ts.to_s, checksum_key.to_s].join('|')
11
+ ) if service_client_id.blank?
12
+ Digest::MD5.hexdigest(
13
+ [app_id.to_s, kind, session_id.to_s, amount.to_s, currency.to_s, ts.to_s, service_client_id.to_s, checksum_key.to_s].join('|')
9
14
  )
10
15
  end
11
16
 
12
- def self.form_post(api_v=nil)
13
- Espago.production ? "https://secure.espago.com/secure_web_page" : "https://sandbox.espago.com/secure_web_page"
17
+ def self.form_post(_api_v = nil)
18
+ Espago.production ? 'https://secure.espago.com/secure_web_page' : 'https://sandbox.espago.com/secure_web_page'
14
19
  end
15
20
 
16
21
  def self.prepare_form(data)
17
- data[:kind] ||= 'sale'
18
- data[:ts] ||= Time.now.to_i
22
+ data[:kind] ||= 'sale'
23
+ data[:ts] ||= Time.now.to_i
19
24
  data[:app_id] ||= Espago.app_id
20
25
  data[:api_version] ||= Espago.api_version
21
26
  data[:amount] = format('%.2f', data[:amount])
22
- data[:checksum] = calculate_checksum(data[:app_id],data[:kind],data[:session_id],data[:amount],data[:currency],data[:ts],data[:checksum_key]|| Espago.checksum_key)
27
+ data[:checksum] = calculate_checksum(data[:app_id], data[:kind], data[:session_id], data[:amount], data[:currency], data[:ts], data[:service_client_id], data[:checksum_key] || Espago.checksum_key)
23
28
  data
24
29
  end
25
-
26
-
27
30
  end
28
31
  end
@@ -1,3 +1,3 @@
1
1
  module Espago
2
- VERSION = "0.1.8"
2
+ VERSION = '0.1.10'
3
3
  end
@@ -27,7 +27,7 @@ describe Espago::ApiConnection do
27
27
 
28
28
  context "#create" do
29
29
  it "returns response" do
30
- subject.create(:path, :stubbed).should be_a_kind_of Espago::Response
30
+ expect(subject.create(:path, :stubbed)).to be_a_kind_of Espago::Response
31
31
  end
32
32
  it "raises auth error" do
33
33
  expect { subject.create(:path, :unauthorized) }.to raise_error Espago::AuthenticationError
@@ -19,15 +19,15 @@ describe Espago::BackRequest do
19
19
  "created_at"=>1417030497
20
20
  }
21
21
  }
22
-
23
- its(:id) { should eq("in_tUCMhwlg2nkvAaL") }
24
- its(:subscription) { should eq("sub_8yYuCBKdywr7e2") }
25
- its(:amount) { should eq("123.45") }
26
- its(:currency) { should eq("pln") }
27
- its(:paid) { should eq("true") }
28
- its(:client) { should eq("cli_90Pi6Jf0ndl_PP") }
29
- its(:created_at) { should eq(Time.at(1417030497)) }
30
- its(:card) { should eq({}) }
31
- its(:imaginated_attribute) { should be_nil }
32
-
22
+ it {
23
+ expect(subject.id).to eq("in_tUCMhwlg2nkvAaL")
24
+ expect(subject.subscription).to eq("sub_8yYuCBKdywr7e2")
25
+ expect(subject.amount).to eq("123.45")
26
+ expect(subject.currency).to eq("pln")
27
+ expect(subject.paid).to eq("true")
28
+ expect(subject.client).to eq("cli_90Pi6Jf0ndl_PP")
29
+ expect(subject.created_at).to eq(Time.at(1417030497))
30
+ expect(subject.card).to eq({})
31
+ expect(subject.imaginated_attribute).to be_nil
32
+ }
33
33
  end
@@ -15,10 +15,10 @@ describe Espago::Client do
15
15
  let(:stubbed_api_connection) { StubbedApiConnection }
16
16
  let(:response) { FakeResponse.new(200, {id: 1, status: "2012"}.to_json) }
17
17
 
18
- it { subject.should respond_to :app_id }
19
- it { subject.should respond_to :app_password }
20
- it { subject.should respond_to :public_key }
21
- it { subject.should respond_to :api_version }
18
+ it { expect(subject).to respond_to :app_id }
19
+ it { expect(subject).to respond_to :app_password }
20
+ it { expect(subject).to respond_to :public_key }
21
+ it { expect(subject).to respond_to :api_version }
22
22
 
23
23
  context "#send_request" do
24
24
  let(:method) { :get }
@@ -26,7 +26,7 @@ describe Espago::Client do
26
26
  let(:params) { { name: "Jan Kowalski"} }
27
27
 
28
28
  it "should create an api request" do
29
- subject.send_request(path, method, params).should eq('returned api data')
29
+ expect(subject.send_request(path, method, params)).to eq('returned api data')
30
30
  end
31
31
 
32
32
  context "with no credentials" do
@@ -45,7 +45,7 @@ describe Espago::Client do
45
45
  let(:params) { { name: "Jan Kowalski", app_id: 'app_id_test', app_password: 'secret'} }
46
46
 
47
47
  it "should create an api request" do
48
- subject.send_request(path, method, params).should eq('returned api data')
48
+ expect(subject.send_request(path, method, params)).to eq('returned api data')
49
49
  end
50
50
 
51
51
  end
@@ -54,12 +54,12 @@ describe Espago::Client do
54
54
  subject { Espago::Client.new }
55
55
 
56
56
  it "should delegate work to parser" do
57
- Espago::Response.should_receive(:new).with(response)
57
+ expect(Espago::Response).to receive(:new).with(response)
58
58
  subject.parse_response(response)
59
59
  end
60
60
 
61
61
  it "should parse response into object" do
62
- subject.parse_response(response).class.should eq(Espago::Response)
62
+ expect(subject.parse_response(response).class).to eq(Espago::Response)
63
63
  end
64
64
  end
65
65
 
@@ -10,7 +10,8 @@ describe Espago::Error do
10
10
  let(:response) {
11
11
  FakeResponse.new(422, response_body)
12
12
  }
13
-
14
- its(:body) { should eq('body') }
15
- its(:status) { should eq(422) }
13
+ it {
14
+ expect(subject.body).to eq('body')
15
+ expect(subject.status).to eq(422)
16
+ }
16
17
  end
@@ -25,14 +25,14 @@ describe Espago::Response do
25
25
  }
26
26
  }.to_json)
27
27
  }
28
-
29
- its(:id) { should eq("pay_hViT20SOWaUL_w") }
30
- its(:description) { should eq("Zakupy z example.com") }
31
- its(:amount) { should eq("49.99") }
32
- its(:currency) { should eq("pln") }
33
- its(:state) { should eq("executed") }
34
- its(:client) { should eq("cli_wm7dGQltAqIfH8") }
35
- its(:created_at) { should eq(Time.parse("2013-06-28 10:31:14 +0200")) }
36
- its(:imaginated_attribute) { should be_nil }
37
-
28
+ it {
29
+ expect(subject.id).to eq("pay_hViT20SOWaUL_w")
30
+ expect(subject.description).to eq("Zakupy z example.com")
31
+ expect(subject.amount).to eq("49.99")
32
+ expect(subject.currency).to eq("pln")
33
+ expect(subject.state).to eq("executed")
34
+ expect(subject.client).to eq("cli_wm7dGQltAqIfH8")
35
+ expect(subject.created_at).to eq(Time.parse("2013-06-28 10:31:14 +0200"))
36
+ expect(subject.imaginated_attribute).to be_nil
37
+ }
38
38
  end
@@ -6,12 +6,12 @@ class Espago::ApiConnection::StubbedRequestGet; end
6
6
  describe Espago::Router do
7
7
  subject { Espago::Router.new(:stubbed_request, :get) }
8
8
 
9
- it { subject.should respond_to :path}
10
- it { subject.should respond_to :method}
9
+ it { expect(subject).to respond_to :path}
10
+ it { expect(subject).to respond_to :method}
11
11
 
12
12
  context "#route" do
13
13
  it "should get a class name depending on path and method" do
14
- subject.route.should eq( Espago::ApiConnection::StubbedRequestGet )
14
+ expect(subject.route).to eq( Espago::ApiConnection::StubbedRequestGet )
15
15
  end
16
16
 
17
17
  it "should raise error if class not found" do
@@ -22,14 +22,13 @@ describe Espago::Router do
22
22
 
23
23
  context "#path_exists?" do
24
24
  it "should return if path exists" do
25
- subject.path_exists?.should be_true
25
+ expect(subject.path_exists?).to be_truthy
26
26
  end
27
27
 
28
28
  context "with invalid path name" do
29
29
  subject { Espago::Router.new(:not, :existing) }
30
-
31
30
  it "should return false" do
32
- subject.path_exists?.should_not be_true
31
+ expect(subject.path_exists?).not_to be_truthy
33
32
  end
34
33
  end
35
34
  end
@@ -6,7 +6,7 @@ describe 'Two api headers test' do
6
6
  Espago.api_version = '2'
7
7
  VCR.use_cassette('api 2') do
8
8
  response = Espago.charges :get
9
- response.count.should eq(596)
9
+ expect(response.count).to eq(596)
10
10
  end
11
11
  end
12
12
 
@@ -14,7 +14,7 @@ describe 'Two api headers test' do
14
14
  Espago.api_version = '3'
15
15
  VCR.use_cassette('api 3') do
16
16
  response = Espago.charges :get
17
- response.count.should eq(596)
17
+ expect(response.count).to eq(596)
18
18
  end
19
19
  end
20
20
 
@@ -7,20 +7,20 @@ describe 'Espago.charges' do
7
7
  it "should get list of charges" do
8
8
  VCR.use_cassette('charges get') do
9
9
  response = Espago.charges :get
10
- response.count.should eq(589)
10
+ expect(response.count).to eq(589)
11
11
  end
12
12
  end
13
13
 
14
14
  it "should get info abount charges" do
15
15
  VCR.use_cassette('charges get pay_mTOngouLTJWZ0w') do
16
16
  response = Espago.charges :get,{charge_id:'pay_mTOngouLTJWZ0w'}
17
- response.status.should eq(200)
18
- response.channel.should eq('elavon')
19
- response.state.should eq('executed')
20
- response.currency.should eq('PLN')
21
- response.description.should eq('Test12345')
22
- response.client.should eq('cli_YM5tKz6-IfhN7T')
23
- response.created_at.should eq Time.at(1416917311)
17
+ expect(response.status).to eq(200)
18
+ expect(response.channel).to eq('elavon')
19
+ expect(response.state).to eq('executed')
20
+ expect(response.currency).to eq('PLN')
21
+ expect(response.description).to eq('Test12345')
22
+ expect(response.client).to eq('cli_YM5tKz6-IfhN7T')
23
+ expect(response.created_at).to eq Time.at(1416917311)
24
24
  end
25
25
  end
26
26
 
@@ -38,41 +38,41 @@ describe 'Espago.charges' do
38
38
  month:'2'
39
39
  },
40
40
  }
41
- response.status.should eq(201)
42
- response.channel.should eq('elavon')
43
- response.state.should eq('executed')
44
- response.currency.should eq('PLN')
45
- response.description.should eq('Test12345')
46
- response.client.should eq('cli_YM5tKz6-IfhN7T')
47
- response.created_at.should eq Time.at(1416917311)
41
+ expect(response.status).to eq(201)
42
+ expect(response.channel).to eq('elavon')
43
+ expect(response.state).to eq('executed')
44
+ expect(response.currency).to eq('PLN')
45
+ expect(response.description).to eq('Test12345')
46
+ expect(response.client).to eq('cli_YM5tKz6-IfhN7T')
47
+ expect(response.created_at).to eq Time.at(1416917311)
48
48
  end
49
49
  end
50
50
 
51
51
  it "should get 204 status after destroy charge" do
52
52
  VCR.use_cassette('charges destroy') do
53
53
  response = Espago.charges :delete,{charge_id:'pay_kQmS_3RTfm4eix'}
54
- response.state.should eq('reversed')
54
+ expect(response.state).to eq('reversed')
55
55
  end
56
56
  end
57
57
 
58
58
  it "should get refunded status after refund charge" do
59
59
  VCR.use_cassette('charges refund') do
60
60
  response = Espago.charges_refund :post,{charge_id:'pay_lQGyIon5qG59O5'}
61
- response.state.should eq('refunded')
61
+ expect(response.state).to eq('refunded')
62
62
  end
63
63
  end
64
64
 
65
65
  it "should get params from complete charge" do
66
66
  VCR.use_cassette('charges complete') do
67
67
  response = Espago.charges_complete :post,{charge_id:'pay_kQmS_3RTfm4eix'}
68
- response.state.should eq('executed')
68
+ expect(response.state).to eq('executed')
69
69
  end
70
70
  end
71
71
 
72
72
  it "should get params from complete charge (deprecated)" do
73
73
  VCR.use_cassette('charges complete deprecation') do
74
74
  response = Espago.complete :post,{charge_id:'pay_Wmu3hmXJIG4jsg'}
75
- response.state.should eq('executed')
75
+ expect(response.state).to eq('executed')
76
76
  end
77
77
  end
78
78
 
@@ -2,37 +2,37 @@
2
2
  require "spec_helper"
3
3
 
4
4
  describe 'Espago.charges_with_params' do
5
-
5
+
6
6
  before :each do
7
7
  Espago.app_id = ''
8
8
  Espago.app_password = ''
9
9
  Espago.public_key = ''
10
10
  Espago.production = true
11
11
  end
12
-
12
+
13
13
  it "should get list of charges" do
14
14
  VCR.use_cassette('charges get') do
15
15
  response = Espago.charges :get,{app_id: 'app_id_test', app_password: 'app_password_test', production: false}
16
- response.count.should eq(589)
16
+ expect(response.count).to eq(589)
17
17
  end
18
18
  end
19
19
 
20
20
  it "should get info abount charges" do
21
21
  VCR.use_cassette('charges get pay_mTOngouLTJWZ0w') do
22
22
  response = Espago.charges :get,{charge_id:'pay_mTOngouLTJWZ0w', app_id: 'app_id_test', app_password: 'app_password_test', production: false}
23
- response.status.should eq(200)
24
- response.channel.should eq('elavon')
25
- response.state.should eq('executed')
26
- response.currency.should eq('PLN')
27
- response.description.should eq('Test12345')
28
- response.client.should eq('cli_YM5tKz6-IfhN7T')
29
- response.created_at.should eq Time.at(1416917311)
23
+ expect(response.status).to eq(200)
24
+ expect(response.channel).to eq('elavon')
25
+ expect(response.state).to eq('executed')
26
+ expect(response.currency).to eq('PLN')
27
+ expect(response.description).to eq('Test12345')
28
+ expect(response.client).to eq('cli_YM5tKz6-IfhN7T')
29
+ expect(response.created_at).to eq Time.at(1416917311)
30
30
  end
31
31
  end
32
32
 
33
33
  it "should get params from new charge" do
34
34
  VCR.use_cassette('charges post') do
35
- response = Espago.charges :post, {
35
+ response = Espago.charges :post, {
36
36
  app_id: 'app_id_test',
37
37
  app_password: 'app_password_test',
38
38
  production: false,
@@ -48,41 +48,41 @@ describe 'Espago.charges_with_params' do
48
48
  month:'2'
49
49
  },
50
50
  }
51
- response.status.should eq(201)
52
- response.channel.should eq('elavon')
53
- response.state.should eq('executed')
54
- response.currency.should eq('PLN')
55
- response.description.should eq('Test12345')
56
- response.client.should eq('cli_YM5tKz6-IfhN7T')
57
- response.created_at.should eq Time.at(1416917311)
51
+ expect(response.status).to eq(201)
52
+ expect(response.channel).to eq('elavon')
53
+ expect(response.state).to eq('executed')
54
+ expect(response.currency).to eq('PLN')
55
+ expect(response.description).to eq('Test12345')
56
+ expect(response.client).to eq('cli_YM5tKz6-IfhN7T')
57
+ expect(response.created_at).to eq Time.at(1416917311)
58
58
  end
59
59
  end
60
60
 
61
61
  it "should get 204 status after destroy charge" do
62
62
  VCR.use_cassette('charges destroy') do
63
63
  response = Espago.charges :delete,{charge_id:'pay_kQmS_3RTfm4eix', app_id: 'app_id_test', app_password: 'app_password_test', production: false}
64
- response.state.should eq('reversed')
64
+ expect(response.state).to eq('reversed')
65
65
  end
66
66
  end
67
67
 
68
68
  it "should get refunded status after refund charge" do
69
69
  VCR.use_cassette('charges refund') do
70
70
  response = Espago.charges_refund :post,{charge_id:'pay_lQGyIon5qG59O5', app_id: 'app_id_test', app_password: 'app_password_test', production: false}
71
- response.state.should eq('refunded')
71
+ expect(response.state).to eq('refunded')
72
72
  end
73
73
  end
74
74
 
75
75
  it "should get params from complete charge" do
76
76
  VCR.use_cassette('charges complete') do
77
77
  response = Espago.charges_complete :post,{charge_id:'pay_kQmS_3RTfm4eix', app_id: 'app_id_test', app_password: 'app_password_test', production: false}
78
- response.state.should eq('executed')
78
+ expect(response.state).to eq('executed')
79
79
  end
80
80
  end
81
81
 
82
82
  it "should get params from complete charge (deprecated)" do
83
83
  VCR.use_cassette('charges complete deprecation') do
84
84
  response = Espago.complete :post,{charge_id:'pay_Wmu3hmXJIG4jsg', app_id: 'app_id_test', app_password: 'app_password_test', production: false}
85
- response.state.should eq('executed')
85
+ expect(response.state).to eq('executed')
86
86
  end
87
87
  end
88
88
 
@@ -5,17 +5,17 @@ describe 'Espago.clients' do
5
5
  it "should get list of clients" do
6
6
  VCR.use_cassette('clients get') do
7
7
  response = Espago.clients :get
8
- response.count.should eq(597)
8
+ expect(response.count).to eq(597)
9
9
  end
10
10
  end
11
11
 
12
12
  it "should get info abount clients" do
13
13
  VCR.use_cassette('clients get cli_w0Se2smYwyQ0Uw') do
14
14
  response = Espago.clients :get,{client_id:'cli_w0Se2smYwyQ0Uw'}
15
- response.email.should eq(nil)
16
- response.card['company'].should eq('VI')
17
- response.description.should eq(nil)
18
- response.created_at.should eq Time.at(1417004837)
15
+ expect(response.email).to eq(nil)
16
+ expect(response.card['company']).to eq('VI')
17
+ expect(response.description).to eq(nil)
18
+ expect(response.created_at).to eq Time.at(1417004837)
19
19
  end
20
20
  end
21
21
 
@@ -30,22 +30,22 @@ describe 'Espago.clients' do
30
30
  month:'2'
31
31
  },
32
32
  }
33
- response.status.should eq(201)
34
- response.card['company'].should eq('VI')
35
- response.card['last4'].should eq('4242')
36
- response.card['authorized'].should eq(nil)
37
- response.deleted.should eq(false)
38
- response.created_at.should eq Time.at(1417007099)
33
+ expect(response.status).to eq(201)
34
+ expect(response.card['company']).to eq('VI')
35
+ expect(response.card['last4']).to eq('4242')
36
+ expect(response.card['authorized']).to eq(nil)
37
+ expect(response.deleted).to eq(false)
38
+ expect(response.created_at).to eq Time.at(1417007099)
39
39
  end
40
40
  end
41
41
 
42
42
  it "should get status after authorize client card" do
43
43
  VCR.use_cassette('clients authorize') do
44
44
  response = Espago.clients_authorize :post,{client_id:'cli_w0Se2smYwyQ0Uw'}
45
- response.status.should eq(201)
46
- response.card['company'].should eq('VI')
47
- response.card['last4'].should eq('1112')
48
- response.card['authorized'].should eq(true)
45
+ expect(response.status).to eq(201)
46
+ expect(response.card['company']).to eq('VI')
47
+ expect(response.card['last4']).to eq('1112')
48
+ expect(response.card['authorized']).to eq(true)
49
49
  end
50
50
  end
51
51
 
@@ -62,21 +62,21 @@ describe 'Espago.clients' do
62
62
  month:'2'
63
63
  },
64
64
  }
65
- response.status.should eq(200)
66
- response.card['company'].should eq('VI')
67
- response.card['last4'].should eq('4242')
68
- response.card['authorized'].should eq(nil)
69
- response.deleted.should eq(false)
70
- response.created_at.should eq Time.at(1417004837)
65
+ expect(response.status).to eq(200)
66
+ expect(response.card['company']).to eq('VI')
67
+ expect(response.card['last4']).to eq('4242')
68
+ expect(response.card['authorized']).to eq(nil)
69
+ expect(response.deleted).to eq(false)
70
+ expect(response.created_at).to eq Time.at(1417004837)
71
71
  end
72
72
  end
73
73
 
74
74
  it "should get client invoices" do
75
75
  VCR.use_cassette('clients invoices') do
76
76
  response = Espago.clients_invoices :get, { client_id:'cli_w0Se2smYwyQ0Uw'}
77
- response.status.should eq(200)
78
- response.count.should eq(0)
79
- response.invoices.should eq([])
77
+ expect(response.status).to eq(200)
78
+ expect(response.count).to eq(0)
79
+ expect(response.invoices).to eq([])
80
80
  end
81
81
  end
82
82
 
@@ -84,16 +84,16 @@ describe 'Espago.clients' do
84
84
  it "should get client subscriptions" do
85
85
  VCR.use_cassette('clients subscriptions') do
86
86
  response = Espago.clients_subscriptions :get, { client_id:'cli_w0Se2smYwyQ0Uw'}
87
- response.status.should eq(200)
88
- response.count.should eq(0)
89
- response.subscriptions.should eq([])
87
+ expect(response.status).to eq(200)
88
+ expect(response.count).to eq(0)
89
+ expect(response.subscriptions).to eq([])
90
90
  end
91
91
  end
92
92
 
93
93
  it "should get status 204 after delete client" do
94
94
  VCR.use_cassette('clients delete') do
95
95
  response = Espago.clients :delete, { client_id:'cli_5rDoJyvKDM4RbM'}
96
- response.status.should eq(204)
96
+ expect(response.status).to eq(204)
97
97
  end
98
98
  end
99
99
 
@@ -6,13 +6,13 @@ describe 'Espago.dcc_decision' do
6
6
  it "should get params from new charge" do
7
7
  VCR.use_cassette('dcc_decision post') do
8
8
  response = Espago.dcc_decision :post, {charge_id:'pay_mTOngouLTJWZ0w', decision:'Y'}
9
- response.status.should eq(201)
10
- response.channel.should eq('elavon')
11
- response.state.should eq('executed')
12
- response.currency.should eq('PLN')
13
- response.description.should eq('Test12345')
14
- response.client.should eq('cli_YM5tKz6-IfhN7T')
15
- response.created_at.should eq Time.at(1416917311)
9
+ expect(response.status).to eq(201)
10
+ expect(response.channel).to eq('elavon')
11
+ expect(response.state).to eq('executed')
12
+ expect(response.currency).to eq('PLN')
13
+ expect(response.description).to eq('Test12345')
14
+ expect(response.client).to eq('cli_YM5tKz6-IfhN7T')
15
+ expect(response.created_at).to eq Time.at(1416917311)
16
16
  end
17
17
  end
18
18
 
@@ -5,9 +5,9 @@ describe 'Espago.invoice_items' do
5
5
  it "should get info abount invoice_items" do
6
6
  VCR.use_cassette('invoice_items get ii_5LS-YR7S1QaJBl3') do
7
7
  response = Espago.invoice_items :get,{invoice_item_id:'ii_5LS-YR7S1QaJBl3'}
8
- response.client.should eq('cli_90Pi6Jf0ndl_PP')
9
- response.amount.should eq('123.45')
10
- response.created_at.should eq Time.at(1417030496)
8
+ expect(response.client).to eq('cli_90Pi6Jf0ndl_PP')
9
+ expect(response.amount).to eq('123.45')
10
+ expect(response.created_at).to eq Time.at(1417030496)
11
11
  end
12
12
  end
13
13
 
@@ -19,18 +19,18 @@ describe 'Espago.invoice_items' do
19
19
  description: 'Test invoice items',
20
20
  client: 'cli_90Pi6Jf0ndl_PP'
21
21
  }
22
- response.status.should eq(201)
23
- response.client.should eq('cli_90Pi6Jf0ndl_PP')
24
- response.amount.should eq('49.99')
25
- response.currency.should eq('pln')
26
- response.created_at.should eq Time.at(1417102491)
22
+ expect(response.status).to eq(201)
23
+ expect(response.client).to eq('cli_90Pi6Jf0ndl_PP')
24
+ expect(response.amount).to eq('49.99')
25
+ expect(response.currency).to eq('pln')
26
+ expect(response.created_at).to eq Time.at(1417102491)
27
27
  end
28
28
  end
29
29
 
30
30
  it "should get info abount deleted invoice_items" do
31
31
  VCR.use_cassette('invoice_items delete ii_WDzszvhTshe78Xd') do
32
32
  response = Espago.invoice_items :delete,{invoice_item_id:'ii_WDzszvhTshe78Xd'}
33
- response.status.should eq(204)
33
+ expect(response.status).to eq(204)
34
34
  end
35
35
  end
36
36