berkshelf 2.0.18 → 3.0.0.beta1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. data/.ruby-version +1 -1
  2. data/.travis.yml +4 -1
  3. data/CHANGELOG.md +2 -26
  4. data/Gemfile +12 -2
  5. data/README.md +9 -1
  6. data/berkshelf.gemspec +9 -18
  7. data/bin/berks +3 -13
  8. data/features/apply_command.feature +11 -9
  9. data/features/berksfile.feature +8 -10
  10. data/features/config.feature +1 -2
  11. data/features/configure_command.feature +13 -14
  12. data/features/contingent_command.feature +13 -1
  13. data/features/cookbook_command.feature +2 -4
  14. data/features/groups_install.feature +10 -2
  15. data/features/help.feature +1 -1
  16. data/features/init_command.feature +5 -7
  17. data/features/install_command.feature +157 -228
  18. data/features/json_formatter.feature +27 -15
  19. data/features/licenses.feature +18 -12
  20. data/features/list_command.feature +6 -1
  21. data/features/lockfile.feature +116 -72
  22. data/features/outdated_command.feature +3 -47
  23. data/features/package_command.feature +10 -7
  24. data/features/shelf/show.feature +2 -2
  25. data/features/shelf/uninstall.feature +2 -2
  26. data/features/show_command.feature +10 -3
  27. data/features/step_definitions/chef/config_steps.rb +12 -0
  28. data/features/step_definitions/chef_server_steps.rb +16 -16
  29. data/features/step_definitions/cli_steps.rb +3 -79
  30. data/features/step_definitions/config_steps.rb +43 -0
  31. data/features/step_definitions/environment_steps.rb +7 -0
  32. data/features/step_definitions/filesystem_steps.rb +12 -57
  33. data/features/step_definitions/gem_steps.rb +1 -2
  34. data/features/step_definitions/json_steps.rb +3 -1
  35. data/features/step_definitions/lockfile_steps.rb +4 -0
  36. data/features/step_definitions/utility_steps.rb +0 -19
  37. data/features/support/aruba.rb +12 -0
  38. data/features/support/env.rb +52 -57
  39. data/features/update_command.feature +37 -23
  40. data/features/upload_command.feature +96 -160
  41. data/generator_files/Berksfile.erb +2 -1
  42. data/generator_files/Vagrantfile.erb +3 -0
  43. data/generator_files/default_test.rb.erb +1 -1
  44. data/generator_files/helpers.rb.erb +1 -1
  45. data/lib/berkshelf.rb +43 -24
  46. data/lib/berkshelf/api_client.rb +67 -0
  47. data/lib/berkshelf/api_client/remote_cookbook.rb +42 -0
  48. data/lib/berkshelf/berksfile.rb +232 -420
  49. data/lib/berkshelf/cached_cookbook.rb +22 -10
  50. data/lib/berkshelf/chef/config.rb +1 -0
  51. data/lib/berkshelf/cli.rb +66 -68
  52. data/lib/berkshelf/commands/shelf.rb +1 -1
  53. data/lib/berkshelf/community_rest.rb +10 -17
  54. data/lib/berkshelf/config.rb +23 -27
  55. data/lib/berkshelf/cookbook_generator.rb +3 -4
  56. data/lib/berkshelf/cookbook_store.rb +74 -17
  57. data/lib/berkshelf/core_ext/file.rb +2 -2
  58. data/lib/berkshelf/core_ext/pathname.rb +7 -5
  59. data/lib/berkshelf/{cookbook_source.rb → dependency.rb} +47 -67
  60. data/lib/berkshelf/downloader.rb +49 -106
  61. data/lib/berkshelf/errors.rb +64 -71
  62. data/lib/berkshelf/formatters.rb +11 -9
  63. data/lib/berkshelf/formatters/human_readable.rb +9 -9
  64. data/lib/berkshelf/formatters/json.rb +14 -4
  65. data/lib/berkshelf/init_generator.rb +3 -3
  66. data/lib/berkshelf/installer.rb +136 -0
  67. data/lib/berkshelf/location.rb +91 -131
  68. data/lib/berkshelf/locations/git_location.rb +9 -11
  69. data/lib/berkshelf/locations/github_location.rb +1 -1
  70. data/lib/berkshelf/locations/path_location.rb +10 -27
  71. data/lib/berkshelf/lockfile.rb +92 -70
  72. data/lib/berkshelf/logger.rb +4 -7
  73. data/lib/berkshelf/mixin/config.rb +21 -4
  74. data/lib/berkshelf/resolver.rb +60 -150
  75. data/lib/berkshelf/resolver/graph.rb +44 -0
  76. data/lib/berkshelf/source.rb +55 -0
  77. data/lib/berkshelf/source_uri.rb +38 -0
  78. data/lib/berkshelf/version.rb +1 -1
  79. data/spec/config/knife.rb +1 -1
  80. data/spec/fixtures/cassettes/Berkshelf_Resolver/_initialize/adds_the_dependencies_of_the_dependency_as_dependencies.yml +3694 -0
  81. data/spec/fixtures/cookbooks/example_cookbook/Berksfile.lock +1 -1
  82. data/spec/fixtures/lockfiles/default.lock +1 -1
  83. data/spec/spec_helper.rb +20 -121
  84. data/spec/support/chef_api.rb +3 -4
  85. data/spec/support/chef_server.rb +20 -11
  86. data/spec/support/git.rb +127 -0
  87. data/spec/support/kitchen.rb +12 -0
  88. data/spec/support/path_helpers.rb +69 -0
  89. data/spec/unit/berkshelf/api_client/remote_cookbook_spec.rb +23 -0
  90. data/spec/unit/berkshelf/api_client_spec.rb +57 -0
  91. data/spec/unit/berkshelf/berksfile_spec.rb +206 -324
  92. data/spec/unit/berkshelf/cached_cookbook_spec.rb +73 -38
  93. data/spec/unit/berkshelf/community_rest_spec.rb +30 -71
  94. data/spec/unit/berkshelf/config_spec.rb +3 -14
  95. data/spec/unit/berkshelf/cookbook_generator_spec.rb +1 -2
  96. data/spec/unit/berkshelf/cookbook_store_spec.rb +12 -7
  97. data/spec/unit/berkshelf/dependency_spec.rb +285 -0
  98. data/spec/unit/berkshelf/downloader_spec.rb +4 -183
  99. data/spec/unit/berkshelf/formatters/null_spec.rb +1 -1
  100. data/spec/unit/berkshelf/formatters_spec.rb +4 -2
  101. data/spec/unit/berkshelf/git_spec.rb +15 -15
  102. data/spec/unit/berkshelf/installer_spec.rb +39 -0
  103. data/spec/unit/berkshelf/location_spec.rb +87 -114
  104. data/spec/unit/berkshelf/locations/git_location_spec.rb +41 -53
  105. data/spec/unit/berkshelf/locations/path_location_spec.rb +13 -23
  106. data/spec/unit/berkshelf/lockfile_spec.rb +38 -40
  107. data/spec/unit/berkshelf/resolver/graph_spec.rb +44 -0
  108. data/spec/unit/berkshelf/resolver_spec.rb +34 -83
  109. data/spec/unit/berkshelf/source_spec.rb +23 -0
  110. data/spec/unit/berkshelf/source_uri_spec.rb +29 -0
  111. metadata +149 -188
  112. checksums.yaml +0 -7
  113. data/features/default_locations.feature +0 -127
  114. data/features/step_definitions/berksfile_steps.rb +0 -8
  115. data/features/step_definitions/configure_cli_steps.rb +0 -19
  116. data/features/vendor_install.feature +0 -19
  117. data/lib/berkshelf/core_ext/openuri.rb +0 -36
  118. data/lib/berkshelf/core_ext/rbzip2.rb +0 -8
  119. data/lib/berkshelf/locations/chef_api_location.rb +0 -228
  120. data/lib/berkshelf/locations/site_location.rb +0 -92
  121. data/lib/berkshelf/test.rb +0 -35
  122. data/spec/knife.rb.sample +0 -12
  123. data/spec/support/test_generators.rb +0 -27
  124. data/spec/unit/berkshelf/cli_spec.rb +0 -16
  125. data/spec/unit/berkshelf/cookbook_source_spec.rb +0 -358
  126. data/spec/unit/berkshelf/core_ext/pathname_spec.rb +0 -46
  127. data/spec/unit/berkshelf/locations/chef_api_location_spec.rb +0 -139
  128. data/spec/unit/berkshelf/locations/site_location_spec.rb +0 -19
