Sha256: ea5a5a87cc25dd59251270db7fc0e9673db95a7200f33c6ac28ccf0439c11493

Contents?: true

Size: 1.36 KB

Versions: 3

Compression:

Stored size: 1.36 KB

Contents

require 'nc_first_fail'

describe NcFirstFail do
  let(:formatter)   { NcFirstFail.new(StringIO.new) }
  let(:current_dir) { File.basename(File.expand_path '.') }
  let(:failure_count) { 1 }
  let(:summary_notification) do
    instance_double(RSpec::Core::Notifications::SummaryNotification,
      formatted_duration: '0.0001 seconds',
      totals_line: '3 examples, 1 failure, 1 pending',
      failure_count: failure_count,
    )
  end
  let(:failed_example_notification) do
    instance_double(RSpec::Core::Notifications::FailedExampleNotification,
      example: double(:example,
        metadata: {full_description: '_full_description_'},
        exception: '_exception_',
      ),
    )
  end

  it 'sends a failure notification for the first failure only' do
    expect(TerminalNotifier).to receive(:notify).with(
      "_full_description_\n_exception_",
      title: "#{Nc::FAILURE_EMOJI} #{current_dir}: Failure",
    )
    formatter.example_failed failed_example_notification

    expect(TerminalNotifier).to_not receive(:notify)
    formatter.example_failed failed_example_notification

    expect(TerminalNotifier).to_not receive(:notify)
    formatter.dump_summary summary_notification
  end


  context 'with all examples passing' do
    let(:failure_count) { 0 }

    it 'sends a success summary notification' do
      formatter.dump_summary summary_notification
    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
gameboard-3.1.0 vendor/bundle/ruby/2.3.0/gems/rspec-nc-0.3.0/spec/nc_first_fail_spec.rb
gameboard-3.0.0 vendor/bundle/ruby/2.3.0/gems/rspec-nc-0.3.0/spec/nc_first_fail_spec.rb
rspec-nc-0.3.0 spec/nc_first_fail_spec.rb