Sha256: 3e9ce5baf30ea84e23551f6e26fa7103df8d0592e1e0835b83ce8824b200235b

Contents?: true

Size: 1.8 KB

Versions: 1

Compression:

Stored size: 1.8 KB

Contents

require 'capistrano/blaze/message'

describe Capistrano::Blaze::Message do

  subject { Capistrano::Blaze::Message }
  let(:exception) { RuntimeError.new("woops") }

  before do
    subject.any_instance.stub(:user) { "your mom" }
  end

  it "sends a test message" do
    should_speak(":heart: basecamp!")
    context = stub(:application => "basecamp")
    subject.test(context)
  end

  context "with multistage extension" do

    let(:context) { stub(:stage => "production", :application => "basecamp") }

    it "displays a start message" do
      should_speak("your mom is deploying to the production stage of basecamp, via `#{command}`")
      subject.start(context)
    end

    it "displays a failure message" do
      should_speak(":warning: your mom failed to deploy to the production stage of basecamp, via `#{command}`: woops (RuntimeError)")
      subject.failure(context, exception)
    end

    it "displays success message" do
      should_speak("your mom succesfully deployed to the production stage of basecamp, via `#{command}`")
      subject.success(context)
    end

  end

  context "without multistage extension" do

    let(:context) { stub(:application => "basecamp") }

    it "displays a start message" do
      should_speak("your mom is deploying basecamp, via `#{command}`")
      subject.start(context)
    end

    it "displays success message" do
      should_speak("your mom succesfully deployed basecamp, via `#{command}`")
      subject.success(context)
    end

    it "displays failure message" do
      should_speak(":warning: your mom failed to deploy basecamp, via `#{command}`: woops (RuntimeError)")
      subject.failure(context, exception)
    end

  end

  def command
    [ 'cap', *ARGV ] * ' '
  end

  def should_speak(message)
    Capistrano::Blaze.should_receive(:speak).with(message)
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
capistrano-blaze-0.2.0 spec/message_spec.rb