features/step_definitions/filesystem_steps.rb in berkshelf-0.6.0.beta2 vs features/step_definitions/filesystem_steps.rb in berkshelf-0.6.0.beta3
- old
+ new
@@ -16,10 +16,20 @@
Given /^I do not have a Berksfile\.lock$/ do
in_current_dir { FileUtils.rm_f(Berkshelf::Lockfile::DEFAULT_FILENAME) }
end
+Given /^I have a Berkshelf config file containing:$/ do |contents|
+ write_file File.expand_path("~/.berkshelf/config.json"), contents
+end
+
+Given /^I do not have a Berkshelf config file$/ do
+ file = File.expand_path "~/.berkshelf/config.json"
+
+ remove_file file if File.exists? file
+end
+
Given /^the cookbook "(.*?)" has the file "(.*?)" with:$/ do |cookbook_name, file_name, content|
write_file(File.join(cookbook_name, file_name), content)
end
Given /^the cookbook store has the cookbooks:$/ do |cookbooks|
@@ -83,47 +93,28 @@
end
directory "resources"
directory "templates" do
directory "default"
end
- file "README.md"
- file "metadata.rb"
+ file ".gitignore"
+ file "chefignore"
file "Berksfile" do
contains "metadata"
end
- file "chefignore"
- file "Berksfile"
file "Gemfile" do
contains "gem 'berkshelf'"
- end
- }
-end
-
-Then /^I should have a new cookbook skeleton "(.*?)" with Vagrant support$/ do |name|
- steps %Q{ Then I should have a new cookbook skeleton "#{name}" }
-
- cb_path = Pathname.new(current_dir).join(name)
- cb_path.should have_structure {
- file "Gemfile" do
contains "gem 'vagrant'"
end
+ file "metadata.rb"
+ file "README.md"
file "Vagrantfile" do
contains "require 'berkshelf/vagrant'"
contains "recipe[#{name}::default]"
end
}
end
-Then /^I should have a new cookbook skeleton "(.*?)" with Git support$/ do |name|
- steps %Q{ Then I should have a new cookbook skeleton "#{name}" }
-
- cb_path = Pathname.new(current_dir).join(name)
- cb_path.should have_structure {
- file ".gitignore"
- }
-end
-
Then /^I should have a new cookbook skeleton "(.*?)" with Foodcritic support$/ do |name|
steps %Q{ Then I should have a new cookbook skeleton "#{name}" }
cb_path = Pathname.new(current_dir).join(name)
cb_path.should have_structure {
@@ -176,10 +167,25 @@
file "Berksfile"
no_file "Gemfile"
}
end
+Then /^I should have a new cookbook skeleton "(.*?)" without Git support$/ do |name|
+ Pathname.new(current_dir).join(name).should have_structure {
+ no_file ".gitignore"
+ }
+end
+
+Then /^I should have a new cookbook skeleton "(.*?)" without Vagrant support$/ do |name|
+ Pathname.new(current_dir).join(name).should have_structure {
+ file "Gemfile" do
+ does_not_contain "gem 'vagrant'"
+ end
+ no_file "Vagrantfile"
+ }
+end
+
Then /^the cookbook "(.*?)" should have the following files:$/ do |name, files|
check_file_presence(files.raw.map{|file_row| File.join(name, file_row[0])}, true)
end
Then /^the cookbook "(.*?)" should not have the following files:$/ do |name, files|
@@ -193,10 +199,20 @@
end
file "chefignore"
}
end
+Then /^the resulting "(.+)" Vagrantfile should contain:$/ do |cookbook_name, content|
+ Pathname.new(current_dir).join(cookbook_name).should have_structure {
+ file "Vagrantfile" do
+ content.respond_to?(:raw) ?
+ content.raw.flatten.each { |string| contains string } :
+ contains(content)
+ end
+ }
+end
+
Then /^the directory "(.*?)" should have the following files:$/ do |name, files|
check_file_presence(files.raw.map{|file_row| File.join(name, file_row[0])}, true)
end
Then /^the directory "(.*?)" should not have the following files:$/ do |name, files|
@@ -215,6 +231,12 @@
check_file_presence(files.raw.map{|file_row| file_row[0]}, true)
end
Then /^the current directory should not have the following files:$/ do |files|
check_file_presence(files.raw.map{|file_row| file_row[0]}, false)
+end
+
+Then /^I should have a Berkshelf config file$/ do
+ Pathname.new(ENV['HOME']).join(".berkshelf").should have_structure {
+ file "config.json"
+ }
end