Sha256: 41bbaf7da660abdd5b5c828c5ff32538ab3d892be21487072a5e1d1341f659db

Contents?: true

Size: 1.48 KB

Versions: 1

Compression:

Stored size: 1.48 KB

Contents

require 'spec_helper'

describe Gitme::CommandLineOptions do

  describe "#initialize" do

    before do
      mock(File).read(file) do
        YAML.dump Hash.new
      end
    end

    describe "with no additional options" do

      let (:file) do
        File.expand_path '~/.gitme.yml'
      end

      it "should read the map of repositories from the ~/.gitme.yml" do
        described_class.new({})
      end

    end

    describe "with -f file option" do

      let (:file) do
        'something'
      end

      it "should read the map of repositories from the specified file" do
        described_class.new({:f => file})
      end

    end

  end

  describe "#fetch" do

    before do
      mock(File).read(anything) do
        YAML.dump repositories
      end
    end

    subject do
      described_class.new({})
    end

    let (:repositories) do
      {'repo' => {
        'repository' => 'path_to_the_repo'
      }}
    end

    describe "a simple repository" do

      it "should map the keys to symbols" do
        subject.fetch('repo')[:repository].should == 'path_to_the_repo'
      end

      it "should map the add the name of the repository as a key" do
        subject.fetch('repo')[:name].should == 'repo'
      end

    end

    describe "a non-existent repository" do

      it "should return the repository settings" do
        lambda{ subject.fetch('non_existent') }.should raise_error(Gitme::Error,
          "Non-existent repository: non_existent")
      end

    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gitme-0.0.1 spec/gitme/command_line_options_spec.rb