@@ -1,6 +1,5 @@
1
1
  Given /^the gem "(.*)" is not installed$/ do |gem_name|
2
- # @see berkshelf/test.rb
3
- set_env 'MISSING_GEMS', [ENV['MISSING_GEMS'], gem_name].compact.join(',')
2
+ Gem::Specification.stub(:find_by_name).with(gem_name).and_raise(Gem::LoadError)
4
3
  end
5
4
 
6
5
  Then /^the output should contain a warning to suggest supporting the option "(.*?)" by installing "(.*?)"$/ do |option, gem_name|
@@ -5,7 +5,9 @@ class Hash
5
5
  if seed[key].is_a?(Hash)
6
6
  seed[key] = seed[key].sort_by_key(&block)
7
7
  elsif seed[key].is_a?(Array)
8
- seed[key] = seed[key].map { |i| i.sort_by_key(&block) }
8
+ seed[key] = seed[key].map do |i|
9
+ i.respond_to?(:sort_by_key) ? i.sort_by_key(&block) : i
10
+ end
9
11
  end
10
12
  seed
11
13
  end
@@ -0,0 +1,4 @@
1
+ Then(/^the output should warn about the old lockfile format$/) do
2
+ message = Berkshelf::Lockfile.class_eval('LockfileLegacy.send(:warning_message)')
3
+ expect(all_output).to include(message)
4
+ end
@@ -2,27 +2,8 @@ Given /^pending\s+"([^\"]+)"$/ do |msg|
2
2
  pending
3
3
  end
4
4
 
