features/step_definitions/filesystem_steps.rb in berkshelf-2.0.18 vs features/step_definitions/filesystem_steps.rb in berkshelf-3.0.0.beta1
- old
+ new
@@ -1,64 +1,29 @@
require 'aruba/api'
World(Aruba::Api)
World(Berkshelf::RSpec::ChefAPI)
+World(Berkshelf::RSpec::FileSystemMatchers)
-Given /^I dynamically write to "(.+)" with:$/ do |file, contents|
- steps %{
- Given I write to "#{file}" with:
- """
- #{ERB.new(contents).result(binding)}
- """
- }
-end
-
Given /^a cookbook named "(.*?)"$/ do |name|
steps %{
Given a directory named "#{name}"
And an empty file named "#{name}/metadata.rb"
}
end
-Given /^I do not have a Berksfile$/ do
- in_current_dir { FileUtils.rm_f(Berkshelf::DEFAULT_FILENAME) }
-end
-
-Given /^I do not have a Berksfile\.lock$/ do
- in_current_dir { FileUtils.rm_f("#{Berkshelf::DEFAULT_FILENAME}.lock") }
-end
-
-Given /^I have a default Berkshelf config file$/ do
- Berkshelf::Config.new.save
-end
-
-Given /^I have a Berkshelf config file containing:$/ do |contents|
- ::File.open(Berkshelf::Config.path, 'w+') do |f|
- f.write(contents)
- end
-end
-
-Given /^I do not have a Berkshelf config file$/ do
- remove_file Berkshelf::Config.path if ::File.exists? Berkshelf::Config.path
-end
-
-Given /^I do not have a Berkshelf config file at "(.+)"$/ do |path|
- remove_file(path) if File.exists?(path)
-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|
cookbooks.raw.each do |name, version, license|
- generate_cookbook(cookbook_store, name, version, license: license)
+ generate_cookbook(cookbook_store.storage_path, name, version, license: license)
end
end
-Given /^the cookbook store has the cookbooks installed by git:$/ do |cookbooks|
+Given /^the cookbook store has the git cookbooks:$/ do |cookbooks|
cookbooks.raw.each do |name, version, sha|
folder = "#{name}-#{sha}"
metadata = File.join(folder, 'metadata.rb')
create_dir(folder)
@@ -68,28 +33,32 @@
].join("\n"))
end
end
Given /^the cookbook store contains a cookbook "(.*?)" "(.*?)" with dependencies:$/ do |name, version, dependencies|
- generate_cookbook(cookbook_store, name, version, dependencies: dependencies.raw)
+ generate_cookbook(cookbook_store.storage_path, name, version, dependencies: dependencies.raw)
end
+Given(/^the cookbook store is empty$/) do
+ Berkshelf::CookbookStore.instance.clean!
+end
+
Then /^the cookbook store should have the cookbooks:$/ do |cookbooks|
cookbooks.raw.each do |name, version|
- expect(cookbook_store).to have_structure {
+ expect(cookbook_store.storage_path).to have_structure {
directory "#{name}-#{version}" do
file "metadata.rb" do
contains version
end
end
}
end
end
-Then /^the cookbook store should have the cookbooks installed by git:$/ do |cookbooks|
+Then /^the cookbook store should have the git cookbooks:$/ do |cookbooks|
cookbooks.raw.each do |name, version, sha1|
- expect(cookbook_store).to have_structure {
+ expect(cookbook_store.storage_path).to have_structure {
directory "#{name}-#{sha1}" do
file "metadata.rb" do
contains version
end
end
@@ -97,25 +66,20 @@
end
end
Then /^the cookbook store should not have the cookbooks:$/ do |cookbooks|
cookbooks.raw.each do |name, version|
- expect(cookbook_store).to_not have_structure {
+ expect(cookbook_store.storage_path).to_not have_structure {
directory "#{name}-#{version}"
}
end
end
-Then /^I should have the cookbook "(.*?)"$/ do |name|
- expect(Pathname.new(current_dir).join(name)).to be_cookbook
-end
-
Then /^I should have a new cookbook skeleton "(.*?)"$/ do |name|
cb_path = Pathname.new(current_dir).join(name)
expect(cb_path).to have_structure {
directory "attributes"
- directory "definitions"
directory "files" do
directory "default"
end
directory "libraries"
directory "providers"
@@ -204,11 +168,10 @@
Then /^I should have a new cookbook skeleton "(.*?)" with no Bundler support$/ do |name|
cb_path = Pathname.new(current_dir).join(name)
expect(cb_path).to have_structure {
directory "attributes"
- directory "definitions"
directory "files" do
directory "default"
end
directory "libraries"
directory "providers"
@@ -284,14 +247,6 @@
Pathname.new(current_dir).join(directory_name).should_not have_structure {
file "Berksfile" do
contains content
end
}
-end
-
-Then /^the current directory should have the following files:$/ do |files|
- 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