Skip to content

Commit

Permalink
Merge pull request #1 from loqimean/development
Browse files Browse the repository at this point in the history
refactor: use keyword params instead named ones
  • Loading branch information
loqimean authored Jul 22, 2023
2 parents 4325304 + 8438d80 commit cdd773c
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 5 deletions.
18 changes: 16 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
## [1.0.0] - 2023-06-27

### Changed

### Breaking Change
Updated method signatures in the gem to use keyword arguments instead of named arguments.

###### Specifically
`MonopayRuby::Invoices::SimpleInvoice::new` method was affected by this change.
###### Previously
the method was called like `new("redirect/url", "webhook/url")`. Now, it should be called like `new(redirect_url: "redirect/url", webhook_url: "webhook/url")`.
#### Note
This is a breaking change and will require updating your code if you are updating to this version of the gem from an earlier version.

## [0.1.1] - 2023-06-19

- Fix typo in a `README.md` file
- add ability to pass reference to an invoice by `reference` parameter in a `MonopayRuby::Invoices::SimpleInvoice::create` method
- Use named parameter of `destionation` for "MonopayRuby::Invoices::SimpleInvoice::create" method
- Add ability to pass reference to an invoice by `reference` parameter in a `MonopayRuby::Invoices::SimpleInvoice::create` method
- Use keyword parameter of `destination` for "MonopayRuby::Invoices::SimpleInvoice::create" method

## [0.1.0] - 2023-06-18

Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
monopay-ruby (0.1.1)
monopay-ruby (1.0.0)
base64 (~> 0.1.1)
json (~> 2.5)
money (~> 6.13)
Expand Down
2 changes: 1 addition & 1 deletion lib/monopay-ruby/invoices/simple_invoice.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class SimpleInvoice < MonopayRuby::Base
#
# @param [String] redirect_url - url where user will be redirected after payment
# @param [String] webhook_url - url where Monobank will send webhook after payment
def initialize(redirect_url = nil, webhook_url = nil)
def initialize(redirect_url: nil, webhook_url: nil)
@redirect_url = redirect_url
@webhook_url = webhook_url

Expand Down
2 changes: 1 addition & 1 deletion lib/monopay-ruby/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module MonopayRuby
VERSION = "0.1.1"
VERSION = "1.0.0"
end
31 changes: 31 additions & 0 deletions spec/lib/invoices/simple_invoice_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,37 @@
# frozen_string_literal: true

RSpec.describe MonopayRuby::Invoices::SimpleInvoice do
describe "#new" do
let!(:redirect_url) { "https://redirect.example.com" }
let!(:webhook_url) { "https://webhook.example.com" }

context "with keyword parameters" do
subject { described_class.new(redirect_url: redirect_url, webhook_url: webhook_url) }

it "initializes with correct redirect_url" do
expect(subject.redirect_url).to eq(redirect_url)
end

it "initializes with correct webhook_url" do
expect(subject.webhook_url).to eq(webhook_url)
end
end

context "without keyword parameters" do
subject { described_class.new(redirect_url, webhook_url) }

it "raises an ArgumentError" do
expect { subject }.to raise_error(ArgumentError)
end
end

context "without parameters" do
subject { described_class.new }

it { is_expected.to be_a(described_class) }
end
end

describe "#create" do
context "when request is successful" do
let(:simple_invoice_instance) { described_class.new }
Expand Down

0 comments on commit cdd773c

Please sign in to comment.