Skip to content

Commit

Permalink
adding testing bits, fixing an bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean OMeara committed Aug 8, 2013
1 parent 2ec93da commit 51b2eba
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 2 deletions.
Empty file added .kitchen/logs/celluloid.log
Empty file.
1 change: 1 addition & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--color
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
source 'https://rubygems.org'

gem 'berkshelf'
gem 'rspec', :group => :integration
gem 'chefspec', :group => :integration
gem 'guard', :group => :integration
gem 'test-kitchen', :group => :integration
gem 'kitchen-vagrant', :group => :integration
10 changes: 10 additions & 0 deletions Guardfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# A sample Guardfile
# More info at https://github.com/guard/guard#readme

guard 'rspec', spec_paths: [ 'spec' ] do
watch(%r{^spec/.+spec\.rb$})
watch('spec/spec_helper.rb') { 'spec' }
watch(%r{recipes/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch(%r{([A-Za-z]+)/(.+)(\..*)?$}) { |m| "spec/*.rb" }
end

2 changes: 1 addition & 1 deletion files/default/dangerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ HELLO THERE I AM DANGERFILE
# UNCOMMENT ME YOU FOOL
COMMENT ME AND I STOP YELLING I PROMISE
int main(void){ for i=0; i<100; i++ };
hey there
hey there
4 changes: 4 additions & 0 deletions files/default/dangerfile2
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAADA1F45ADMVN24QFL123LPPEQWERWWEWO keepme@yourfile
ssh-rsa AAAAB3NzaC1yc2EAAAADDEADBEEFDERPDERPDERPILIKESSHTOO skelator@grayskull
ssh-rsa AAAAB3NzaC1yc2EAAAADAKHASDKJHSDKHASDHK1231235KJASD0 keepmetoo@yourfile
2 changes: 1 addition & 1 deletion libraries/provider_replace_or_add.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def action_edit
temp_file.puts line
end

if (!found && !modified) then # "add"!
if (!found && modified) then # "add"!
temp_file.puts new_resource.line
modified = true
end
Expand Down
18 changes: 18 additions & 0 deletions recipes/tester.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@
notifies :run, "execute[woot]"
end

cookbook_file "/tmp/dangerfile2" do
owner "root"
mode "00666"
notifies :run, "execute[woot]"
action :create_if_missing
end

cookbook_file "/tmp/serial.conf" do
owner "root"
mode "00644"
Expand All @@ -52,3 +59,14 @@
line "hey there how you doin"
end

replace_or_add "example 3" do
path "/tmp/dangerfile"
pattern "hey there.*"
line "hey there how you doin"
end

replace_or_add "example 4" do
path "/tmp/dangerfile2"
pattern "ssh-rsa AAAAB3NzaC1yc2EAAAADDEADBEEF.*"
line ""
end
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require 'chefspec'
14 changes: 14 additions & 0 deletions spec/tester_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
require 'spec_helper'

describe 'line::tester' do
let(:chef_run) { ChefSpec::ChefRunner.new.converge 'line::tester' }

it 'creates dangerfile' do
expect(chef_run).to create_cookbook_file '/tmp/dangerfile'
file = chef_run.cookbook_file '/tmp/dangerfile'
expect(file).to be_owned_by('root')
expect(file.mode).to eq("00644")
end

end

0 comments on commit 51b2eba

Please sign in to comment.