features/step_definitions/filesystem_steps.rb in berkshelf-1.4.6 vs features/step_definitions/filesystem_steps.rb in berkshelf-2.0.0.beta

- old
+ new

@@ -13,11 +13,11 @@ 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::Lockfile::DEFAULT_FILENAME) } + 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 @@ -30,10 +30,15 @@ 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| @@ -46,11 +51,11 @@ generate_cookbook(cookbook_store, name, version, dependencies: dependencies.raw) end Then /^the cookbook store should have the cookbooks:$/ do |cookbooks| cookbooks.raw.each do |name, version| - cookbook_store.should have_structure { + expect(cookbook_store).to have_structure { directory "#{name}-#{version}" do file "metadata.rb" do contains version end end @@ -58,11 +63,11 @@ end end Then /^the cookbook store should have the git cookbooks:$/ do |cookbooks| cookbooks.raw.each do |name, version, sha1| - cookbook_store.should have_structure { + expect(cookbook_store).to have_structure { directory "#{name}-#{sha1}" do file "metadata.rb" do contains version end end @@ -70,23 +75,23 @@ end end Then /^the cookbook store should not have the cookbooks:$/ do |cookbooks| cookbooks.raw.each do |name, version| - cookbook_store.should_not have_structure { + expect(cookbook_store).to_not have_structure { directory "#{name}-#{version}" } end end Then /^I should have the cookbook "(.*?)"$/ do |name| - Pathname.new(current_dir).join(name).should be_cookbook + 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) - cb_path.should have_structure { + expect(cb_path).to have_structure { directory "attributes" directory "definitions" directory "files" do directory "default" end @@ -117,11 +122,11 @@ Then /^I should have a new cookbook skeleton "(.*?)" with Chef-Minitest 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 { + expect(cb_path).to have_structure { file "Berksfile" do contains "cookbook \"minitest-handler\"" end file "Vagrantfile" do contains "recipe[minitest-handler::default]" @@ -149,11 +154,11 @@ 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 { + expect(cb_path).to have_structure { file "Gemfile" do contains "gem 'thor-foodcritic'" end file "Thorfile" do contains "require 'thor/foodcritic'" @@ -163,11 +168,11 @@ Then /^I should have a new cookbook skeleton "(.*?)" with SCMVersion 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 { + expect(cb_path).to have_structure { file "Gemfile" do contains "gem 'thor-scmversion'" end file "Thorfile" do contains "require 'thor/scmversion'" @@ -175,11 +180,11 @@ } end Then /^I should have a new cookbook skeleton "(.*?)" with no Bundler support$/ do |name| cb_path = Pathname.new(current_dir).join(name) - cb_path.should have_structure { + expect(cb_path).to have_structure { directory "attributes" directory "definitions" directory "files" do directory "default" end @@ -202,17 +207,17 @@ no_file "Gemfile" } end Then /^I should have a new cookbook skeleton "(.*?)" with no Git support$/ do |name| - Pathname.new(current_dir).join(name).should have_structure { + expect(Pathname.new(current_dir).join(name)).to have_structure { no_file ".gitignore" } end Then /^I should have a new cookbook skeleton "(.*?)" with no Vagrant support$/ do |name| - Pathname.new(current_dir).join(name).should have_structure { + expect(Pathname.new(current_dir).join(name)).to have_structure { file "Gemfile" do does_not_contain "gem 'vagrant'" end no_file "Vagrantfile" } @@ -225,19 +230,19 @@ Then /^the cookbook "(.*?)" should not have the following files:$/ do |name, files| check_file_presence(files.raw.map{|file_row| ::File.join(name, file_row[0])}, false) end Then /^the file "(.*?)" in the cookbook "(.*?)" should contain:$/ do |file_name, cookbook_name, content| - Pathname.new(current_dir).join(cookbook_name).should have_structure { + expect(Pathname.new(current_dir).join(cookbook_name)).to have_structure { file "Berksfile" do contains content end file "chefignore" } end Then /^the resulting "(.+)" Vagrantfile should contain:$/ do |cookbook_name, content| - Pathname.new(current_dir).join(cookbook_name).should have_structure { + expect(Pathname.new(current_dir).join(cookbook_name)).to have_structure { file "Vagrantfile" do content.respond_to?(:raw) ? content.raw.flatten.each { |string| contains string } : contains(content) end