You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

deprecate_spec.rb 1.5 kB

2 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # frozen_string_literal: true
  2. require 'spec_helper'
  3. module Cucumber::Deprecate
  4. describe 'Cucumber.deprecate' do
  5. context 'for developers' do
  6. it 'fails when running the tests' do
  7. expect do
  8. Cucumber.deprecate('Use some_method instead', 'someMethod', '1.0.0')
  9. end.to raise_exception('This method is due for removal after version 1.0.0')
  10. end
  11. end
  12. context 'for users' do
  13. it 'outputs a message to STDERR' do
  14. stub_const('Cucumber::Deprecate::STRATEGY', ForUsers)
  15. allow($stderr).to receive(:puts)
  16. Cucumber.deprecate('Use some_method instead', 'someMethod', '1.0.0')
  17. expect($stderr).to have_received(:puts).with(
  18. a_string_including(
  19. 'WARNING: #someMethod is deprecated and will be removed after version 1.0.0. Use some_method instead.'
  20. )
  21. )
  22. end
  23. end
  24. end
  25. describe CliOption do
  26. let(:error_stream) { double }
  27. context '.deprecate' do
  28. it 'outputs a warning to the provided channel' do
  29. allow(error_stream).to receive(:puts)
  30. described_class.deprecate(error_stream, '--some-option', 'Please use --another-option instead', '1.2.3')
  31. expect(error_stream).to have_received(:puts).with(
  32. a_string_including(
  33. "WARNING: --some-option is deprecated and will be removed after version 1.2.3.\n" \
  34. 'Please use --another-option instead.'
  35. )
  36. )
  37. end
  38. end
  39. end
  40. end

No Description

Contributors (1)