berkshelf 0.1.1

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 (93) hide show
  1. data/.gitignore +20 -0
  2. data/.rbenv-version +1 -0
  3. data/Gemfile +3 -0
  4. data/Guardfile +23 -0
  5. data/LICENSE +22 -0
  6. data/README.rdoc +102 -0
  7. data/Thorfile +47 -0
  8. data/berkshelf.gemspec +39 -0
  9. data/features/config.sample.yml +3 -0
  10. data/features/init_command.feature +40 -0
  11. data/features/install.feature +55 -0
  12. data/features/lockfile.feature +22 -0
  13. data/features/step_definitions/chef_server_steps.rb +13 -0
  14. data/features/step_definitions/cli_steps.rb +56 -0
  15. data/features/step_definitions/filesystem_steps.rb +79 -0
  16. data/features/support/env.rb +55 -0
  17. data/features/update.feature +23 -0
  18. data/features/upload_command.feature +43 -0
  19. data/features/without.feature +25 -0
  20. data/lib/berkshelf.rb +90 -0
  21. data/lib/berkshelf/berksfile.rb +170 -0
  22. data/lib/berkshelf/cached_cookbook.rb +253 -0
  23. data/lib/berkshelf/cookbook_source.rb +139 -0
  24. data/lib/berkshelf/cookbook_source/git_location.rb +54 -0
  25. data/lib/berkshelf/cookbook_source/path_location.rb +27 -0
  26. data/lib/berkshelf/cookbook_source/site_location.rb +206 -0
  27. data/lib/berkshelf/cookbook_store.rb +77 -0
  28. data/lib/berkshelf/core_ext.rb +3 -0
  29. data/lib/berkshelf/core_ext/file.rb +14 -0
  30. data/lib/berkshelf/core_ext/kernel.rb +33 -0
  31. data/lib/berkshelf/core_ext/pathname.rb +24 -0
  32. data/lib/berkshelf/downloader.rb +92 -0
  33. data/lib/berkshelf/dsl.rb +39 -0
  34. data/lib/berkshelf/errors.rb +20 -0
  35. data/lib/berkshelf/generator_files/Berksfile.erb +3 -0
  36. data/lib/berkshelf/generator_files/chefignore +44 -0
  37. data/lib/berkshelf/git.rb +70 -0
  38. data/lib/berkshelf/init_generator.rb +38 -0
  39. data/lib/berkshelf/lockfile.rb +42 -0
  40. data/lib/berkshelf/resolver.rb +176 -0
  41. data/lib/berkshelf/tx_result.rb +12 -0
  42. data/lib/berkshelf/tx_result_set.rb +37 -0
  43. data/lib/berkshelf/uploader.rb +153 -0
  44. data/lib/berkshelf/version.rb +3 -0
  45. data/lib/chef/knife/berks_init.rb +29 -0
  46. data/lib/chef/knife/berks_install.rb +27 -0
  47. data/lib/chef/knife/berks_update.rb +23 -0
  48. data/lib/chef/knife/berks_upload.rb +39 -0
  49. data/spec/fixtures/Berksfile +3 -0
  50. data/spec/fixtures/cookbooks/example_cookbook-0.5.0/README.md +12 -0
  51. data/spec/fixtures/cookbooks/example_cookbook-0.5.0/metadata.rb +6 -0
  52. data/spec/fixtures/cookbooks/example_cookbook-0.5.0/recipes/default.rb +8 -0
  53. data/spec/fixtures/cookbooks/example_cookbook/README.md +12 -0
  54. data/spec/fixtures/cookbooks/example_cookbook/metadata.rb +6 -0
  55. data/spec/fixtures/cookbooks/example_cookbook/recipes/default.rb +8 -0
  56. data/spec/fixtures/cookbooks/invalid_ruby_files-1.0.0/recipes/default.rb +1 -0
  57. data/spec/fixtures/cookbooks/invalid_template_files-1.0.0/templates/default/broken.erb +1 -0
  58. data/spec/fixtures/cookbooks/nginx-0.100.5/README.md +77 -0
  59. data/spec/fixtures/cookbooks/nginx-0.100.5/attributes/default.rb +65 -0
  60. data/spec/fixtures/cookbooks/nginx-0.100.5/definitions/nginx_site.rb +35 -0
  61. data/spec/fixtures/cookbooks/nginx-0.100.5/files/default/mime.types +73 -0
  62. data/spec/fixtures/cookbooks/nginx-0.100.5/files/ubuntu/mime.types +73 -0
  63. data/spec/fixtures/cookbooks/nginx-0.100.5/libraries/nginxlib.rb +1 -0
  64. data/spec/fixtures/cookbooks/nginx-0.100.5/metadata.rb +91 -0
  65. data/spec/fixtures/cookbooks/nginx-0.100.5/providers/defprovider.rb +1 -0
  66. data/spec/fixtures/cookbooks/nginx-0.100.5/recipes/default.rb +59 -0
  67. data/spec/fixtures/cookbooks/nginx-0.100.5/resources/defresource.rb +1 -0
  68. data/spec/fixtures/cookbooks/nginx-0.100.5/templates/default/nginx.pill.erb +15 -0
  69. data/spec/fixtures/cookbooks/nginx-0.100.5/templates/default/plugins/nginx.rb.erb +66 -0
  70. data/spec/fixtures/lockfile_spec/with_lock/Berksfile +1 -0
  71. data/spec/fixtures/lockfile_spec/without_lock/Berksfile.lock +5 -0
  72. data/spec/spec_helper.rb +92 -0
  73. data/spec/support/chef_api.rb +27 -0
  74. data/spec/support/matchers/file_system_matchers.rb +115 -0
  75. data/spec/support/matchers/filepath_matchers.rb +19 -0
  76. data/spec/unit/berkshelf/cached_cookbook_spec.rb +420 -0
  77. data/spec/unit/berkshelf/cookbook_source/git_location_spec.rb +59 -0
  78. data/spec/unit/berkshelf/cookbook_source/path_location_spec.rb +34 -0
  79. data/spec/unit/berkshelf/cookbook_source/site_location_spec.rb +166 -0
  80. data/spec/unit/berkshelf/cookbook_source_spec.rb +194 -0
  81. data/spec/unit/berkshelf/cookbook_store_spec.rb +71 -0
  82. data/spec/unit/berkshelf/cookbookfile_spec.rb +160 -0
  83. data/spec/unit/berkshelf/downloader_spec.rb +82 -0
  84. data/spec/unit/berkshelf/dsl_spec.rb +42 -0
  85. data/spec/unit/berkshelf/git_spec.rb +63 -0
  86. data/spec/unit/berkshelf/init_generator_spec.rb +52 -0
  87. data/spec/unit/berkshelf/lockfile_spec.rb +25 -0
  88. data/spec/unit/berkshelf/resolver_spec.rb +126 -0
  89. data/spec/unit/berkshelf/tx_result_set_spec.rb +77 -0
  90. data/spec/unit/berkshelf/tx_result_spec.rb +21 -0
  91. data/spec/unit/berkshelf/uploader_spec.rb +71 -0
  92. data/spec/unit/berkshelf_spec.rb +29 -0
  93. metadata +411 -0
