Sha256: a92b937a8b053b4fb2cac71c92bf957f1eb3fc0579968a0f6903310440cc8908

Contents?: true

Size: 1.84 KB

Versions: 1

Compression:

Stored size: 1.84 KB

Contents

require 'spec_helper'

describe GitReflow::Workflow do

  class DummyWorkflow
    include GitReflow::Workflow
  end

  let(:workflow) { DummyWorkflow }
  let(:loader)   { double() }

  describe ".current" do
    subject { GitReflow::Workflow.current }

    context "when no workflow is set" do
      before  { allow(GitReflow::Config).to receive(:get).with("reflow.workflow").and_return('') }
      specify { expect( subject ).to eql(GitReflow::Workflows::Core) }
    end

    context "when a workflow is set" do
      let(:workflow_path) { File.join(File.expand_path("../../../fixtures", __FILE__), "/awesome_workflow.rb") }

      before  { allow(GitReflow::Config).to receive(:get).with("reflow.workflow").and_return(workflow_path) }
      specify { expect( subject ).to eql(GitReflow::Workflow::AwesomeWorkflow) }
    end
  end

  describe ".command" do
    it "creates a class method for a bogus command" do
      class DummyWorkflow
        include GitReflow::Workflow
      end
      workflow.command :bogus do
        "Woohoo"
      end

      expect(DummyWorkflow.bogus).to eql("Woohoo")
    end

    it "creates a method for a bogus command with arguments" do
      workflow.command :bogus, arguments: [:feature_branch] do |**params|
        "Woohoo #{params[:feature_branch]}!"
      end

      expect(DummyWorkflow.bogus(feature_branch: "donuts")).to eql("Woohoo donuts!")
    end

    it "creates a class method for a bogus command with default options" do
      workflow.command :bogus, arguments: [:feature_branch], defaults: {decoration: 'sprinkles'} do |**params|
        donut_excitement = "Woohoo #{params[:feature_branch]}"
        donut_excitement += " with #{params[:decoration]}" if params[:decoration]
        "#{donut_excitement}!"
      end

      expect(DummyWorkflow.bogus(feature_branch: "donuts")).to eql("Woohoo donuts with sprinkles!")
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
git_reflow-0.8.10 spec/lib/git_reflow/workflow_spec.rb