Sha256: d4ba0c2ffb6944686831071e70f060b719a9cd6b6cf78314ea14ecf52c358b1f

Contents?: true

Size: 1.95 KB

Versions: 5

Compression:

Stored size: 1.95 KB

Contents

# Load Spec Helper
require File.join(File.expand_path(File.dirname(__FILE__)), '../..', 'spec_helper')

describe StackFu::Commands::PublishCommand do
  
  it "checks if script exists before publishing" do
    prepare(:get, '/scripts/firewall.json', '/scripts/firewall.json')
    prepare(:delete, '/scripts/firewall.json', '/scripts/delete.json')
    prepare(:post, '/scripts.json', '/scripts/create.json')
    
    setup_script(:script_name => 'firewall')
  
    agree_with("You already have a script named firewall. Do you want to update it?")
  
    command "pub"
    stdout.should =~ /Publishing script firewall/
    stdout.should =~ /Success/
  end
  
  def setup_script(options={})
    StackFu::Commands::PublishCommand.any_instance.expects(:read).with("script.yml").returns(<<-EOS)
--- 
type: stack
name: #{options[:"script_name"] || "my_script"}
description: "This will deploy my script"
EOS
    StackFu::Commands::PublishCommand.any_instance.expects(:read).with("config/01-controls.yml").returns(<<-EOS)
controls:
- name: nome
  label: Nome
  type: Textbox
- name: idade
  label: Idade
  type: Numericbox
EOS
    StackFu::Commands::PublishCommand.any_instance.expects(:read).with("config/02-requirements.yml").returns(<<-EOS)
requirements:

- type: directory
  data: "/var"
  error: "You need /var folder before installing"
EOS
    StackFu::Commands::PublishCommand.any_instance.expects(:read).with("config/03-executions.yml").returns(options[:scripts] || <<-EOS)
executions: 

- description: Echoer
  file: echoer
EOS
    StackFu::Commands::PublishCommand.any_instance.expects(:read).with("config/04-validations.yml").returns(<<-EOS)
validations:
- type: directory
  data: "/etc/apache2"
  error: Apache was not installed properly
EOS

    unless options[:scripts]
      StackFu::Commands::PublishCommand.any_instance.expects(:read).with("executables/echoer.sh.erb").returns(<<-EOS)
#
# echoe.sh
# Echoes a variable
#

echo "<%= nome %> is <%= age %> years old"
EOS
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
stackfu-0.1.5 spec/stackfu/commands/publish_command_spec.rb
stackfu-0.1.4 spec/stackfu/commands/publish_command_spec.rb
stackfu-0.1.3 spec/stackfu/commands/publish_command_spec.rb
stackfu-0.1.2.2 spec/stackfu/commands/publish_command_spec.rb
stackfu-0.1.2.1 spec/stackfu/commands/publish_command_spec.rb