Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add back working chef_dna specs and rake spec

  • Loading branch information...
commit bfe81a447201b32812e35622af8ed0f4e1873f01 1 parent 90bc32d
@cldwalker cldwalker authored
Showing with 75 additions and 0 deletions.
  1. +7 −0 Rakefile
  2. +58 −0 spec/chef_dna_spec.rb
  3. +10 −0 spec/spec_helper.rb
View
7 Rakefile
@@ -6,3 +6,10 @@ task :bam do
require 'elzar'
Elzar.create_provision_directory File.dirname(__FILE__) + '/provision', :local => true
end
+
+desc "Run Rspec tests"
+task :spec do
+ sh 'rspec spec'
+end
+
+task :default => :spec
View
58 spec/chef_dna_spec.rb
@@ -0,0 +1,58 @@
+require 'spec_helper'
+
+describe Elzar::ChefDNA do
+ let(:database) { 'mysql' }
+ let(:json) {
+ {
+ "run_list" => ["role[plumbing]", "mysql::server", "role[enterprise_appstack]", "rails_app"],
+ 'ruby' => {'url' => '', 'version' => '', 'gems_version' => ''},
+ 'ruby_enterprise' => {'url' => '', 'version' => '', 'gems_version' => ''}
+ }
+ }
+ let(:run_list) { json['run_list'] }
+
+ def splice(database = nil)
+ Elzar::ChefDNA.gene_splice(json, database, ruby_version)
+ end
+
+ describe '.gene_splice' do
+ context 'for mri ruby' do
+ let(:ruby_version) { 'ruby-1.9.3-p194' }
+
+ it "updates run_list correctly for mysql" do
+ splice 'mysql'
+ run_list[1].should == 'mysql::server'
+ end
+
+ it "updates run_list correctly for mysql as default" do
+ splice nil
+ run_list[1].should == 'mysql::server'
+ end
+
+ it "updates run_list correctly for postgresql" do
+ splice 'postgresql'
+ run_list[1].should == 'role[postgres_database]'
+ end
+
+ it "updates ruby dna correctly" do
+ splice
+ json['ruby']['url'].should == "http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p194.tar.gz"
+ json['ruby']['version'].should == '1.9.3-p194'
+ json['ruby']['gems_version'].should == Gem::VERSION
+ run_list[2].should == 'role[ruby_appstack]'
+ end
+ end
+
+ context 'for ree' do
+ let(:ruby_version) { 'ree-1.8.7-2011.03' }
+
+ it "updates ree dna correctly" do
+ splice
+ json['ruby_enterprise']['url'].should == "http://rubyenterpriseedition.googlecode.com/files/ruby-enterprise-1.8.7-2011.03"
+ json['ruby_enterprise']['version'].should == '1.8.7-2011.03'
+ json['ruby_enterprise']['gems_version'].should == Gem::VERSION
+ run_list[2].should == 'role[enterprise_appstack]'
+ end
+ end
+ end
+end
View
10 spec/spec_helper.rb
@@ -0,0 +1,10 @@
+require 'elzar'
+
+RSpec.configure do |config|
+ config.filter_run_excluding :disabled => true
+ config.run_all_when_everything_filtered = true
+
+ config.alias_example_to :fit, :focused => true
+ config.alias_example_to :xit, :disabled => true
+ config.alias_example_to :they
+end
Please sign in to comment.
Something went wrong with that request. Please try again.