spec/unit/berkshelf/init_generator_spec.rb in berkshelf-0.6.0.beta2 vs spec/unit/berkshelf/init_generator_spec.rb in berkshelf-0.6.0.beta3
- old
+ new
@@ -12,14 +12,20 @@
capture(:stdout) { generator.invoke_all }
end
specify do
target.should have_structure {
+ file ".gitignore"
file "Berksfile"
file "Gemfile" do
contains "gem 'berkshelf'"
+ contains "gem 'vagrant'"
end
+ file "Vagrantfile" do
+ contains "require 'berkshelf/vagrant'"
+ contains "recipe[some_cookbook::default]"
+ end
no_file "chefignore"
}
end
end
@@ -37,10 +43,12 @@
end
end
context "with a metadata entry in the Berksfile" do
before do
+ Dir.mkdir target
+ File.write target.join("metadata.rb"), ""
generator = subject.new([target], metadata_entry: true)
capture(:stdout) { generator.invoke_all }
end
specify do
@@ -50,42 +58,10 @@
end
}
end
end
- context "with the vagrant option true" do
- before do
- generator = subject.new([target], vagrant: true)
- quietly { generator.invoke_all }
- end
-
- specify do
- target.should have_structure {
- file "Vagrantfile" do
- contains "require 'berkshelf/vagrant'"
- contains "recipe[some_cookbook::default]"
- end
- file "Gemfile" do
- contains "gem 'vagrant'"
- end
- }
- end
- end
-
- context "with the git option true" do
- before do
- generator = subject.new([target], git: true)
- capture(:stdout) { generator.invoke_all }
- end
-
- specify do
- target.should have_structure {
- file ".gitignore"
- }
- end
- end
-
context "with the foodcritic option true" do
before do
generator = subject.new([target], foodcritic: true)
capture(:stdout) { generator.invoke_all }
end
@@ -144,9 +120,35 @@
context "when no value for cookbook_name option is specified" do
it "infers the name of the cookbook from the directory name" do
generator = subject.new([target])
generator.send(:cookbook_name).should eql("some_cookbook")
+ end
+ end
+
+ context "when skipping git" do
+ before do
+ generator = subject.new([target], skip_git: true)
+ capture(:stdout) { generator.invoke_all }
+ end
+
+ it "should not have a .git directory" do
+ target.should_not have_structure {
+ directory ".git"
+ }
+ end
+ end
+
+ context "when skipping vagrant" do
+ before do
+ generator = subject.new([target], skip_vagrant: true)
+ capture(:stdout) { generator.invoke_all }
+ end
+
+ it "should not have a Vagrantfile" do
+ target.should have_structure {
+ no_file "Vagrantfile"
+ }
end
end
end
end