Skip to content

Commit

Permalink
Do not read Berkshelf config values in cookbook generator spec
Browse files Browse the repository at this point in the history
Fixes #1226
  • Loading branch information
sethvargo committed Nov 1, 2014
1 parent 054fa5f commit af88d11
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions spec/unit/berkshelf/cookbook_generator_spec.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
require 'spec_helper'

describe Berkshelf::CookbookGenerator do
let(:name) { 'sparkle_motion' }
let(:name) { 'sparkle_motion' }
let(:license) { 'reserved' }
let(:maintainer) { 'Berkshelf Core' }
let(:maintainer_email) { 'core@berkshelf.com' }

let(:target) { tmp_path.join(name) }
let(:kitchen_generator) { double('kitchen-generator', invoke_all: nil) }

before do
allow(Kitchen::Generator::Init).to receive(:new).with(any_args()).and_return(kitchen_generator)
allow(Kitchen::Generator::Init)
.to receive(:new)
.with(any_args())
.and_return(kitchen_generator)
end

context 'with default options' do
before do
capture(:stdout) { Berkshelf::CookbookGenerator.new([target, name]).invoke_all }
capture(:stdout) do
Berkshelf::CookbookGenerator.new([target, name],
license: license,
maintainer: maintainer,
maintainer_email: maintainer_email,
).invoke_all
end
end

it "generates a new cookbook" do
Expand All @@ -26,7 +39,7 @@
file 'default.rb' do
contains '# Cookbook Name:: sparkle_motion'
contains '# Recipe:: default'
contains "# Copyright (C) #{Time.now.year} YOUR_NAME"
contains "# Copyright (C) #{Time.now.year} Berkshelf Core"
contains '# All rights reserved - Do Not Redistribute'
end
end
Expand All @@ -35,7 +48,7 @@
directory 'default'
end
file 'LICENSE' do
contains "Copyright (C) #{Time.now.year} YOUR_NAME"
contains "Copyright (C) #{Time.now.year} Berkshelf Core"
contains 'All rights reserved - Do Not Redistribute'
end
file 'README.md' do
Expand All @@ -44,16 +57,16 @@
contains " <td><tt>['sparkle_motion']['bacon']</tt></td>"
contains "Include `sparkle_motion` in your node's `run_list`:"
contains ' "recipe[sparkle_motion::default]"'
contains 'Author:: YOUR_NAME (<YOUR_EMAIL>)'
contains 'Author:: Berkshelf Core (<core@berkshelf.com>)'
end
file 'CHANGELOG.md' do
contains '# 0.1.0'
contains "Initial release of sparkle_motion"
end
file 'metadata.rb' do
contains "name 'sparkle_motion'"
contains "maintainer 'YOUR_NAME'"
contains "maintainer_email 'YOUR_EMAIL'"
contains "maintainer 'Berkshelf Core'"
contains "maintainer_email 'core@berkshelf.com'"
contains "license 'All rights reserved'"
contains "description 'Installs/Configures sparkle_motion'"
end
Expand Down

0 comments on commit af88d11

Please sign in to comment.