require 'spec_helper' describe Pig do let(:format) { :plain } let(:pig) { Pig.new({:format => format}) } 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_message) { stub(:to_s => "One great commit") } let(:author) { stub(:date => date, :name => "Dev Author") } let(:date) { stub(:strftime => "12-31-01") } let(:commit) { stub(:author => author, :to_s => "393932", :message => commit_message) } context "plain format" do let(:format) { :plain } it "returns the commit message, sha1, date, and author in plain text" do pig.send(:format_commit, commit).should == "One great commit\n 393932\n 12-31-01 Dev Author\n\n" end end context "html format" do let(:format) { :html } it "returns the commit message, sha1, date, and author in html format" do pig.send(:format_commit, commit).should == "