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.

profile_loader_spec.rb 2.9 kB

2 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. # frozen_string_literal: true
  2. require 'spec_helper'
  3. require 'yaml'
  4. module Cucumber
  5. module Cli
  6. describe ProfileLoader do
  7. def given_cucumber_yml_defined_as(hash_or_string)
  8. allow(Dir).to receive(:glob).with('{,.config/,config/}cucumber{.yml,.yaml}') { ['cucumber.yml'] }
  9. allow(File).to receive(:exist?) { true }
  10. cucumber_yml = hash_or_string.is_a?(Hash) ? hash_or_string.to_yaml : hash_or_string
  11. allow(IO).to receive(:read).with('cucumber.yml') { cucumber_yml }
  12. end
  13. def loader
  14. ProfileLoader.new
  15. end
  16. it 'treats backslashes as literals in rerun.txt when on Windows (JRuby or MRI)' do
  17. given_cucumber_yml_defined_as('default' => '--format "pretty" features\sync_imap_mailbox.feature:16:22')
  18. if Cucumber::WINDOWS
  19. expect(loader.args_from('default')).to eq ['--format', 'pretty', 'features\sync_imap_mailbox.feature:16:22']
  20. else
  21. expect(loader.args_from('default')).to eq ['--format', 'pretty', 'featuressync_imap_mailbox.feature:16:22']
  22. end
  23. end
  24. it 'treats forward slashes as literals' do
  25. given_cucumber_yml_defined_as('default' => '--format "ugly" features/sync_imap_mailbox.feature:16:22')
  26. expect(loader.args_from('default')).to eq ['--format', 'ugly', 'features/sync_imap_mailbox.feature:16:22']
  27. end
  28. it 'treats percent sign as ERB code block after YAML directive' do
  29. yml = <<-HERE
  30. ---
  31. % x = '--format "pretty" features/sync_imap_mailbox.feature:16:22'
  32. default: <%= x %>
  33. HERE
  34. given_cucumber_yml_defined_as yml
  35. expect(loader.args_from('default')).to eq ['--format', 'pretty', 'features/sync_imap_mailbox.feature:16:22']
  36. end
  37. it 'correctly parses a profile that uses tag expressions (with double quotes)' do
  38. given_cucumber_yml_defined_as('default' => '--format "pretty" features\sync_imap_mailbox.feature:16:22 --tags "not @jruby"')
  39. if Cucumber::WINDOWS
  40. expect(loader.args_from('default')).to eq ['--format', 'pretty', 'features\sync_imap_mailbox.feature:16:22', '--tags', 'not @jruby']
  41. else
  42. expect(loader.args_from('default')).to eq ['--format', 'pretty', 'featuressync_imap_mailbox.feature:16:22', '--tags', 'not @jruby']
  43. end
  44. end
  45. it 'correctly parses a profile that uses tag expressions (with single quotes)' do
  46. given_cucumber_yml_defined_as('default' => "--format 'pretty' features\\sync_imap_mailbox.feature:16:22 --tags 'not @jruby'")
  47. if Cucumber::WINDOWS
  48. expect(loader.args_from('default')).to eq ['--format', 'pretty', 'features\sync_imap_mailbox.feature:16:22', '--tags', 'not @jruby']
  49. else
  50. expect(loader.args_from('default')).to eq ['--format', 'pretty', 'featuressync_imap_mailbox.feature:16:22', '--tags', 'not @jruby']
  51. end
  52. end
  53. end
  54. end
  55. end

No Description

Contributors (1)