Sha256: 38ebb3f88d13c94a1573a11b83d4f5f2cab1e6def4ad01d46fac6557f179619d

Contents?: true

Size: 541 Bytes

Versions: 9

Compression:

Stored size: 541 Bytes

Contents

RSpec::Matchers.define :warn do |message|
  match do |block|
    output = fake_stderr(&block)
    output.include? message
  end

  description do
    "write \"#{message}\" to standard error"
  end

  failure_message do
    "expected to #{description}"
  end

  failure_message_when_negated do
    "expected to not #{description}"
  end

  def fake_stderr
    original_stderr = $stderr
    $stderr = StringIO.new
    yield
    $stderr.string
  ensure
    $stderr = original_stderr
  end

  def supports_block_expectations?
    true
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
green-button-data-0.3.2 spec/support/custom_expectations/warn_expectation.rb
green-button-data-0.4.0.alpha.pre.1 spec/support/custom_expectations/warn_expectation.rb
green-button-data-0.3.1 spec/support/custom_expectations/warn_expectation.rb
green-button-data-0.3.0 spec/support/custom_expectations/warn_expectation.rb
green-button-data-0.2.1 spec/support/custom_expectations/warn_expectation.rb
green-button-data-0.2.0 spec/support/custom_expectations/warn_expectation.rb
green-button-data-0.1.2 spec/support/custom_expectations/warn_expectation.rb
green-button-data-0.1.1 spec/support/custom_expectations/warn_expectation.rb
green-button-data-0.1.0 spec/support/custom_expectations/warn_expectation.rb