Sha256: c6c612546d416074cedc0526cb8d49b2188ffef6cbcdd43305c98dff5e52b7f7

Contents?: true

Size: 1.61 KB

Versions: 3

Compression:

Stored size: 1.61 KB

Contents

require "spec_helper"

describe GitPresenter::Slide do
  context "when displaying as string" do
    it "should write out the commit id and the message" do
      slide = GitPresenter::Slide.new({"commit" => "012345678901234567890","message" => "message"})
      slide.to_s.should eql "0123456789, message"
    end

    it "should not blow up if no command exists" do
      slide = GitPresenter::Slide.new({"run" => "echo hello world"})
      slide.to_s.should eql "run: echo hello world"
    end
  end

  describe "execute" do
    context "when slide has only a run command" do
      it "should run that command" do
        command_line_helper = CommandLineHelper.capture_output
        slide = GitPresenter::Slide.new({"run" => "echo hello world"})
        slide.execute.strip.should eql "hello world"
      end
    end

    context "when slide contains both commit and run message" do
      it "should checkout the code then run the command" do
        command_line_helper = CommandLineHelper.capture_output
        slide = GitPresenter::Slide.new({"commit" => "number", "message" => "checkout", "run" => "echo hello world"})
        slide.stub(:checkout).and_return("checkout\n")
        slide.execute.should eql "checkout\nhello world\n"
      end
    end

    context "when slide contains only a commit" do
      it "should checkout the code then run the command" do
        command_line_helper = CommandLineHelper.capture_output
        slide = GitPresenter::Slide.new({"commit" => "number", "message" => "checkout"})
        slide.stub(:checkout).and_return("checkout\n")
        slide.execute.should eql "checkout\n"
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
git_presenter-0.3.0 spec/lib/git_presenter/slide_spec.rb
git_presenter-0.2.2 spec/lib/git_presenter/slide_spec.rb
git_presenter-0.2.1 spec/lib/git_presenter/slide_spec.rb