spec/pre_prepare_spec.rb in bebox-0.0.1 vs spec/pre_prepare_spec.rb in bebox-0.1.0

- old
+ new

@@ -3,21 +3,23 @@ require 'colorize' require_relative '../spec/factories/node.rb' describe 'Test 05: 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::Node.generate_vagrantfile(project_root, nodes) + Bebox::VagrantHelper.generate_vagrantfile(nodes) vagrantfile_content = File.read("#{project_root}/Vagrantfile").gsub(/\s+/, ' ').strip ouput_template = Tilt::ERBTemplate.new('spec/fixtures/node/Vagrantfile.test.erb') vagrantfile_output_content = ouput_template.render(nil, ip_address: nodes.first.ip).gsub(/\s+/, ' ').strip expect(vagrantfile_content).to eq(vagrantfile_output_content) end @@ -42,27 +44,27 @@ 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| node.add_to_local_hosts} + 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| node.add_vagrant_node(project_name, vagrant_box_base)} + nodes.each{|node| add_vagrant_node(project_name, vagrant_box_base, node)} node = nodes.first - expect(node.installed_vagrant_box_names).to include(*vagrant_box_names_expected) + expect(installed_vagrant_box_names(node)).to include(*vagrant_box_names_expected) end it 'should up the vagrant boxes' do - Bebox::Node.up_vagrant_nodes(project_root) - nodes.each{|node| expect(node.vagrant_box_running?).to eq(true)} + Bebox::VagrantHelper.up_vagrant_nodes(project_root) + nodes.each{|node| expect(vagrant_box_running?(node)).to eq(true)} end it 'should connect to vagrant box through ssh' do connection_successful = true nodes.each do |node| \ No newline at end of file