spec/gitmine_spec.rb in gitmine-0.1.1 vs spec/gitmine_spec.rb in gitmine-0.1.2

- old
+ new

@@ -1,35 +1,47 @@ require 'spec_helper' describe Gitmine do + before do + File.stub!(:read) { "ref: refs/heads/wip" } + end + let(:gitmine) { Gitmine.new } let(:commit_1) do mock( :message => "Commit 1 #1234", :committer => "Sam", :committed_date => Time.now ) end + let(:repo) do + mock(Grit::Repo, :commits => [commit_1]) + end + before do - Grit::Repo.stub!(:new) { - mock(Grit::Repo, :commits => [commit_1]) - } + Grit::Repo.stub!(:new) { repo } end describe "#commits" do - it "should return the last 10 commit messages" do - gitmine.commits.should == [commit_1] + it "should return Gitmine commits" do + gitmine.commits.first.should be_a Commit end + it "should return commits for the current branch" do + repo.should_receive(:commits).with('wip') + gitmine.commits + end end describe "#initialize" do - context "when not a git repo" do - it "should raise an exception" + let(:grit_repo) { mock(:checkout => true)} + before do + Grit::Repo.stub!(:new) { grit_repo } end - context "when git repo" do - it "should not raise any exception" + it "should check out to the current branch" do + Grit::Repo.should_receive(:new).with(ENV['PWD']) { grit_repo } + Gitmine.new end end end