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.

rerun_spec.rb 2.9 kB

2 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. # frozen_string_literal: true
  2. require 'spec_helper'
  3. module Cucumber
  4. module Cli
  5. describe RerunFile do
  6. let(:rerun_file) { RerunFile.new('@rerun.txt') }
  7. it 'expects rerun files to have a leading @' do
  8. allow(File).to receive(:file?) { true }
  9. expect(RerunFile.can_read?('rerun.txt')).to eq false
  10. expect(RerunFile.can_read?('@rerun.txt')).to eq true
  11. end
  12. it 'does not treat directories as rerun files' do
  13. allow(File).to receive(:file?) { false }
  14. expect(RerunFile.can_read?('@rerun.txt')).to eq false
  15. end
  16. it 'removes leading @ character from filename' do
  17. expect(rerun_file.path).to eq 'rerun.txt'
  18. end
  19. context 'rerun file containing single feature' do
  20. before(:each) do
  21. allow(IO).to receive(:read).and_return('cucumber.feature')
  22. end
  23. it 'produces an array containing a single feature file path' do
  24. expect(rerun_file.features).to eq %w[cucumber.feature]
  25. end
  26. end
  27. context 'contains multiple features on multiple lines' do
  28. before(:each) do
  29. allow(IO).to receive(:read).and_return("cucumber.feature\nfoo.feature")
  30. end
  31. it 'produces an array containing multiple feature file paths' do
  32. expect(rerun_file.features).to eq %w[cucumber.feature foo.feature]
  33. end
  34. end
  35. context 'contains multiple features on same line' do
  36. before(:each) do
  37. allow(IO).to receive(:read).and_return('cucumber.feature foo.feature')
  38. end
  39. it 'produces an array containing multiple feature file paths' do
  40. expect(rerun_file.features).to eq %w[cucumber.feature foo.feature]
  41. end
  42. end
  43. context 'contains multiple scenarios on same line' do
  44. before(:each) do
  45. allow(IO).to receive(:read).and_return('cucumber.feature:8 foo.feature:8:16')
  46. end
  47. it 'produces an array containing multiple feature file paths with scenario lines' do
  48. expect(rerun_file.features).to eq %w[cucumber.feature:8 foo.feature:8:16]
  49. end
  50. end
  51. context 'contains features with spaces in file names' do
  52. before(:each) do
  53. allow(IO).to receive(:read).and_return('cucumber test.feature:8 foo.feature:8:16')
  54. end
  55. it 'produces an array containing multiple feature file paths with scenario lines' do
  56. expect(rerun_file.features).to eq ['cucumber test.feature:8', 'foo.feature:8:16']
  57. end
  58. end
  59. context 'contains multiple scenarios without spaces between them' do
  60. before(:each) do
  61. allow(IO).to receive(:read).and_return('cucumber test.feature:8foo.feature:8:16')
  62. end
  63. it 'produces an array containing multiple feature file paths with scenario lines' do
  64. expect(rerun_file.features).to eq ['cucumber test.feature:8', 'foo.feature:8:16']
  65. end
  66. end
  67. end
  68. end
  69. end

No Description

Contributors (1)