diff --git a/spec/lib/convenient_service/examples/standard/cowsay/services/build_cloud_spec.rb b/spec/lib/convenient_service/examples/standard/cowsay/services/build_cloud_spec.rb index 26981f1c971..327307e5e14 100644 --- a/spec/lib/convenient_service/examples/standard/cowsay/services/build_cloud_spec.rb +++ b/spec/lib/convenient_service/examples/standard/cowsay/services/build_cloud_spec.rb @@ -17,19 +17,21 @@ example_group "class methods" do describe ".result" do - context "when text is NOT passed" do - subject(:result) { described_class.result } + context "when `BuildCloud` is successful" do + context "when text is NOT passed" do + subject(:result) { described_class.result } - let(:cloud) do - <<~HEREDOC - ______________ - < Hello World! > - -------------- - HEREDOC - end + let(:cloud) do + <<~HEREDOC + ______________ + < Hello World! > + -------------- + HEREDOC + end - it "returns success with cloud with \"Hello World!\"" do - expect(result).to be_success.with_data(cloud: cloud) + it "returns success with cloud with \"Hello World!\"" do + expect(result).to be_success.with_data(cloud: cloud) + end end end diff --git a/spec/lib/convenient_service/examples/standard/cowsay/services/build_cow_spec.rb b/spec/lib/convenient_service/examples/standard/cowsay/services/build_cow_spec.rb index 463b9cbcb1a..2b0442cfaa4 100644 --- a/spec/lib/convenient_service/examples/standard/cowsay/services/build_cow_spec.rb +++ b/spec/lib/convenient_service/examples/standard/cowsay/services/build_cow_spec.rb @@ -17,20 +17,22 @@ example_group "class methods" do describe ".result" do - subject(:result) { described_class.result } - - let(:cow) do - <<~'HEREDOC'.split("\n").map { |line| " " * 10 + line }.join("\n") - \ ^__^ - \ (oo)\_______ - (__)\ )\/\ - ||----w | - || || - HEREDOC - end - - it "returns success with data" do - expect(result).to be_success.with_data(cow: cow) + context "when `BuildCow` is successful" do + subject(:result) { described_class.result } + + let(:cow) do + <<~'HEREDOC'.split("\n").map { |line| " " * 10 + line }.join("\n") + \ ^__^ + \ (oo)\_______ + (__)\ )\/\ + ||----w | + || || + HEREDOC + end + + it "returns success with data" do + expect(result).to be_success.with_data(cow: cow) + end end end end diff --git a/spec/lib/convenient_service/examples/standard/cowsay/services/print_spec.rb b/spec/lib/convenient_service/examples/standard/cowsay/services/print_spec.rb index 4bda8028258..622f87d8ba6 100644 --- a/spec/lib/convenient_service/examples/standard/cowsay/services/print_spec.rb +++ b/spec/lib/convenient_service/examples/standard/cowsay/services/print_spec.rb @@ -9,88 +9,79 @@ include ConvenientService::RSpec::Matchers::Results include ConvenientService::RSpec::Matchers::IncludeModule - let(:text) { "foo" } - let(:out) { Tempfile.new } - example_group "modules" do subject { described_class } it { is_expected.to include_module(ConvenientService::Standard::Config) } end - example_group "attributes" do - include ConvenientService::RSpec::PrimitiveMatchers::HaveAttrReader - - subject { service } - - let(:service) { described_class.new(text: text, out: out) } - - it { is_expected.to have_attr_reader(:text) } - it { is_expected.to have_attr_reader(:out) } - end - example_group "class methods" do describe ".result" do - context "when `text` is NOT passed" do - subject(:result) { described_class.result(out: out) } - - let(:content) do - <<~'HEREDOC' - ______________ - < Hello World! > - -------------- - \ ^__^ - \ (oo)\_______ - (__)\ )\/\ - ||----w | - || || - HEREDOC - end + context "when `Print` is successful" do + let(:text) { "foo" } + let(:out) { Tempfile.new } + + context "when `text` is NOT passed" do + subject(:result) { described_class.result(out: out) } + + let(:content) do + <<~'HEREDOC' + ______________ + < Hello World! > + -------------- + \ ^__^ + \ (oo)\_______ + (__)\ )\/\ + ||----w | + || || + HEREDOC + end - it "returns success" do - expect(result).to be_success.without_data - end + it "returns success" do + expect(result).to be_success.without_data + end - it "prints cloud and cow to out" do - result + it "prints cloud and cow to out" do + result - expect(out.tap(&:rewind).read).to eq(content) + expect(out.tap(&:rewind).read).to eq(content) + end end - end - context "when `text` is passed" do - subject(:result) { described_class.result(text: text, out: out) } - - let(:content) do - <<~'HEREDOC' - _____ - < Hi! > - ----- - \ ^__^ - \ (oo)\_______ - (__)\ )\/\ - ||----w | - || || - HEREDOC - end + context "when `text` is passed" do + subject(:result) { described_class.result(text: text, out: out) } + + let(:content) do + <<~'HEREDOC' + _____ + < Hi! > + ----- + \ ^__^ + \ (oo)\_______ + (__)\ )\/\ + ||----w | + || || + HEREDOC + end - let(:text) { "Hi!" } + let(:text) { "Hi!" } - it "returns `success`" do - expect(result).to be_success.without_data - end + it "returns `success`" do + expect(result).to be_success.without_data + end - it "prints cloud and cow to out" do - result + it "prints cloud and cow to out" do + result - expect(out.tap(&:rewind).read).to eq(content) - end + expect(out.tap(&:rewind).read).to eq(content) + end - context "when `out` is NOT passed" do - subject(:result) { described_class.result(text: text) } + context "when `out` is NOT passed" do + subject(:result) { described_class.result(text: text) } - it "defaults to `stdout`" do - expect { result }.to output(content).to_stdout + it "defaults to `stdout`" do + expect { result }.to output(content).to_stdout + end end end end