Skip to content

Commit

Permalink
refactor(examples): structure contexts
Browse files Browse the repository at this point in the history
  • Loading branch information
marian13 committed Jan 14, 2024
1 parent fff27d0 commit e7a7429
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -87,15 +87,15 @@ 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

context "when result spec for error with message and code" do
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
Expand All @@ -105,15 +105,15 @@ 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

context "when result spec for error with code and message" do
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -70,15 +70,15 @@
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

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
Expand Down Expand Up @@ -116,15 +116,15 @@
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

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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e7a7429

Please sign in to comment.