From e7a74292d45b0dd727bc45c3dab2a82ce76a8a1e Mon Sep 17 00:00:00 2001 From: Marian13 Date: Sun, 14 Jan 2024 16:47:33 +0200 Subject: [PATCH] refactor(examples): structure contexts --- .../v1/gemfile/services/run_shell_command_spec.rb | 2 +- .../gemfile/services/run_shell_command_spec.rb | 2 +- .../services/extract_params_from_path_spec.rb | 4 ++-- .../v1/gemfile/services/run_shell_command_spec.rb | 2 +- .../services/extract_params_from_path_spec.rb | 4 ++-- .../stub_service/entities/result_spec_spec.rb | 10 +++++----- .../error/middleware_spec.rb | 14 +++++++------- .../middleware_spec.rb | 2 +- 8 files changed, 20 insertions(+), 20 deletions(-) diff --git a/spec/lib/convenient_service/examples/rails/v1/gemfile/services/run_shell_command_spec.rb b/spec/lib/convenient_service/examples/rails/v1/gemfile/services/run_shell_command_spec.rb index 04fe7738aa2..993ae44e3a5 100644 --- a/spec/lib/convenient_service/examples/rails/v1/gemfile/services/run_shell_command_spec.rb +++ b/spec/lib/convenient_service/examples/rails/v1/gemfile/services/run_shell_command_spec.rb @@ -52,7 +52,7 @@ allow(service).to receive(:system).with(command).and_return(false) end - it "returns error with message" do + it "returns `error` with message" do expect(result).to be_error.with_message("#{command} returned non-zero exit code").of_service(described_class).of_step(:result) end end diff --git a/spec/lib/convenient_service/examples/standard/gemfile/services/run_shell_command_spec.rb b/spec/lib/convenient_service/examples/standard/gemfile/services/run_shell_command_spec.rb index 2c017866af1..9d82d49d26c 100644 --- a/spec/lib/convenient_service/examples/standard/gemfile/services/run_shell_command_spec.rb +++ b/spec/lib/convenient_service/examples/standard/gemfile/services/run_shell_command_spec.rb @@ -64,7 +64,7 @@ allow(service).to receive(:system).with(command).and_return(false) end - it "returns error with message" do + it "returns `error` with message" do expect(result).to be_error.with_message("#{command} returned non-zero exit code").of_service(described_class).of_step(:result) end end diff --git a/spec/lib/convenient_service/examples/standard/request_params/services/extract_params_from_path_spec.rb b/spec/lib/convenient_service/examples/standard/request_params/services/extract_params_from_path_spec.rb index 63a481cdeac..0423f5d2088 100644 --- a/spec/lib/convenient_service/examples/standard/request_params/services/extract_params_from_path_spec.rb +++ b/spec/lib/convenient_service/examples/standard/request_params/services/extract_params_from_path_spec.rb @@ -46,7 +46,7 @@ MESSAGE end - it "returns error with message" do + it "returns `error` with message" do expect(result).to be_error.with_message(error_message) end end @@ -57,7 +57,7 @@ let(:error_message) { "Path `#{path}` does NOT match pattern `#{pattern}`." } - it "returns error with message" do + it "returns `error` with message" do expect(result).to be_error.with_message(error_message) end end diff --git a/spec/lib/convenient_service/examples/standard/v1/gemfile/services/run_shell_command_spec.rb b/spec/lib/convenient_service/examples/standard/v1/gemfile/services/run_shell_command_spec.rb index b5ef4c0f6d7..98687a0ae7d 100644 --- a/spec/lib/convenient_service/examples/standard/v1/gemfile/services/run_shell_command_spec.rb +++ b/spec/lib/convenient_service/examples/standard/v1/gemfile/services/run_shell_command_spec.rb @@ -58,7 +58,7 @@ allow(service).to receive(:system).with(command).and_return(false) end - it "returns error with message" do + it "returns `error` with message" do expect(result).to be_error.with_message("#{command} returned non-zero exit code").of_service(described_class).of_step(:result) end end diff --git a/spec/lib/convenient_service/examples/standard/v1/request_params/services/extract_params_from_path_spec.rb b/spec/lib/convenient_service/examples/standard/v1/request_params/services/extract_params_from_path_spec.rb index 55d06be4c0a..8537893ac9b 100644 --- a/spec/lib/convenient_service/examples/standard/v1/request_params/services/extract_params_from_path_spec.rb +++ b/spec/lib/convenient_service/examples/standard/v1/request_params/services/extract_params_from_path_spec.rb @@ -46,7 +46,7 @@ MESSAGE end - it "returns error with message" do + it "returns `error` with message" do expect(result).to be_error.with_message(error_message) end end @@ -57,7 +57,7 @@ let(:error_message) { "Path `#{path}` does NOT match pattern `#{pattern}`." } - it "returns error with message" do + it "returns `error` with message" do expect(result).to be_error.with_message(error_message) end end diff --git a/spec/lib/convenient_service/rspec/helpers/classes/stub_service/entities/result_spec_spec.rb b/spec/lib/convenient_service/rspec/helpers/classes/stub_service/entities/result_spec_spec.rb index 70cec7a2282..7c97941c471 100644 --- a/spec/lib/convenient_service/rspec/helpers/classes/stub_service/entities/result_spec_spec.rb +++ b/spec/lib/convenient_service/rspec/helpers/classes/stub_service/entities/result_spec_spec.rb @@ -75,7 +75,7 @@ def result context "when result spec for error" do let(:result_spec) { described_class.new(status: :error, service_class: service_class) } - it "returns error" do + it "returns `error`" do expect(result_spec.calculate_value).to be_error end @@ -87,7 +87,7 @@ def result let(:result_spec) { described_class.new(status: :error, service_class: service_class).with_message(message) } let(:message) { "foo" } - it "returns error with message" do + it "returns `error` with message" do expect(result_spec.calculate_value).to be_error.with_message(message) end @@ -95,7 +95,7 @@ def result let(:result_spec) { described_class.new(status: :error, service_class: service_class).with_message(message).and_code(code) } let(:code) { :foo } - it "returns error with message" do + it "returns `error` with message" do expect(result_spec.calculate_value).to be_error.with_message(message).and_code(code) end end @@ -105,7 +105,7 @@ def result let(:result_spec) { described_class.new(status: :error, service_class: service_class).with_code(code) } let(:code) { :foo } - it "returns error with code" do + it "returns `error` with code" do expect(result_spec.calculate_value).to be_error.with_code(code) end @@ -113,7 +113,7 @@ def result let(:result_spec) { described_class.new(status: :error, service_class: service_class).with_code(code).and_message(message) } let(:message) { "foo" } - it "returns error with message" do + it "returns `error` with message" do expect(result_spec.calculate_value).to be_error.with_code(code).and_message(message) end end diff --git a/spec/lib/convenient_service/service/plugins/has_j_send_result_short_syntax/error/middleware_spec.rb b/spec/lib/convenient_service/service/plugins/has_j_send_result_short_syntax/error/middleware_spec.rb index 29c5505fcf2..b6500a72e7c 100644 --- a/spec/lib/convenient_service/service/plugins/has_j_send_result_short_syntax/error/middleware_spec.rb +++ b/spec/lib/convenient_service/service/plugins/has_j_send_result_short_syntax/error/middleware_spec.rb @@ -61,7 +61,7 @@ context "when `args` are NOT passed" do subject(:method_value) { method.call } - it "returns error without data" do + it "returns `error` without data" do expect(method_value).to be_error.without_data end end @@ -70,7 +70,7 @@ context "when only one `arg` is passed" do subject(:method_value) { method.call("foo") } - it "returns error with message" do + it "returns `error` with message" do expect(method_value).to be_error.with_message("foo") end end @@ -78,7 +78,7 @@ context "when only two `args` are passed" do subject(:method_value) { method.call("foo", :foo) } - it "returns error with message" do + it "returns `error` with message" do expect(method_value).to be_error.with_message("foo").with_code(:foo) end end @@ -116,7 +116,7 @@ context "when `kwargs` do NOT contain `:data`, `:message` and `code` keys" do subject(:method_value) { method.call(foo: :bar) } - it "returns error with data" do + it "returns `error` with data" do expect(method_value).to be_error.with_data(foo: :bar) end end @@ -124,7 +124,7 @@ context "when `kwargs` contain `:data` key" do subject(:method_value) { method.call(data: {foo: :bar}) } - it "returns error with data" do + it "returns `error` with data" do expect(method_value).to be_error.with_data(foo: :bar) end @@ -178,7 +178,7 @@ context "when `kwargs` contain `:message` key" do subject(:method_value) { method.call(message: "foo") } - it "returns error with message" do + it "returns `error` with message" do expect(method_value).to be_error.with_message("foo") end @@ -232,7 +232,7 @@ context "when `kwargs` contain `:code` key" do subject(:method_value) { method.call(code: :foo) } - it "returns error with code" do + it "returns `error` with code" do expect(method_value).to be_error.with_code(:foo) end diff --git a/spec/lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions/middleware_spec.rb b/spec/lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions/middleware_spec.rb index f9824aab73c..cb967d4fe93 100644 --- a/spec/lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions/middleware_spec.rb +++ b/spec/lib/convenient_service/service/plugins/rescues_result_unhandled_exceptions/middleware_spec.rb @@ -165,7 +165,7 @@ def result .with_arguments(exception: exception, args: result_arguments.args, kwargs: result_arguments.kwargs, block: result_arguments.block, max_backtrace_size: max_backtrace_size) end - it "returns error with formatted exception" do + it "returns `error` with formatted exception" do expect(method_value).to be_error.with_data(exception: exception).and_message(formatted_exception) end end