-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added Minitest * Added rubocop-minitest * Test Configuration * Add Webmock * Added tests for Resource * Added tests for BanckAccount * Added tests for Client * Improved README configuration example * Fetch environment variable first before using default value * Standardize Establishment class name in singular * Added tests for Establishment * Added tests for Sale * Added tests for Transfer * Added simplecov * Improved Rubocop workflow job * Added job to run tests * Optimized workflow to use less jobs
- Loading branch information
Pedro Augusto
authored
Mar 21, 2024
1 parent
b981dbb
commit 64f6076
Showing
21 changed files
with
457 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,5 @@ | |
/.ruby-gemset | ||
/*.gem | ||
/.tool-versions | ||
/.idea/ | ||
/.idea/ | ||
.byebug_history |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
require: rubocop-rake | ||
require: | ||
- rubocop-rake | ||
- rubocop-minitest | ||
|
||
AllCops: | ||
TargetRubyVersion: 3.0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
# frozen_string_literal: true | ||
|
||
require "bundler/gem_tasks" | ||
|
||
require "minitest/test_task" | ||
require "rubocop/rake_task" | ||
|
||
Minitest::TestTask.create | ||
RuboCop::RakeTask.new | ||
|
||
task default: %i[rubocop] | ||
task default: %i[test rubocop] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
lib/zspay/resources/establishments.rb → lib/zspay/resources/establishment.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# frozen_string_literal: true | ||
|
||
require "test_helper" | ||
|
||
class TestConfiguration < Minitest::Test | ||
def setup | ||
Zspay.configure do |config| | ||
config.token = "my_token" | ||
end | ||
end | ||
|
||
def test_that_it_assign_token | ||
assert_equal "my_token", Zspay.configuration.token | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# frozen_string_literal: true | ||
|
||
$LOAD_PATH.unshift File.expand_path("../lib", __dir__) | ||
|
||
require "simplecov" | ||
SimpleCov.start do | ||
add_filter "/test/" | ||
end | ||
|
||
require "zspay" | ||
|
||
require "webmock" | ||
require "webmock/minitest" | ||
|
||
require "minitest/autorun" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# frozen_string_literal: true | ||
|
||
require "test_helper" | ||
|
||
class TestVersion < Minitest::Test | ||
def test_that_it_has_a_version_number | ||
refute_nil Zspay::VERSION | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# frozen_string_literal: true | ||
|
||
require "test_helper" | ||
|
||
class TestBankAccount < Minitest::Test | ||
def setup | ||
@resource_path = "/estabelecimentos/contas_bancarias" | ||
end | ||
|
||
def test_index | ||
mock = Minitest::Mock.new | ||
mock.expect :call, [], [@resource_path] | ||
|
||
Zspay::BankAccount.stub :get, mock do | ||
Zspay::BankAccount.index | ||
end | ||
|
||
mock.verify | ||
end | ||
|
||
def test_create | ||
account = { name: "Example" } | ||
mock = Minitest::Mock.new | ||
mock.expect :call, [], [@resource_path, account] | ||
|
||
Zspay::BankAccount.stub :post, mock do | ||
Zspay::BankAccount.create(account) | ||
end | ||
|
||
mock.verify | ||
end | ||
|
||
def test_active | ||
account_id = 1 | ||
mock = Minitest::Mock.new | ||
mock.expect :call, [], ["#{@resource_path}/#{account_id}/ativar"] | ||
|
||
Zspay::BankAccount.stub :post, mock do | ||
Zspay::BankAccount.active(account_id) | ||
end | ||
|
||
mock.verify | ||
end | ||
|
||
def test_destroy | ||
establishment_id = 1 | ||
account_id = 1 | ||
mock = Minitest::Mock.new | ||
mock.expect :call, [], ["/estabelecimentos/#{establishment_id}/contas_bancarias/#{account_id}/excluir"] | ||
|
||
Zspay::BankAccount.stub :delete, mock do | ||
Zspay::BankAccount.destroy(establishment_id, account_id) | ||
end | ||
|
||
mock.verify | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# frozen_string_literal: true | ||
|
||
require "test_helper" | ||
|
||
class TestClient < Minitest::Test | ||
def setup | ||
@clients_path = "/clientes" | ||
end | ||
|
||
def test_create | ||
client_data = { name: "John Doe", email: "[email protected]" } | ||
mock = Minitest::Mock.new | ||
mock.expect :call, [], [@clients_path, client_data] | ||
|
||
Zspay::Client.stub :post, mock do | ||
Zspay::Client.create(client_data) | ||
end | ||
|
||
mock.verify | ||
end | ||
|
||
def test_create_card | ||
client_id = "123" | ||
card_data = { number: "4111111111111111", expiry_month: "12", expiry_year: "2023", cvv: "123" } | ||
mock = Minitest::Mock.new | ||
mock.expect :call, [], ["#{@clients_path}/#{client_id}/cartoes", card_data] | ||
|
||
Zspay::Client.stub :post, mock do | ||
Zspay::Client.create_card(client_id, card_data) | ||
end | ||
|
||
mock.verify | ||
end | ||
end |
Oops, something went wrong.