Sha256: 90197c42c750e5a0103366887b0c9590d22e6c35644701147087a3e227505a89

Contents?: true

Size: 880 Bytes

Versions: 10

Compression:

Stored size: 880 Bytes

Contents

require "spec_helper"
require "boxes/testing"

RSpec.describe Boxes::Testing::Matchers::WriteToStdoutMatcher do
  context "when the output matches" do
    it "passes" do
      expected = mock_command(stdout: "Hello World!\n")

      instance = described_class.new("Hello World!\n")
      outcome = instance.matches?(expected)

      expect(outcome).to be(true)
    end
  end

  context "when the output is different" do
    it "fails with a message" do
      expected = mock_command(stdout: "Hello!\n")

      instance = described_class.new("Hello World!\n")
      outcome = instance.matches?(expected)

      expect(outcome).to be(false)
      expect(instance.failure_message).to eq(
        "expected that 'Hello!\\n' would be Hello World!\\n",
      )
    end
  end

  def mock_command(cmd: nil, stdout: nil)
    double("Command::Response", cmd: cmd, stdout: stdout)
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
boxes-3.7.0 spec/boxes/testing/matchers/write_to_stdout_matcher_spec.rb
boxes-3.6.1 spec/boxes/testing/matchers/write_to_stdout_matcher_spec.rb
boxes-3.6.0 spec/boxes/testing/matchers/write_to_stdout_matcher_spec.rb
boxes-3.5.0 spec/boxes/testing/matchers/write_to_stdout_matcher_spec.rb
boxes-3.4.0 spec/boxes/testing/matchers/write_to_stdout_matcher_spec.rb
boxes-3.3.1 spec/boxes/testing/matchers/write_to_stdout_matcher_spec.rb
boxes-3.3.0 spec/boxes/testing/matchers/write_to_stdout_matcher_spec.rb
boxes-3.2.0 spec/boxes/testing/matchers/write_to_stdout_matcher_spec.rb
boxes-3.1.0 spec/boxes/testing/matchers/write_to_stdout_matcher_spec.rb
boxes-3.0.0 spec/boxes/testing/matchers/write_to_stdout_matcher_spec.rb