Sha256: 743801f4f16316a8c185386c3f6d07fc826154076db2717de0eca2b8ddf798f1

Contents?: true

Size: 1.29 KB

Versions: 5

Compression:

Stored size: 1.29 KB

Contents

require 'spec_helper'

describe Pig do

  let(:pig) { Pig.new }

  describe "#call" do

    before do
      pig.stub(:history).and_return('some text')
    end

    it "returns a valid rack response" do
      pig.call(:any_environment).should == [200, {"Content-Type" => "text/plain"}, ['some text']]
    end

  end

  describe "#format" do

    let(:commit) { stub(:author => author, :to_s => "393932") }
    let(:author) { stub(:date => date, :name => "Dev Author") }
    let(:date) { stub(:strftime => "12-31-01") }

    it "returns the sha1, date, and author by default" do
      pig.format(commit).should == "393932 12-31-01 Dev Author\n"
    end

  end

  describe "#repository" do

    it "calls Git.open on the specified working directory" do
      Git.should_receive(:open, Pig::WORKING_DIR)
      pig.repository
    end

  end

  describe "#history" do

    before do
      repo = stub(:log)
      pig.stub(:repository).and_return(repo)
      repo.stub(:log, 10).and_return([])
    end

    it "retrieves a log of the last 10 commits by default" do
      repo = stub(:log)
      pig.should_receive(:repository).and_return(repo)
      repo.should_receive(:log, 10).and_return([])
      pig.history
    end

    it "returns an empty string if no commits are found" do
      pig.history.should == ""
    end

  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
pig-0.0.6 spec/pig_spec.rb
pig-0.0.5 spec/pig_spec.rb
pig-0.0.4 spec/pig_spec.rb
pig-0.0.3 spec/pig_spec.rb
pig-0.0.2 spec/pig_spec.rb