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.

pickle_by_test_spec.rb 1.8 kB

2 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. # frozen_string_literal: true
  2. require 'spec_helper'
  3. require 'cucumber/formatter/spec_helper'
  4. require 'cucumber/formatter/query/pickle_by_test'
  5. module Cucumber
  6. module Formatter
  7. module Query
  8. describe PickleByTest do
  9. extend SpecHelperDsl
  10. include SpecHelper
  11. before(:each) do
  12. Cucumber::Term::ANSIColor.coloring = false
  13. @test_cases = []
  14. @out = StringIO.new
  15. @config = actual_runtime.configuration.with_options(out_stream: @out)
  16. @formatter = PickleByTest.new(@config)
  17. @config.on_event :test_case_created do |event|
  18. @test_cases << event.test_case
  19. end
  20. @pickle_ids = []
  21. @config.on_event :envelope do |event|
  22. next unless event.envelope.pickle
  23. @pickle_ids << event.envelope.pickle.id
  24. end
  25. end
  26. describe 'given a single feature' do
  27. before(:each) do
  28. run_defined_feature
  29. end
  30. describe 'with a scenario' do
  31. context '#pickle_id' do
  32. define_feature <<-FEATURE
  33. Feature: Banana party
  34. Scenario: Monkey eats banana
  35. Given there are bananas
  36. FEATURE
  37. it 'provides the ID of the pickle used to generate the Test::Case' do
  38. expect(@formatter.pickle_id(@test_cases.first)).to eq(@pickle_ids.first)
  39. end
  40. it 'raises an error when the Test::Case is unknown' do
  41. test_case = double
  42. allow(test_case).to receive(:id).and_return('whatever-id')
  43. expect { @formatter.pickle_id(test_case) }.to raise_error(Cucumber::Formatter::TestCaseUnknownError)
  44. end
  45. end
  46. end
  47. end
  48. end
  49. end
  50. end
  51. end

No Description

Contributors (1)