summaryrefslogtreecommitdiff
path: root/spec/support/services/service_response_shared_examples.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/support/services/service_response_shared_examples.rb')
-rw-r--r--spec/support/services/service_response_shared_examples.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/spec/support/services/service_response_shared_examples.rb b/spec/support/services/service_response_shared_examples.rb
new file mode 100644
index 00000000000..186627347fb
--- /dev/null
+++ b/spec/support/services/service_response_shared_examples.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+
+RSpec.shared_examples 'returning an error service response' do |message: nil|
+ it 'returns an error service response' do
+ result = subject
+
+ expect(result).to be_error
+
+ if message
+ expect(result.message).to eq(message)
+ end
+ end
+end
+
+RSpec.shared_examples 'returning a success service response' do |message: nil|
+ it 'returns a success service response' do
+ result = subject
+
+ expect(result).to be_success
+
+ if message
+ expect(result.message).to eq(message)
+ end
+ end
+end