Skip to content

Commit

Permalink
Fix failure! argument error (ruby 3)
Browse files Browse the repository at this point in the history
  • Loading branch information
ystetsyk authored and stgeneral committed Sep 28, 2023
1 parent 6235cef commit 4022f72
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/auxiliary_rails/concerns/performable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def ensure_execution!
def failure!(message = nil, options = {})
ensure_empty_status!

errors.add(:base, message, options) if message.present?
errors.add(:base, message, **options) if message.present?

self.performable_status = :failure
self
Expand Down
12 changes: 12 additions & 0 deletions spec/sample_commands_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,16 @@
end
end
end

describe 'FailureMessageErrorsCommand' do
subject(:cmd) { SampleCommands::FailureMessageErrorsCommand.new }

describe '#call' do
it do
expect(cmd.call).to be_failure
expect(cmd.errors.first.options).to eq foo: :bar
expect(cmd.errors.full_messages.join(', ')).to eq 'Custom failure message!'
end
end
end
end
6 changes: 6 additions & 0 deletions spec/support/sample_classes/sample_commands.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,10 @@ def perform
success!
end
end

class FailureMessageErrorsCommand < AuxiliaryRails::Application::Command
def perform
failure!('Custom failure message!', { foo: :bar })
end
end
end

0 comments on commit 4022f72

Please sign in to comment.