@@ -0,0 +1,20 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ /Gemfile.lock
7
+ _yardoc
8
+ /coverage
9
+ /doc/
10
+ /pkg
11
+ /spec/reports
12
+ /Berksfile*
13
+ tmp
14
+ *~
15
+ *.tar*
16
+ \#*
17
+ .DS_Store
18
+ /spec/fixtures/vcr_cassettes/*
19
+ /features/config.yml
20
+ *.sw[op]
@@ -0,0 +1 @@
1
+ 1.9.3-p125
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
@@ -0,0 +1,23 @@
1
+ guard 'spork' do
2
+ watch('Gemfile')
3
+ watch('spec/spec_helper.rb') { :rspec }
4
+ watch(%r{^features/support/}) { :cucumber }
5
+ end
6
+
7
+ guard 'yard', :stdout => '/dev/null', :stderr => '/dev/null' do
8
+ watch(%r{app/.+\.rb})
9
+ watch(%r{lib/.+\.rb})
10
+ watch(%r{ext/.+\.c})
11
+ end
12
+
13
+ guard 'rspec', :version => 2, :cli => "--color --drb --format Fuubar", :all_on_start => false, :all_after_pass => false, :notification => false do
14
+ watch(%r{^spec/unit/.+_spec\.rb$})
15
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/unit/#{m[1]}_spec.rb" }
16
+ watch('spec/spec_helper.rb') { "spec" }
17
+ end
18
+
19
+ guard 'cucumber', :cli => "--drb --format pretty --tags ~@wip", :all_on_start => false, :all_after_pass => false, :notification => false do
20
+ watch(%r{^features/.+\.feature$})
21
+ watch(%r{^features/support/.+$}) { 'features' }
22
+ watch(%r{^features/step_definitions/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'features' }
23
+ end
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Riot Games
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,102 @@
1
+ = Berkshelf
2
+
3
+ Manages a Cookbook's, or an Application's, Cookbook dependencies
4
+
5
+ == Getting Started
6
+
7
+ === Install
8
+
9
+ $ gem install berkshelf
10
+
11
+ === Use
12
+
13
+ ==== Berksfile
14
+
15
+ Dependencies are managed via a `Berksfile` in the directory where you want the cookbooks to be installed. The Berksfile, like Bundler's Gemfile, contains which cookbooks are needed and, optionally, where to find them:
16
+
17
+ cookbook 'memcached'
18
+ cookbook 'nginx'
19
+ cookbook 'my_app', path: '/path/to/cookbook'
20
+ cookbook 'mysql', git: 'git://github.com/opscode-cookbooks/mysql.git'
21
+
22
+ ==== CLI
23
+
24
+ The CLI consists of 2 commands: install, update
25
+
26
+ $ knife berks (install|update) [(--without|-W) group_to_exclude]
27
+
28
+ [install] Installs the from the Berksfile.lock, or Berksfile if the the lockfile does not exist.
29
+
30
+ [update] Skips the lockfile and installs fresh
31
+
32
+ [init] Prepares a local path to have it's Cookbook dependencies managed by Berkshelf. If the target path is a Cookbook itself, additional Berkshelf support files will be generated to get you started.
33
+
34
+ == The Berksfile
35
+
36
+ Cookbooks are defined as dependencies by declaring them in the `Berksfile`
37
+
38
+ cookbook 'nginx'
39
+
40
+ Cookbooks without additional options are assumed to come from the Opscode Community site at the latest available version: http://community.opscode.com/cookbooks
41
+
42
+ Options available include:
43
+
44
+ version constraint
45
+
46
+ cookbook "nginx", "= 0.101.2" # precisely 0.101.2
47
+ cookbook "mysql", "< 1.2.4" # less than and not including 1.2.4
48
+ cookbook "openssl", "~> 1.0.0" # greater than 1.0.0, and up to but not including 1.1.0
49
+
50
+ git
51
+
52
+ # ref can be a branch name, tag, or commit hash. If ref is not provided, HEAD is used.
53
+ cookbook "mysql", git: "https://github.com/opscode-cookbooks/mysql.git", ref: "<any git ref>"
54
+
55
+ path
56
+
57
+ # knife berks will look in /path/to/location/of/my_application for the cookbook
58
+ cookbook "my_application", path: "/path/to/location/of"
59
+
60
+ === Groups
61
+
62
+ Groups can be defined via blocks or inline as an option:
63
+
64
+ group :solo do
65
+ cookbook 'base'
66
+ end
67
+
68
+ cookbook 'base', :group => 'solo'
69
+
70
+ When using install or update, groups can be excluded with the --without GROUP_NAME or -W GROUP_NAME flags.
71
+
72
+ = Contributing
73
+
74
+ == Running tests
75
+
76
+ === Install prerequisites
77
+
78
+ Install the latest version of {Bundler}[http://gembundler.com]
79
+
80
+ $ gem install bundler
81
+
82
+ Clone the project
83
+
84
+ $ git clone git://github.com/RiotGames/berkshelf.git
85
+
86
+ and run:
87
+
88
+ $ cd berkshelf
89
+ $ bundle install
90
+
91
+ Bundler will install all gems and their dependencies required for testing and developing.
92
+
93
+ === Running unit (RSpec) and acceptance (Cucumber) tests
94
+
95
+ $ bundle exec guard start
96
+
97
+ = Authors and Contributors
98
+
99
+ * Josiah Kiehl (<josiah@skirmisher.net>)
100
+ * Jamie Winsor (<jamie@vialstudios.com>)
101
+ * Erik Hollensbe (<erik@hollensbe.org>)
102
+ * Michael Ivey (<ivey@gweezlebur.com>)
@@ -0,0 +1,47 @@
1
+ # encoding: utf-8
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+
4
+ require 'bundler'
5
+ require 'bundler/setup'
6
+
7
+ require 'berkshelf'
8
+ require 'thor/rake_compat'
9
+
10
+ class Berks < Thor
11
+ include Thor::RakeCompat
12
+ Bundler::GemHelper.install_tasks
13
+
14
+ desc "build", "Build berkshelf-#{Berkshelf::VERSION}.gem into the pkg directory"
15
+ def build
16
+ Rake::Task["build"].execute
17
+ end
18
+
19
+ desc "install", "Build and install berkshelf-#{Berkshelf::VERSION}.gem into system gems"
20
+ def install
21
+ Rake::Task["install"].execute
22
+ end
23
+
24
+ desc "release", "Create tag v#{Berkshelf::VERSION} and build and push berkshelf-#{Berkshelf::VERSION}.gem to Rubygems"
25
+ def release
26
+ Rake::Task["release"].execute
27
+ end
28
+
29
+ desc "spec", "Run RSpec code examples"
30
+ def spec
31
+ exec "rspec --color --format=documentation spec"
32
+ end
33
+
34
+ desc "cucumber", "Run Cucumber features"
35
+ def cucumber
36
+ exec "cucumber --color --format=progress"
37
+ end
38
+
39
+ class VCR < Thor
40
+ namespace :vcr
41
+
42
+ desc "clean", "clean VCR cassettes"
43
+ def clean
44
+ FileUtils.rm_rf("spec/fixtures/vcr_cassettes/*")
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,39 @@
1
+ # -*- encoding: utf-8; mode: ruby -*-
2
+
3
+ require File.expand_path('../lib/berkshelf/version', __FILE__)
4
+
5
+ Gem::Specification.new do |s|
6
+ s.authors = ["Josiah Kiehl", "Jamie Winsor", "Michael Ivey", "Erik Hollensbe"]
7
+ s.email = ["josiah@skirmisher.net", "jamie@vialstudios.com", "ivey@gweezlebur.com", "erik@hollensbe.org"]
8
+ s.description = %q{Manages a Cookbook's, or an Application's, Cookbook dependencies}
9
+ s.summary = s.description
10
+ s.homepage = "https://github.com/RiotGames/berkshelf"
11
+ s.files = `git ls-files`.split($\)
12
+ s.executables = s.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
14
+ s.name = "berkshelf"
15
+ s.require_paths = ["lib"]
16
+ s.version = Berkshelf::VERSION
17
+ s.required_ruby_version = ">= 1.9.1"
18
+
19
+ s.add_runtime_dependency 'dep_selector'
20
+ s.add_runtime_dependency 'chef', '~> 0.10.0'
21
+ s.add_runtime_dependency 'minitar'
22
+ s.add_runtime_dependency 'thor', '~> 0.15.2'
23
+
24
+ s.add_development_dependency 'cucumber'
25
+ s.add_development_dependency 'vcr'
26
+ s.add_development_dependency 'webmock'
27
+ s.add_development_dependency 'aruba'
28
+ s.add_development_dependency 'rspec'
29
+ s.add_development_dependency 'json_spec'
30
+ s.add_development_dependency 'simplecov'
31
+ s.add_development_dependency 'fuubar'
32
+ s.add_development_dependency 'spork'
33
+ s.add_development_dependency 'yard'
34
+ s.add_development_dependency 'guard'
35
+ s.add_development_dependency 'guard-rspec'
36
+ s.add_development_dependency 'guard-cucumber'
37
+ s.add_development_dependency 'guard-spork'
38
+ s.add_development_dependency 'guard-yard'
39
+ end
@@ -0,0 +1,3 @@
1
+ node_name: 'reset'
2
+ client_key: '/Users/reset/.chef/reset.pem'
3
+ chef_server_url: 'https://api.opscode.com/organizations/vialstudios'
@@ -0,0 +1,40 @@
1
+ Feature: initialize command
2
+ As a Cookbook author
3
+ I want a way to quickly prepare a Cookbook on my local disk with Berkshelf files
4
+ So that I can resolve my Cookbook's dependencies with Berkshelf
5
+
6
+ Scenario: initializing a path containing a cookbook
7
+ Given a cookbook named "sparkle_motion"
8
+ When I run the init command with the cookbook "sparkle_motion" as the target
9
+ Then the cookbook "sparkle_motion" should have the following files:
10
+ | Berksfile |
11
+ | .chefignore |
12
+ And the file "Berksfile" in the cookbook "sparkle_motion" should contain:
13
+ """
14
+ metadata
15
+ """
16
+ And the output should contain "Successfully initialized"
17
+ And the exit status should be 0
18
+
19
+ Scenario: initializing a path that does not contain a cookbook
20
+ Given a directory named "not_a_cookbook"
21
+ When I run the init command with the directory "not_a_cookbook" as the target
22
+ Then the directory "not_a_cookbook" should have the following files:
23
+ | Berksfile |
24
+ And the directory "not_a_cookbook" should not have the following files:
25
+ | .chefignore |
26
+ And the file "Berksfile" in the directory "not_a_cookbook" should not contain:
27
+ """
28
+ metadata
29
+ """
30
+ And the output should contain "Successfully initialized"
31
+ And the exit status should be 0
32
+
33
+ Scenario: initializing with no value given for target
34
+ When I run the init command with no value for the target
35
+ Then the output should contain "Successfully initialized"
36
+ And the current directory should have the following files:
37
+ | Berksfile |
38
+ And the current directory should not have the following files:
39
+ | .chefignore |
40
+ And the exit status should be 0
@@ -0,0 +1,55 @@
1
+ Feature: install cookbooks from a Berksfile
2
+ As a user with a Berksfile
3
+ I want to be able to run knife berkshelf install to install my cookbooks
4
+ So that I don't have to download my cookbooks and their dependencies manually
5
+
6
+ Scenario: install cookbooks
7
+ Given I write to "Berksfile" with:
8
+ """
9
+ cookbook "mysql", "1.2.4"
10
+ """
11
+ When I run the install command
12
+ Then the cookbook store should have the cookbooks:
13
+ | mysql | 1.2.4 |
14
+ | openssl | 1.0.0 |
15
+ And the output should contain:
16
+ """
17
+ Installing mysql (1.2.4) from site: 'http://cookbooks.opscode.com/api/v1/cookbooks'
18
+ Installing openssl (1.0.0) from site: 'http://cookbooks.opscode.com/api/v1/cookbooks'
19
+ """
20
+
21
+ Scenario: running install when current project is a cookbook and the 'metadata' is specified
22
+ Given a cookbook named "sparkle_motion"
23
+ And the cookbook "sparkle_motion" has the file "Berksfile" with:
24
+ """
25
+ metadata
26
+ """
27
+ When I cd to "sparkle_motion"
28
+ And I run the install command
29
+ Then the output should contain:
30
+ """
31
+ Using sparkle_motion (0.0.0) at path:
32
+ """
33
+ And the exit status should be 0
34
+
35
+ Scenario: running install with no Berksfile or Berksfile.lock
36
+ Given I do not have a Berksfile
37
+ And I do not have a Berksfile.lock
38
+ When I run the install command
39
+ Then the output should contain:
40
+ """
41
+ No Berksfile or Berksfile.lock found at:
42
+ """
43
+ And the CLI should exit with the status code for error "BerksfileNotFound"
44
+
45
+ Scenario: running install when the Cookbook is not found on the remote site
46
+ Given I write to "Berksfile" with:
47
+ """
48
+ cookbook "doesntexist"
49
+ """
50
+ And I run the install command
51
+ Then the output should contain:
52
+ """
53
+ Cookbook 'doesntexist' not found at site: 'http://cookbooks.opscode.com/api/v1/cookbooks'
54
+ """
55
+ And the CLI should exit with the status code for error "DownloadFailure"
@@ -0,0 +1,22 @@
1
+ Feature: Berksfile.lock
2
+ As a user
3
+ I want my versions to be locked even when I don't specify versions in my Berksfile
4
+ So when I share my repository, all other developers get the same versions that I did when I installed.
5
+
6
+ @slow_process
7
+ Scenario: Writing the Berksfile.lock
8
+ Given I write to "Berksfile" with:
9
+ """
10
+ cookbook 'ntp'
11
+ cookbook 'mysql', git: 'https://github.com/opscode-cookbooks/mysql.git', :ref => '190c0c2267785b7b9b303369b8a64ed04364d5f9'
12
+ """
13
+ When I run the install command
14
+ Then a file named "Berksfile.lock" should exist in the current directory
15
+ And the file "Berksfile.lock" should contain in the current directory:
16
+ """
17
+ cookbook 'ntp', :locked_version => '1.1.8'
18
+ cookbook 'mysql', :git => 'https://github.com/opscode-cookbooks/mysql.git', :ref => '190c0c2267785b7b9b303369b8a64ed04364d5f9'
19
+ cookbook 'openssl', :locked_version => '1.0.0'
20
+ cookbook 'chef_handler', :locked_version => '1.0.6'
21
+ cookbook 'windows', :locked_version => '1.3.0'
22
+ """
@@ -0,0 +1,13 @@
1
+ World(Berkshelf::RSpec::ChefAPI)
2
+
3
+ Given /^the Chef server does not have the cookbooks:$/ do |cookbooks|
4
+ cookbooks.raw.each do |name, version|
5
+ purge_cookbook(name, version)
6
+ end
7
+ end
8
+
9
+ Then /^the Chef server should have the cookbooks:$/ do |cookbooks|
10
+ cookbooks.raw.each do |name, version|
11
+ server_has_cookbook?(name, version).should be_true
12
+ end
13
+ end
@@ -0,0 +1,56 @@
1
+ require 'aruba/api'
2
+
3
+ World(Aruba::Api)
4
+ World(Berkshelf::RSpec::FileSystemMatchers)
5
+
6
+ Then /^I trace$/ do
7
+ end
8
+
9
+ When /^I sleep$/ do
10
+ sleep 10
11
+ end
12
+
13
+ Then /^a file named "(.*?)" should exist in the current directory$/ do |filename|
14
+ in_current_dir do
15
+ File.exists?(filename).should be_true # not sure why Aruba's
16
+ # #check_file_presence
17
+ # doesn't work here. It
18
+ # looks in the wrong
19
+ # directory.
20
+ end
21
+ end
22
+
23
+ Then /^the file "(.*?)" should contain in the current directory:$/ do |filename, string|
24
+ in_current_dir do
25
+ File.read(filename).should match(Regexp.new(string))
26
+ end
27
+ end
28
+
29
+ When /^I run the init command with the cookbook "(.*?)" as the target$/ do |cookbook_name|
30
+ run_simple(unescape("knife berks init #{cookbook_name}"), false)
31
+ end
32
+
33
+ When /^I run the init command with the directory "(.*?)" as the target$/ do |directory_name|
34
+ run_simple(unescape("knife berks init #{directory_name}"), false)
35
+ end
36
+
37
+ When /^I run the init command with no value for the target$/ do
38
+ run_simple(unescape("knife berks init"), false)
39
+ end
40
+
41
+ When /^I run the install command$/ do
42
+ run_simple(unescape("knife berks install"), false)
43
+ end
44
+
45
+ When /^I run the update command$/ do
46
+ run_simple(unescape("knife berks update"), false)
47
+ end
48
+
49
+ When /^I run the upload command$/ do
50
+ run_simple(unescape("knife berks upload"), false)
51
+ end
52
+
53
+ Then /^the CLI should exit with the status code for error "(.*?)"$/ do |error_constant|
54
+ exit_status = Berkshelf.const_get(error_constant).status_code
55
+ assert_exit_status(exit_status)
56
+ end