spec/pre_prepare_spec.rb in bebox-0.1.0 vs spec/pre_prepare_spec.rb in bebox-0.1.1
- old
+ new
@@ -1,21 +1,19 @@
require 'spec_helper'
require 'tilt'
-require 'colorize'
require_relative '../spec/factories/node.rb'
-describe 'Test 05: Bebox::Node' do
+describe 'Test 09: Bebox::Node' do
include Bebox::VagrantHelper
describe 'Pre-prepare nodes' do
let(:nodes) { 1.times.map{|index| build(:node, :created, hostname: "node#{index}.server1.test")} }
let(:project_root) { "#{Dir.pwd}/tmp/bebox-pname" }
let(:environment) { 'vagrant' }
let(:project_name) {'bebox-pname'}
- let(:vagrant_box_base) {"#{Dir.pwd}/ubuntu-server-12042-x64-vbox4210-nocm.box"}
context 'pre vagrant prepare' do
it 'should generate the Vagrantfile' do
Bebox::VagrantHelper.generate_vagrantfile(nodes)
vagrantfile_content = File.read("#{project_root}/Vagrantfile").gsub(/\s+/, ' ').strip
@@ -30,34 +28,39 @@
expect(vagrant_deploy_content).to eq(vagrant_deploy_output_content)
end
end
context 'vagrant prepare' do
+
+ let (:original_hosts_content) { File.read("#{nodes.first.local_hosts_path}/hosts").gsub(/\s+/, ' ').strip }
+
+ before :all do
+ node = nodes.first
+ puts "\nPlease provide your local password, if asked, to configure the local hosts file.".yellow
+ original_hosts_content
+ `sudo rm -rf #{node.local_hosts_path}/hosts_before_#{project_name}`
+ prepare_vagrant(node)
+ end
+
describe 'Configure the hosts file' do
it 'should create a hosts backup file' do
node = nodes.first
- puts "\nPlease provide your account password, if ask you, to configure the local hosts file.".yellow
- `sudo rm -rf #{node.local_hosts_path}/hosts_before_#{project_name}`
- original_hosts_content = File.read("#{node.local_hosts_path}/hosts").gsub(/\s+/, ' ').strip
- nodes.each{|node| node.backup_local_hosts(project_name)}
hosts_backup_file = "#{node.local_hosts_path}/hosts_before_#{project_name}"
expect(File).to exist(hosts_backup_file)
hosts_backup_content = File.read(hosts_backup_file).gsub(/\s+/, ' ').strip
expect(original_hosts_content).to eq(hosts_backup_content)
end
it 'should add the hosts config to hosts file' do
- nodes.each{|node| add_to_local_hosts(node)}
node = nodes.first
hosts_content = File.read("#{node.local_hosts_path}/hosts").gsub(/\s+/, ' ').strip
expect(hosts_content).to include(*nodes.map{|node| "#{node.ip} #{node.hostname}"})
end
end
describe 'vagrant setup' do
it 'should add the node to vagrant' do
vagrant_box_names_expected = nodes.map{|node| "#{project_name}-#{node.hostname}"}
- nodes.each{|node| add_vagrant_node(project_name, vagrant_box_base, node)}
node = nodes.first
expect(installed_vagrant_box_names(node)).to include(*vagrant_box_names_expected)
end
it 'should up the vagrant boxes' do
\ No newline at end of file