require 'spec_helper' describe Gitme do let(:name) do 'something' end let(:repository) do File.join(File.dirname(__FILE__),'..','.git') end describe "#initialize" do it "should not generate an error" do lambda{ described_class.new({}) }.should_not raise_error end end describe "#execute!" do subject do described_class.new({:repository => repository}) end it "should call #clone for the specified repository" do mock(subject).clone subject.execute! end end describe "#clone" do describe "a simple repository" do subject do described_class.new({:repository => repository, :name => name}) end it "should clone the specified repository" do subject.clone File.exists?(name).should be_true end after do FileUtils.rm_rf(name) if File.exists?(name) end end describe "when git fails" do subject do described_class.new({:repository => 'non_existent_repo', :name => name}) end it "should clone the specified repository" do lambda{ subject.clone }.should raise_error(Gitme::Error, "Git failed to clone non_existent_repo") end end end end