Skip to content
This repository has been archived by the owner on Feb 9, 2018. It is now read-only.

Commit

Permalink
KnifeInterface coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Blades committed Mar 27, 2013
1 parent 1075e4c commit f97a2e5
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .rspec
@@ -0,0 +1,2 @@
-fd
-c
3 changes: 3 additions & 0 deletions .simplecov
@@ -0,0 +1,3 @@
SimpleCov.start do
add_filter '/spec/'
end
19 changes: 19 additions & 0 deletions Rakefile
@@ -1,2 +1,21 @@
#!/usr/bin/env rake
require "bundler/gem_tasks"
require "rspec/core/rake_task"

desc 'Run all tests'
task :test => [:spec]

desc "Run all rspec tests"
RSpec::Core::RakeTask.new 'spec' do |t|
t.pattern = 'spec/**/*_spec.rb'
# t.rspec_opts = '-I spec -I spec/lib/silver_spurs -I lib -I . -fd
# -c'
t.rspec_opts = '-fd -c'
end

desc "Run all rspec tests and generate a coverage report"
task :coverage do
ENV['COVERAGE'] = 'true'
Rake::Task['spec'].invoke
`open coverage/index.html` if RUBY_PLATFORM.downcase.include? 'darwin'
end
1 change: 1 addition & 0 deletions silver_spurs.gemspec
Expand Up @@ -26,5 +26,6 @@ Gem::Specification.new do |gem|
gem.add_development_dependency 'growl'
gem.add_development_dependency 'rb-fsevent', '~> 0.9'
gem.add_development_dependency 'rack-test'
gem.add_development_dependency 'rake'

end
15 changes: 8 additions & 7 deletions spec/lib/silver_spurs/app_spec.rb
Expand Up @@ -51,41 +51,42 @@ def app

context "with good node name" do
before(:each) do
SilverSpurs::KnifeInterface.stub(:bootstrap).and_return({:exit_code => 0, :log_lines => "I'm a test!"})
SilverSpurs::Asyncifier.stub(:has_lock?).and_return true
end

it "should accept node names with dashes" do
node_name = "your-mom"
put "/bootstrap/10.0.0.0", :node_name => node_name
last_response.status.should eq 201
last_response.status.should eq 303
end

it "should accept one-word node names" do
node_name = "mom"
put "/bootstrap/10.0.0.0", :node_name => node_name
last_response.status.should eq 201
last_response.status.should eq 303
end

it "should accept node names with numbers" do
node_name = "mombot-3000"
put "/bootstrap/10.0.0.0", :node_name => node_name
last_response.status.should eq 201
last_response.status.should eq 303
end

it "should accept node names with 15 chars" do
node_name = "123456789012345"
put "/bootstrap/10.0.0.0", :node_name => node_name
last_response.status.should eq 201
last_response.status.should eq 303
end

it "should accept node names with 3 chars" do
node_name = "123"
put "/bootstrap/10.0.0.0", :node_name => node_name
last_response.status.should eq 201
last_response.status.should eq 303
end

end



end
end

Expand Down
27 changes: 26 additions & 1 deletion spec/lib/silver_spurs/knife_interface_spec.rb
Expand Up @@ -81,7 +81,32 @@
end

end
end

describe 'supported_arguments' do

it 'includes all of the keys form BOOTSTRAP_ARGS_MAP' do
SilverSpurs::KnifeInterface::BOOTSTRAP_ARGS_MAP.each do |k,v|
SilverSpurs::KnifeInterface.supported_arguments.should include k
end
end

end

describe 'bootstrap_command' do

it 'expands the arguments into a "knife bootstrap -FLAG VALUE HOST" pattern' do
ip = '1.2.3.4'
node_name = 'noodles'
user = 'user'
key = 'key'
options = {:distro => 'suse', :run_list => 'recipe[world_one]'}
expected = "knife bootstrap -i '#{key}' -x '#{user}' -N '#{node_name}' -d 'suse' -r 'recipe[world_one]' #{ip}"
SilverSpurs::KnifeInterface.bootstrap_command(ip, node_name, user, key, options).should eq expected
end

end


end


2 changes: 2 additions & 0 deletions spec/spec_helper.rb
@@ -1,3 +1,5 @@
require 'simplecov' and SimpleCov.start if ENV['COVERAGE']

require_relative '../lib/silver_spurs'
require 'rack/test'

Expand Down

0 comments on commit f97a2e5

Please sign in to comment.