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