5
- Given(/^the BERKSHELF_EDITOR and VISUAL environment variables are not set$/) do
6
- set_env "BERKSHELF_EDITOR", nil
7
- set_env "VISUAL", nil
8
- end
9
-
10
- Given /^the environment variable (.+) is nil$/ do |variable|
11
- set_env variable, nil
12
- end
13
-
14
- Given /^the environment variable (.+) is "(.+)"$/ do |variable, value|
15
- set_env variable, value
16
- end
17
-
18
5
  Then /^the output should be the same as \`(.+)\`$/ do |command|
19
6
  run_simple(command)
20
7
  output = output_from(command)
21
8
  expect(all_output).to include(output)
22
9
  end
23
-
24
- # The built-in regex matcher does not support multi-line matching :(
25
- Then /^the output should match multiline:$/ do |expected|
26
- regex = Regexp.new(expected.strip, Regexp::MULTILINE)
27
- expect(regex).to match(all_output)
28
- end
@@ -0,0 +1,12 @@
1
+ module Aruba
2
+ # Force Aruba to behave like the SpawnProcess Aruba class.
3
+ class InProcess
4
+ def stdin
5
+ @stdin
6
+ end
7
+
8
+ def output
9
+ stdout + stderr
10
+ end
11
+ end
12
+ end
@@ -1,78 +1,73 @@
1
- require 'rubygems'
2
- require 'bundler'
3
1
  require 'spork'
4
2
 
5
3
  Spork.prefork do
6
- require 'rspec'
7
- require 'pp'
8
4
  require 'aruba/cucumber'
5
+ require 'aruba/in_process'
6
+ require 'aruba/spawn_process'
7
+ require 'cucumber/rspec/doubles'
8
+ require 'berkshelf/api/rspec'
9
+ require 'berkshelf/api/cucumber'
9
10
 
10
- APP_ROOT = File.expand_path('../../../', __FILE__)
11
+ Dir['spec/support/**/*.rb'].each { |f| require File.expand_path(f) }
11
12
 
12
- ENV['RUBY_ENV'] = 'test'
13
- ENV['BERKSHELF_PATH'] = File.join(APP_ROOT, 'tmp', 'berkshelf')
14
- ENV['BERKSHELF_CHEF_CONFIG'] = File.join(APP_ROOT, 'spec', 'config', 'knife.rb')
13
+ World(Berkshelf::RSpec::PathHelpers)
14
+ World(Berkshelf::RSpec::Kitchen)
15
15
 
16
- # Workaround for RSA Fingerprint prompt in Travis CI
17
- git_ssh_path = '/tmp/git_ssh.sh'
18
- unless File.exist? git_ssh_path
19
- git_ssh = File.new(git_ssh_path, 'w+')
20
- git_ssh.puts 'ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $1 $2'
21
- git_ssh.chmod 0775
22
- git_ssh.flush
23
- git_ssh.close
24
- end
25
-
26
- ENV['GIT_SSH'] = git_ssh_path
27
-
28
- Dir[File.join(APP_ROOT, 'spec/support/**/*.rb')].each {|f| require f}
29
-
30
- World(Berkshelf::TestGenerators)
31
-
32
- Before do
33
- set_env 'RUBY_ENV', 'test'
34
- clean_cookbook_store
35
- generate_berks_config(File.join(ENV['BERKSHELF_PATH'], 'config.json'))
36
- @aruba_io_wait_seconds = 5
37
- @aruba_timeout_seconds = 30
38
- end
39
-
40
- Before('@slow_process') do
41
- @aruba_timeout_seconds = 60
42
- @aruba_io_wait_seconds = 30
43
- end
44
-
45
- # Chef Zero
46
- require 'chef_zero/server'
47
- @server = ChefZero::Server.new(port: 4000, generate_real_keys: false)
48
- @server.start_background
16
+ CHEF_SERVER_PORT = 26310
17
+ BERKS_API_PORT = 26210
49
18
 
50
19
  at_exit do
51
- @server.stop if @server && @server.running?
52
- end
53
-
54
- def cookbook_store
55
- Pathname.new(File.join(ENV['BERKSHELF_PATH'], 'cookbooks'))
20
+ Berkshelf::RSpec::ChefServer.stop
21
+ Berkshelf::API::RSpec::Server.stop
56
22
  end
57
23
 
58
- def clean_cookbook_store
59
- FileUtils.rm_rf(cookbook_store)
60
- FileUtils.mkdir_p(cookbook_store)
24
+ Before do
25
+ # Legacy ENV variables until we can move over to all InProcess
26
+ ENV['BERKSHELF_PATH'] = berkshelf_path.to_s
27
+ ENV['BERKSHELF_CONFIG'] = Berkshelf.config.path.to_s
28
+ ENV['BERKSHELF_CHEF_CONFIG'] = chef_config_path.to_s
29
+
30
+ Aruba::InProcess.main_class = Berkshelf::Cli::Runner
31
+ Aruba.process = Aruba::InProcess
32
+
33
+ stub_kitchen!
34
+ clean_tmp_path
35
+ Berkshelf.initialize_filesystem
36
+ Berkshelf::CookbookStore.instance.initialize_filesystem
37
+ reload_configs
38
+
39
+ endpoints = [
40
+ {
41
+ type: "chef_server",
42
+ options: {
43
+ url: "http://localhost:#{CHEF_SERVER_PORT}",
44
+ client_name: "reset",
45
+ client_key: fixtures_path.join("reset.pem")
46
+ }
47
+ }
48
+ ]
49
+
50
+ Berkshelf::RSpec::ChefServer.start(port: CHEF_SERVER_PORT)
51
+ Berkshelf::API::RSpec::Server.start(port: BERKS_API_PORT, endpoints: endpoints)
52
+
53
+ @aruba_io_wait_seconds = Cucumber::JRUBY ? 7 : 5
54
+ @aruba_timeout_seconds = Cucumber::JRUBY ? 35 : 15
61
55
  end
62
56
 
63
- def app_root_path
64
- Pathname.new(APP_ROOT)
65
- end
57
+ Before('@spawn') do
58
+ Aruba.process = Aruba::SpawnProcess
66
59
 
67
- def tmp_path
68
- app_root_path.join('spec/tmp')
60
+ set_env('BERKSHELF_PATH', berkshelf_path.to_s)
61
+ set_env('BERKSHELF_CONFIG', Berkshelf.config.path.to_s)
62
+ set_env('BERKSHELF_CHEF_CONFIG', chef_config_path.to_s)
69
63
  end
70
64
 
71
- def fixtures_path
72
- app_root_path.join('spec/fixtures')
65
+ Before('@slow_process') do
66
+ @aruba_io_wait_seconds = Cucumber::JRUBY ? 70 : 30
67
+ @aruba_timeout_seconds = Cucumber::JRUBY ? 140 : 60
73
68
  end
74
69
  end
75
70
 
76
71
  Spork.each_run do
77
- require 'berkshelf'
72
+ require 'berkshelf/cli'
78
73
  end
@@ -8,7 +8,8 @@ Feature: Updating a cookbook defined by a Berksfile
8
8
  | berkshelf-cookbook-fixture | 0.1.0 |
9
9
  And I write to "Berksfile" with:
10
10
  """
11
- site :opscode
11
+ source "http://localhost:26210"
12
+
12
13
  cookbook 'berkshelf-cookbook-fixture', '~> 0.1'
13
14
  """
14
15
  And I write to "Berksfile.lock" with:
@@ -16,13 +17,14 @@ Feature: Updating a cookbook defined by a Berksfile
16
17
  cookbook 'berkshelf-cookbook-fixture', :locked_version => '0.1.0'
17
18
  """
18
19
  When I successfully run `berks update`
19
- Then the output should contain "You are using the old lockfile format. Attempting to convert..."
20
+ Then the output should warn about the old lockfile format
20
21
  Then the file "Berksfile.lock" should contain JSON:
21
22
  """
22
23
  {
23
- "sources":{
24
+ "dependencies":{
24
25
  "berkshelf-cookbook-fixture":{
25
- "locked_version":"0.1.0"
26
+ "locked_version":"0.1.0",
27
+ "constraint":"~> 0.1"
26
28
  }
27
29
  }
28
30
  }
@@ -35,19 +37,22 @@ Feature: Updating a cookbook defined by a Berksfile
35
37
  | hostsfile | 1.0.1 |
36
38
  And I write to "Berksfile" with:
37
39
  """
38
- site :opscode
40
+ source "http://localhost:26210"
41
+
39
42
  cookbook 'berkshelf-cookbook-fixture', '~> 0.1'
40
43
  cookbook 'hostsfile', '~> 1.0.0'
41
44
  """
42
45
  And I write to "Berksfile.lock" with:
43
46
  """
44
47
  {
45
- "sources":{
48
+ "dependencies":{
46
49
  "berkshelf-cookbook-fixture":{
47
- "locked_version":"0.1.0"
50
+ "locked_version":"0.1.0",
51
+ "constraint":"~> 0.1"
48
52
  },
49
53
  "hostsfile":{
50
- "locked_version":"1.0.1"
54
+ "locked_version":"1.0.1",
55
+ "constraint":"= 1.0.1"
51
56
  }
52
57
  }
53
58
  }
@@ -56,12 +61,14 @@ Feature: Updating a cookbook defined by a Berksfile
56
61
  Then the file "Berksfile.lock" should contain JSON:
57
62
  """
58
63
  {
59
- "sources":{
64
+ "dependencies":{
60
65
  "berkshelf-cookbook-fixture":{
61
- "locked_version":"0.2.0"
66
+ "locked_version":"0.2.0",
67
+ "constraint":"~> 0.1"
62
68
  },
63
69
  "hostsfile":{
64
- "locked_version":"1.0.1"
70
+ "locked_version":"1.0.1",
71
+ "constraint":"~> 1.0.0"
65
72
  }
66
73
  }
67
74
  }
@@ -74,19 +81,22 @@ Feature: Updating a cookbook defined by a Berksfile
74
81
  | hostsfile | 1.0.1 |
75
82
  Given I write to "Berksfile" with:
76
83
  """
77
- site :opscode
84
+ source "http://localhost:26210"
85
+
78
86
  cookbook 'berkshelf-cookbook-fixture', '~> 0.1'
79
87
  cookbook 'hostsfile', '~> 1.0.0'
80
88
  """
81
89
  And I write to "Berksfile.lock" with:
82
90
  """
83
91
  {
84
- "sources":{
92
+ "dependencies":{
85
93
  "berkshelf-cookbook-fixture":{
86
- "locked_version":"0.1.0"
94
+ "locked_version":"0.1.0",
95
+ "constraint":"~> 0.1"
87
96
  },
88
97
  "hostsfile":{
89
- "locked_version":"1.0.0"
98
+ "locked_version":"1.0.0",
99
+ "constraint":"~> 1.0.0"
90
100
  }
91
101
  }
92
102
  }
@@ -95,12 +105,14 @@ Feature: Updating a cookbook defined by a Berksfile
95
105
  Then the file "Berksfile.lock" should contain JSON:
96
106
  """
97
107
  {
98
- "sources":{
108
+ "dependencies":{
99
109
  "berkshelf-cookbook-fixture":{
100
- "locked_version":"0.2.0"
110
+ "locked_version":"0.2.0",
111
+ "constraint":"~> 0.1"
101
112
  },
102
113
  "hostsfile":{
103
- "locked_version":"1.0.0"
114
+ "locked_version":"1.0.0",
115
+ "constraint":"~> 1.0.0"
104
116
  }
105
117
  }
106
118
  }
@@ -111,15 +123,17 @@ Feature: Updating a cookbook defined by a Berksfile
111
123
  | berkshelf-cookbook-fixture | 0.1.0 |
112
124
  Given I write to "Berksfile" with:
113
125
  """
114
- site :opscode
126
+ source "http://localhost:26210"
127
+
115
128
  cookbook 'berkshelf-cookbook-fixture', '~> 0.1'
116
129
  """
117
130
  Given I write to "Berksfile.lock" with:
118
131
  """
119
132
  {
120
- "sources":{
133
+ "dependencies":{
121
134
  "berkshelf-cookbook-fixture":{
122
- "locked_version":"0.1.0"
135
+ "locked_version":"0.1.0",
136
+ "constraint":"~> 0.1"
123
137
  }
124
138
  }
125
139
  }
@@ -127,6 +141,6 @@ Feature: Updating a cookbook defined by a Berksfile
127
141
  When I run `berks update non-existent-cookbook`
128
142
  Then the output should contain:
129
143
  """
130
- Could not find cookbooks 'non-existent-cookbook' in any of the sources. Is it in your Berksfile?
144
+ Could not find cookbook(s) 'non-existent-cookbook' in any of the configured dependencies. Is it in your Berksfile?
131
145
  """
132
- And the CLI should exit with the status code for error "CookbookNotFound"
146
+ And the exit status should be "CookbookNotFound"
@@ -1,139 +1,146 @@
1
1
  Feature: Uploading cookbooks to a Chef Server
2
2
  As a Berkshelf CLI user
3
- I need a way to upload cookbooks to a Chef server that I have installed into my Bookshelf
3
+ I need a way to upload cookbooks to a Chef Server that I have installed into my Bookshelf
4
4
  So they are available to Chef clients
5
5
 
6
- @chef_server @slow_process
7
- Scenario: With no arguments
6
+ Background:
7
+ Given the Berkshelf API server's cache is empty
8
+ And the Chef Server is empty
9
+ And the cookbook store is empty
10
+
11
+ Scenario: multiple cookbooks with no arguments
8
12
  Given the cookbook store has the cookbooks:
9
- | fake | 1.0.0 |
10
- | ekaf | 2.0.0 |
13
+ | ruby | 1.0.0 |
14
+ | elixir | 2.0.0 |
11
15
  And I write to "Berksfile" with:
12
16
  """
13
- cookbook 'fake', '1.0.0'
14
- cookbook 'ekaf', '2.0.0'
17
+ source "http://localhost:26210"
18
+
19
+ cookbook 'ruby', '1.0.0'
20
+ cookbook 'elixir', '2.0.0'
15
21
  """
16
- And the Chef server does not have the cookbooks:
17
- | fake | 1.0.0 |
18
- | ekaf | 2.0.0 |
19
22
  When I successfully run `berks upload`
20
23
  Then the output should contain:
21
24
  """
22
- Uploading fake (1.0.0) to: 'http://localhost:4000/'
23
- Uploading ekaf (2.0.0) to: 'http://localhost:4000/'
25
+ Uploading ruby (1.0.0) to: 'http://localhost:26310/'
26
+ Uploading elixir (2.0.0) to: 'http://localhost:26310/'
24
27
  """
25
- And the Chef server should have the cookbooks:
26
- | fake | 1.0.0 |
27
- | ekaf | 2.0.0 |
28
- And the exit status should be 0
28
+ And the Chef Server should have the cookbooks:
29
+ | ruby | 1.0.0 |
30
+ | elixir | 2.0.0 |
29
31
 
30
- @chef_server
31
- Scenario: With a path location in the Berksfile
32
- Given a cookbook named "fake"
32
+ Scenario: a cookbook with a path location
33
+ Given a cookbook named "ruby"
33
34
  And I write to "Berksfile" with:
34
35
  """
35
- cookbook 'fake', path: './fake'
36
+ source "http://localhost:26210"
37
+
38
+ cookbook 'ruby', path: './ruby'
36
39
  """
37
- And the Chef server does not have the cookbooks:
38
- | fake | 0.0.0 |
39
40
  When I successfully run `berks upload`
40
41
  Then the output should contain:
41
42
  """
42
- Uploading fake (0.0.0) to: 'http://localhost:4000/'
43
+ Uploading ruby (0.0.0) to: 'http://localhost:26310/'
43
44
  """
44
- And the Chef server should have the cookbooks:
45
- | fake | 0.0.0 |
46
- And the exit status should be 0
45
+ And the Chef Server should have the cookbooks:
46
+ | ruby | 0.0.0 |
47
47
 
48
- @chef_server
49
- Scenario: With a git location in the Berksfile
48
+ Scenario: a cookbook with a git location
50
49
  Given the cookbook store has the cookbooks:
51
50
  | berkshelf-cookbook-fixture | 0.1.0 |
52
51
  And I write to "Berksfile" with:
53
52
  """
53
+ source "http://localhost:26210"
54
+
54
55
  cookbook 'berkshelf-cookbook-fixture', ref: 'v0.1.0'
55
56
  """
56
- And the Chef server does not have the cookbooks:
57
- | berkshelf-cookbook-fixture | 0.1.0 |
58
57
  When I successfully run `berks upload`
59
58
  Then the output should contain:
60
59
  """
61
- Uploading berkshelf-cookbook-fixture (0.1.0) to: 'http://localhost:4000/'
60
+ Uploading berkshelf-cookbook-fixture (0.1.0) to: 'http://localhost:26310/'
62
61
  """
63
- And the Chef server should have the cookbooks:
62
+ And the Chef Server should have the cookbooks:
64
63
  | berkshelf-cookbook-fixture | 0.1.0 |
65
- And the exit status should be 0
66
64
 
67
- @chef_server @slow_process
68
- Scenario: With a single cookbook
65
+ Scenario: specifying a single cookbook with dependencies
69
66
  Given the cookbook store has the cookbooks:
70
67
  | fake | 1.0.0 |
71
68
  | ekaf | 2.0.0 |
72
69
  And the cookbook store contains a cookbook "reset" "3.4.5" with dependencies:
73
- | fake | ~> 1.0.0 |
70
+ | fake | = 1.0.0 |
74
71
  And I write to "Berksfile" with:
75
72
  """
73
+ source "http://localhost:26210"
74
+
76
75
  cookbook 'fake', '1.0.0'
77
76
  cookbook 'ekaf', '2.0.0'
78
77
  cookbook 'reset', '3.4.5'
79
78
  """
80
- And the Chef server does not have the cookbooks:
81
- | fake | 1.0.0 |
82
- | ekaf | 2.0.0 |
83
- | reset | 3.4.5 |
84
79
  When I successfully run `berks upload reset`
85
80
  Then the output should contain:
86
81
  """
87
- Uploading reset (3.4.5) to: 'http://localhost:4000/'
88
- Uploading fake (1.0.0) to: 'http://localhost:4000/'
82
+ Uploading reset (3.4.5) to: 'http://localhost:26310/'
83
+ Uploading fake (1.0.0) to: 'http://localhost:26310/'
84
+ """
85
+ And the output should not contain:
86
+ """
87
+ Uploading ekaf (2.0.0) to: 'http://localhost:26310/'
89
88
  """
90
- And the Chef server should have the cookbooks:
89
+ And the Chef Server should have the cookbooks:
91
90
  | reset | 3.4.5 |
92
91
  | fake | 1.0.0 |
93
- And the Chef server should not have the cookbooks:
92
+ And the Chef Server should not have the cookbooks:
94
93
  | ekaf | 2.0.0 |
95
- And the exit status should be 0
96
94
 
97
- @chef_server @slow_process
98
- Scenario: With multiple cookbooks
95
+ Scenario: specifying a dependency not defined in the Berksfile
96
+ Given I write to "Berksfile" with:
97
+ """
98
+ source "http://localhost:26210"
99
+ """
100
+ When I run `berks upload reset`
101
+ Then the output should contain:
102
+ """
103
+ Failed to upload cookbook 'reset'. Not defined in Berksfile.
104
+ """
105
+ And the exit status should be "DependencyNotFound"
106
+
107
+ Scenario: specifying multiple cookbooks to upload
99
108
  Given the cookbook store has the cookbooks:
100
109
  | ntp | 1.0.0 |
101
110
  | vim | 1.0.0 |
102
111
  | apt | 1.0.0 |
103
112
  Given I write to "Berksfile" with:
104
113
  """
114
+ source "http://localhost:26210"
115
+
116
+ cookbook 'apt', '1.0.0'
105
117
  cookbook 'ntp', '1.0.0'
106
118
  cookbook 'vim', '1.0.0'
107
- cookbook 'apt', '1.0.0'
108
119
  """
109
- And the Chef server does not have the cookbooks:
110
- | ntp |
111
- | vim |
112
- | apt |
113
120
  When I successfully run `berks upload ntp vim`
114
121
  Then the output should contain:
115
122
  """
116
- Uploading ntp (1.0.0) to: 'http://localhost:4000/'
117
- Uploading vim (1.0.0) to: 'http://localhost:4000/'
123
+ Uploading ntp (1.0.0) to: 'http://localhost:26310/'
124
+ Uploading vim (1.0.0) to: 'http://localhost:26310/'
118
125
  """
119
126
  And the output should not contain:
120
127
  """
121
- Uploading apt (1.0.0) to: 'http://localhost:4000/'
128
+ Uploading apt (1.0.0) to: 'http://localhost:26310/'
122
129
  """
123
- And the Chef server should have the cookbooks:
130
+ And the Chef Server should have the cookbooks:
124
131
  | ntp |
125
132
  | vim |
126
- And the Chef server should not have the cookbooks:
133
+ And the Chef Server should not have the cookbooks:
127
134
  | apt |
128
- And the exit status should be 0
129
135
 
130
- @chef_server @slow_process
131
- Scenario: With the --only flag
136
+ Scenario: uploading a single groups of demands with the --only flag
132
137
  Given the cookbook store has the cookbooks:
133
138
  | core | 1.0.0 |
134
139
  | system | 1.0.0 |
135
140
  Given I write to "Berksfile" with:
136
141
  """
142
+ source "http://localhost:26210"
143
+
137
144
  group :group_a do
138
145
  cookbook 'core', '1.0.0'
139
146
  end
@@ -142,31 +149,28 @@ Feature: Uploading cookbooks to a Chef Server
142
149
  cookbook 'system', '1.0.0'
143
150
  end
144
151
  """
145
- And the Chef server does not have the cookbooks:
146
- | core | 1.0.0 |
147
- | system | 1.0.0 |
148
152
  When I successfully run `berks upload --only group_a`
149
153
  Then the output should contain:
150
154
  """
151
- Uploading core (1.0.0) to: 'http://localhost:4000/'
155
+ Uploading core (1.0.0) to: 'http://localhost:26310/'
152
156
  """
153
157
  And the output should not contain:
154
158
  """
155
- Uploading system (1.0.0) to: 'http://localhost:4000/'
159
+ Uploading system (1.0.0) to: 'http://localhost:26310/'
156
160
  """
157
- And the Chef server should have the cookbooks:
161
+ And the Chef Server should have the cookbooks:
158
162
  | core | 1.0.0 |
159
- And the Chef server should not have the cookbooks:
163
+ And the Chef Server should not have the cookbooks:
160
164
  | system | 1.0.0 |
161
- And the exit status should be 0
162
165
 
163
- @chef_server @slow_process
164
- Scenario: With the --only flag specifying multiple groups
166
+ Scenario: uploading multiple groups of demands with the --only flag
165
167
  Given the cookbook store has the cookbooks:
166
168
  | core | 1.0.0 |
167
169
  | system | 1.0.0 |
168
170
  Given I write to "Berksfile" with:
169
171
  """
172
+ source "http://localhost:26210"
173
+
170
174
  group :group_a do
171
175
  cookbook 'core', '1.0.0'
172
176
  end
@@ -175,27 +179,24 @@ Feature: Uploading cookbooks to a Chef Server
175
179
  cookbook 'system', '1.0.0'
176
180
  end
177
181
  """
178
- And the Chef server does not have the cookbooks:
179
- | core | 1.0.0 |
180
- | system | 1.0.0 |
181
182
  When I successfully run `berks upload --only group_a group_b`
182
183
  Then the output should contain:
183
184
  """
184
- Uploading core (1.0.0) to: 'http://localhost:4000/'
185
- Uploading system (1.0.0) to: 'http://localhost:4000/'
185
+ Uploading core (1.0.0) to: 'http://localhost:26310/'
186
+ Uploading system (1.0.0) to: 'http://localhost:26310/'
186
187
  """
187
- And the Chef server should have the cookbooks:
188
+ And the Chef Server should have the cookbooks:
188
189
  | core | 1.0.0 |
189
190
  | system | 1.0.0 |
190
- And the exit status should be 0
191
191
 
192
- @chef_server @slow_process
193
- Scenario: With the --except flag
192
+ Scenario: skipping a single group to upload with the --except flag
194
193
  Given the cookbook store has the cookbooks:
195
194
  | core | 1.0.0 |
196
195
  | system | 1.0.0 |
197
196
  Given I write to "Berksfile" with:
198
197
  """
198
+ source "http://localhost:26210"
199
+
199
200
  group :group_a do
200
201
  cookbook 'core', '1.0.0'
201
202
  end
@@ -204,31 +205,28 @@ Feature: Uploading cookbooks to a Chef Server
204
205
  cookbook 'system', '1.0.0'
205
206
  end
206
207
  """
207
- And the Chef server does not have the cookbooks:
208
- | core | 1.0.0 |
209
- | system | 1.0.0 |
210
208
  When I successfully run `berks upload --except group_b`
211
209
  Then the output should contain:
212
210
  """
213
- Uploading core (1.0.0) to: 'http://localhost:4000/'
211
+ Uploading core (1.0.0) to: 'http://localhost:26310/'
214
212
  """
215
213
  And the output should not contain:
216
214
  """
217
- Uploading system (1.0.0) to: 'http://localhost:4000/'
215
+ Uploading system (1.0.0) to: 'http://localhost:26310/'
218
216
  """
219
- And the Chef server should have the cookbooks:
217
+ And the Chef Server should have the cookbooks:
220
218
  | core | 1.0.0 |
221
- And the Chef server should not have the cookbooks:
219
+ And the Chef Server should not have the cookbooks:
222
220
  | system | 1.0.0 |
223
- And the exit status should be 0
224
221
 
225
- @chef_server @slow_process
226
- Scenario: With the --except flag specifying multiple groups
222
+ Scenario: skipping multiple groups with the --except flag
227
223
  Given the cookbook store has the cookbooks:
228
224
  | core | 1.0.0 |
229
225
  | system | 1.0.0 |
230
226
  Given I write to "Berksfile" with:
231
227
  """
228
+ source "http://localhost:26210"
229
+
232
230
  group :group_a do
233
231
  cookbook 'core', '1.0.0'
234
232
  end
@@ -237,24 +235,22 @@ Feature: Uploading cookbooks to a Chef Server
237
235
  cookbook 'system', '1.0.0'
238
236
  end
239
237
  """
240
- And the Chef server does not have the cookbooks:
241
- | core | 1.0.0 |
242
- | system | 1.0.0 |
243
238
  When I successfully run `berks upload --except group_a group_b`
244
239
  Then the output should not contain:
245
240
  """
246
- Uploading core (1.0.0) to: 'http://localhost:4000/'
247
- Uploading system (1.0.0) to: 'http://localhost:4000/'
241
+ Uploading core (1.0.0) to: 'http://localhost:26310/'
242
+ Uploading system (1.0.0) to: 'http://localhost:26310/'
248
243
  """
249
- And the Chef server should not have the cookbooks:
244
+ And the Chef Server should not have the cookbooks:
250
245
  | core | 1.0.0 |
251
246
  | system | 1.0.0 |
252
- And the exit status should be 0
253
247
 
254
- Scenario: With an invalid cookbook
248
+ Scenario: attempting to upload an invalid cookbook
255
249
  Given a cookbook named "cookbook with spaces"
256
250
  And I write to "Berksfile" with:
257
251
  """
252
+ source "http://localhost:26210"
253
+
258
254
  cookbook 'cookbook with spaces', path: './cookbook with spaces'
259
255
  """
260
256
  When I run `berks upload`
@@ -262,39 +258,8 @@ Feature: Uploading cookbooks to a Chef Server
262
258
  """
263
259
  The cookbook 'cookbook with spaces' has invalid filenames:
264
260
  """
265
- And the CLI should exit with the status code for error "InvalidCookbookFiles"
261
+ And the exit status should be "InvalidCookbookFiles"
266
262
 
267
- @chef_server @slow_process
268
- Scenario: With the --skip-dependencies flag
269
- Given the cookbook store has the cookbooks:
270
- | fake | 1.0.0 |
271
- | ekaf | 2.0.0 |
272
- And the cookbook store contains a cookbook "reset" "3.4.5" with dependencies:
273
- | fake | ~> 1.0.0 |
274
- And I write to "Berksfile" with:
275
- """
276
- cookbook 'fake', '1.0.0'
277
- cookbook 'ekaf', '2.0.0'
278
- cookbook 'reset', '3.4.5'
279
- """
280
- And the Chef server does not have the cookbooks:
281
- | fake | 1.0.0 |
282
- | ekaf | 2.0.0 |
283
- | reset | 3.4.5 |
284
- When I successfully run `berks upload reset -D`
285
- Then the output should contain:
286
- """
287
- Uploading reset (3.4.5) to: 'http://localhost:4000/'
288
- Uploading fake (1.0.0) to: 'http://localhost:4000/'
289
- """
290
- And the Chef server should have the cookbooks:
291
- | reset | 3.4.5 |
292
- | fake | 1.0.0 |
293
- And the Chef server should not have the cookbooks:
294
- | ekaf | 2.0.0 |
295
- And the exit status should be 0
296
-
297
- @focus
298
263
  Scenario: With unicode characters
299
264
  Given a cookbook named "fake"
300
265
  And the cookbook "fake" has the file "README.md" with:
@@ -306,7 +271,8 @@ Feature: Uploading cookbooks to a Chef Server
306
271
  """
307
272
  And the cookbook "fake" has the file "Berksfile" with:
308
273
  """
309
- site :opscode
274
+ source "http://localhost:26210"
275
+
310
276
  metadata
311
277
  """
312
278
  When I cd to "fake"
@@ -315,33 +281,3 @@ Feature: Uploading cookbooks to a Chef Server
315
281
  """
316
282
  Uploading fake (0.0.0)
317
283
  """
318
- And the exit status should be 0
319
- Scenario: When the syntax check is skipped
320
- Given a cookbook named "fake"
321
- And the cookbook "fake" has the file "recipes/default.rb" with:
322
- """
323
- Totally not valid Ruby syntax
324
- """
325
- And the cookbook "fake" has the file "templates/default/file.erb" with:
326
- """
327
- <% for %>
328
- """
329
- And the cookbook "fake" has the file "recipes/template.rb" with:
330
- """
331
- template "/tmp/wadus" do
332
- source "file.erb"
333
- end
334
- """
335
- And the cookbook "fake" has the file "Berksfile" with:
336
- """
337
- site :opscode
338
-
339
- metadata
340
- """
341
- And I cd to "fake"
342
- When I successfully run `berks upload --skip-syntax-check`
343
- Then the output should contain:
344
- """
345
- Using fake (0.0.0) from metadata
346
- Uploading fake (0.0.0) to: 'http://localhost:4000/'
347
- """