gemfile_helper_spec.rb 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. require 'rails_helper'
  2. describe GemfileHelper do
  3. context 'parse_each_agent_gem' do
  4. VALID_STRINGS = [
  5. ['huginn_nlp_agents(~> 0.2.1)', [
  6. ['huginn_nlp_agents', '~> 0.2.1']
  7. ]],
  8. ['huginn_nlp_agents(~> 0.2.1, git: http://github.com/dsander/huginn.git, branch: agents_in_gems)',
  9. [['huginn_nlp_agents', '~> 0.2.1', git: 'http://github.com/dsander/huginn.git', branch: 'agents_in_gems']]
  10. ],
  11. ['huginn_nlp_agents(~> 0.2.1, git: http://github.com/dsander/huginn.git, ref: 2342asdab) , huginn_nlp_agents(~> 0.2.1)', [
  12. ['huginn_nlp_agents', '~> 0.2.1', git: 'http://github.com/dsander/huginn.git', ref: '2342asdab'],
  13. ['huginn_nlp_agents', '~> 0.2.1']
  14. ]],
  15. ['huginn_nlp_agents(~> 0.2.1, path: /tmp/test)', [
  16. ['huginn_nlp_agents', '~> 0.2.1', path: '/tmp/test']
  17. ]],
  18. ['huginn_nlp_agents', [
  19. ['huginn_nlp_agents']
  20. ]],
  21. ['huginn_nlp_agents, test(0.1), test2(github: test2/huginn_test)', [
  22. ['huginn_nlp_agents'],
  23. ['test', '0.1'],
  24. ['test2', github: 'test2/huginn_test']
  25. ]],
  26. ['huginn_nlp_agents(git: http://github.com/dsander/huginn.git, ref: 2342asdab)', [
  27. ['huginn_nlp_agents', git: 'http://github.com/dsander/huginn.git', ref: '2342asdab']
  28. ]],
  29. ]
  30. it 'parses valid gem strings correctly' do
  31. VALID_STRINGS.each do |string, outcomes|
  32. GemfileHelper.parse_each_agent_gem(string) do |args|
  33. expect(args).to eq(outcomes.shift)
  34. end
  35. end
  36. end
  37. it 'does nothing when nil is passed' do
  38. expect { |b| GemfileHelper.parse_each_agent_gem(nil, &b) }.not_to yield_control
  39. end
  40. it 'does nothing when an empty string is passed' do
  41. expect { |b| GemfileHelper.parse_each_agent_gem('', &b) }.not_to yield_control
  42. end
  43. end
  44. end