diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 3e2bf49..980ea05 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.4.1" + ".": "0.4.2" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 3e20d4f..ac83981 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 15 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/hexlet%2Fcloudpayments-737bf804f9ef1282c03bc532fc392f69a6e00eb5d229fa39368ea8ca2ff02de1.yml openapi_spec_hash: 68aafd72cb1fa7266ab697cc29f73583 -config_hash: 33c8a1290e177bcab7a82d1fe4e9ecfd +config_hash: 7e3e36dabba4af552324a8ffefba23f5 diff --git a/CHANGELOG.md b/CHANGELOG.md index be1a340..6d19bf5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ # Changelog +## 0.4.2 (2026-02-27) + +Full Changelog: [v0.4.1...v0.4.2](https://github.com/Hexlet/cloudpayments-ruby/compare/v0.4.1...v0.4.2) + +### Bug Fixes + +* properly mock time in ruby ci tests ([7cfd820](https://github.com/Hexlet/cloudpayments-ruby/commit/7cfd8204e2a9d7045d9a05045be6b525768455e0)) + + +### Chores + +* **internal:** remove mock server code ([e100d4f](https://github.com/Hexlet/cloudpayments-ruby/commit/e100d4f1eb3433101355817d309ae3008b0faa06)) +* update mock server docs ([36a2a37](https://github.com/Hexlet/cloudpayments-ruby/commit/36a2a3788aa8b4638c9d41e2fe54a6cd4a939990)) + ## 0.4.1 (2026-02-13) Full Changelog: [v0.4.0...v0.4.1](https://github.com/Hexlet/cloudpayments-ruby/compare/v0.4.0...v0.4.1) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d38fc92..8d2514f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -66,12 +66,6 @@ $ bundle exec rake ## Running tests -Most tests require you to [set up a mock server](https://github.com/stoplightio/prism) against the OpenAPI spec to run the tests. - -```bash -$ npx prism mock path/to/your/openapi.yml -``` - ```bash $ bundle exec rake test ``` diff --git a/Gemfile.lock b/Gemfile.lock index a8d38fb..660c30e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -11,7 +11,7 @@ GIT PATH remote: . specs: - cloudpayments-ruby (0.4.1) + cloudpayments-ruby (0.4.2) cgi connection_pool diff --git a/README.md b/README.md index 91fdbde..4dd30b8 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ To use this gem, install via Bundler by adding the following to your application ```ruby -gem "cloudpayments-ruby", "~> 0.4.1" +gem "cloudpayments-ruby", "~> 0.4.2" ``` diff --git a/lib/cloudpayments_ruby/version.rb b/lib/cloudpayments_ruby/version.rb index e6fd350..9b7fe58 100644 --- a/lib/cloudpayments_ruby/version.rb +++ b/lib/cloudpayments_ruby/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module CloudpaymentsRuby - VERSION = "0.4.1" + VERSION = "0.4.2" end diff --git a/scripts/mock b/scripts/mock deleted file mode 100755 index 0b28f6e..0000000 --- a/scripts/mock +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/env bash - -set -e - -cd "$(dirname "$0")/.." - -if [[ -n "$1" && "$1" != '--'* ]]; then - URL="$1" - shift -else - URL="$(grep 'openapi_spec_url' .stats.yml | cut -d' ' -f2)" -fi - -# Check if the URL is empty -if [ -z "$URL" ]; then - echo "Error: No OpenAPI spec path/url provided or found in .stats.yml" - exit 1 -fi - -echo "==> Starting mock server with URL ${URL}" - -# Run prism mock on the given spec -if [ "$1" == "--daemon" ]; then - npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" &> .prism.log & - - # Wait for server to come online - echo -n "Waiting for server" - while ! grep -q "✖ fatal\|Prism is listening" ".prism.log" ; do - echo -n "." - sleep 0.1 - done - - if grep -q "✖ fatal" ".prism.log"; then - cat .prism.log - exit 1 - fi - - echo -else - npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" -fi diff --git a/scripts/test b/scripts/test index e0dc137..df8caf9 100755 --- a/scripts/test +++ b/scripts/test @@ -4,53 +4,7 @@ set -e cd -- "$(dirname -- "$0")/.." -RED='\033[0;31m' -GREEN='\033[0;32m' -YELLOW='\033[0;33m' -NC='\033[0m' # No Color -function prism_is_running() { - curl --silent "http://localhost:4010" >/dev/null 2>&1 -} - -kill_server_on_port() { - pids=$(lsof -t -i tcp:"$1" || echo "") - if [ "$pids" != "" ]; then - kill "$pids" - echo "Stopped $pids." - fi -} - -function is_overriding_api_base_url() { - [ -n "$TEST_API_BASE_URL" ] -} - -if ! is_overriding_api_base_url && ! prism_is_running ; then - # When we exit this script, make sure to kill the background mock server process - trap 'kill_server_on_port 4010' EXIT - - # Start the dev server - ./scripts/mock --daemon -fi - -if is_overriding_api_base_url ; then - echo -e "${GREEN}✔ Running tests against ${TEST_API_BASE_URL}${NC}" - echo -elif ! prism_is_running ; then - echo -e "${RED}ERROR:${NC} The test suite will not run without a mock Prism server" - echo -e "running against your OpenAPI spec." - echo - echo -e "To run the server, pass in the path or url of your OpenAPI" - echo -e "spec to the prism command:" - echo - echo -e " \$ ${YELLOW}npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock path/to/your.openapi.yml${NC}" - echo - - exit 1 -else - echo -e "${GREEN}✔ Mock prism server is running with your OpenAPI spec${NC}" - echo -fi echo "==> Running tests" bundle exec rake test "$@" diff --git a/test/cloudpayments_ruby/client_test.rb b/test/cloudpayments_ruby/client_test.rb index edaaec9..2048def 100644 --- a/test/cloudpayments_ruby/client_test.rb +++ b/test/cloudpayments_ruby/client_test.rb @@ -150,9 +150,11 @@ def test_client_retry_after_seconds end def test_client_retry_after_date + time_now = Time.now + stub_request(:post, "http://localhost/payments/cards/charge").to_return_json( status: 500, - headers: {"retry-after" => (Time.now + 10).httpdate}, + headers: {"retry-after" => (time_now + 10).httpdate}, body: {} ) @@ -164,15 +166,15 @@ def test_client_retry_after_date max_retries: 1 ) + Thread.current.thread_variable_set(:time_now, time_now) assert_raises(CloudpaymentsRuby::Errors::InternalServerError) do - Thread.current.thread_variable_set(:time_now, Time.now) cloudpayments.payments.charge( amount: 0, card_cryptogram_packet: "CardCryptogramPacket", ip_address: "IpAddress" ) - Thread.current.thread_variable_set(:time_now, nil) end + Thread.current.thread_variable_set(:time_now, nil) assert_requested(:any, /./, times: 2) assert_in_delta(10, Thread.current.thread_variable_get(:mock_sleep).last, 1.0) diff --git a/test/cloudpayments_ruby/resources/orders_test.rb b/test/cloudpayments_ruby/resources/orders_test.rb index 392cfaf..c001bd8 100644 --- a/test/cloudpayments_ruby/resources/orders_test.rb +++ b/test/cloudpayments_ruby/resources/orders_test.rb @@ -4,7 +4,7 @@ class CloudpaymentsRuby::Test::Resources::OrdersTest < CloudpaymentsRuby::Test::ResourceTest def test_create_required_params - skip("Prism tests are disabled") + skip("Mock server tests are disabled") response = @cloudpayments.orders.create(amount: 0, description: "Description") @@ -22,7 +22,7 @@ def test_create_required_params end def test_cancel_required_params - skip("Prism tests are disabled") + skip("Mock server tests are disabled") response = @cloudpayments.orders.cancel(id: "Id") diff --git a/test/cloudpayments_ruby/resources/payments/tokens_test.rb b/test/cloudpayments_ruby/resources/payments/tokens_test.rb index bd866eb..ad1d045 100644 --- a/test/cloudpayments_ruby/resources/payments/tokens_test.rb +++ b/test/cloudpayments_ruby/resources/payments/tokens_test.rb @@ -4,7 +4,7 @@ class CloudpaymentsRuby::Test::Resources::Payments::TokensTest < CloudpaymentsRuby::Test::ResourceTest def test_auth_required_params - skip("Prism tests are disabled") + skip("Mock server tests are disabled") response = @cloudpayments.payments.tokens.auth( @@ -28,7 +28,7 @@ def test_auth_required_params end def test_charge_required_params - skip("Prism tests are disabled") + skip("Mock server tests are disabled") response = @cloudpayments.payments.tokens.charge( diff --git a/test/cloudpayments_ruby/resources/payments_test.rb b/test/cloudpayments_ruby/resources/payments_test.rb index b1322d7..4d0bc94 100644 --- a/test/cloudpayments_ruby/resources/payments_test.rb +++ b/test/cloudpayments_ruby/resources/payments_test.rb @@ -4,7 +4,7 @@ class CloudpaymentsRuby::Test::Resources::PaymentsTest < CloudpaymentsRuby::Test::ResourceTest def test_auth_required_params - skip("Prism tests are disabled") + skip("Mock server tests are disabled") response = @cloudpayments.payments.auth( @@ -26,7 +26,7 @@ def test_auth_required_params end def test_charge_required_params - skip("Prism tests are disabled") + skip("Mock server tests are disabled") response = @cloudpayments.payments.charge( @@ -48,7 +48,7 @@ def test_charge_required_params end def test_confirm_required_params - skip("Prism tests are disabled") + skip("Mock server tests are disabled") response = @cloudpayments.payments.confirm(amount: 0, transaction_id: 0) @@ -65,7 +65,7 @@ def test_confirm_required_params end def test_post3ds_required_params - skip("Prism tests are disabled") + skip("Mock server tests are disabled") response = @cloudpayments.payments.post3ds(pa_res: "PaRes", transaction_id: 0) @@ -83,7 +83,7 @@ def test_post3ds_required_params end def test_refund_required_params - skip("Prism tests are disabled") + skip("Mock server tests are disabled") response = @cloudpayments.payments.refund(amount: 0, transaction_id: 0) @@ -101,7 +101,7 @@ def test_refund_required_params end def test_void_required_params - skip("Prism tests are disabled") + skip("Mock server tests are disabled") response = @cloudpayments.payments.void(transaction_id: 0) diff --git a/test/cloudpayments_ruby/resources/subscriptions_test.rb b/test/cloudpayments_ruby/resources/subscriptions_test.rb index 3f49361..81df5bb 100644 --- a/test/cloudpayments_ruby/resources/subscriptions_test.rb +++ b/test/cloudpayments_ruby/resources/subscriptions_test.rb @@ -4,7 +4,7 @@ class CloudpaymentsRuby::Test::Resources::SubscriptionsTest < CloudpaymentsRuby::Test::ResourceTest def test_create_required_params - skip("Prism tests are disabled") + skip("Mock server tests are disabled") response = @cloudpayments.subscriptions.create( @@ -33,7 +33,7 @@ def test_create_required_params end def test_update_required_params - skip("Prism tests are disabled") + skip("Mock server tests are disabled") response = @cloudpayments.subscriptions.update(id: "Id") @@ -51,7 +51,7 @@ def test_update_required_params end def test_cancel_required_params - skip("Prism tests are disabled") + skip("Mock server tests are disabled") response = @cloudpayments.subscriptions.cancel(id: "Id") @@ -68,7 +68,7 @@ def test_cancel_required_params end def test_find_required_params - skip("Prism tests are disabled") + skip("Mock server tests are disabled") response = @cloudpayments.subscriptions.find(account_id: "AccountId") @@ -86,7 +86,7 @@ def test_find_required_params end def test_get_required_params - skip("Prism tests are disabled") + skip("Mock server tests are disabled") response = @cloudpayments.subscriptions.get(id: "Id")