Skip to content

Commit

Permalink
Adding instance-level summary.
Browse files Browse the repository at this point in the history
  • Loading branch information
ymendel committed Aug 17, 2009
1 parent c9cdc9a commit 01a0a2d
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/punch/instance.rb
Expand Up @@ -37,6 +37,10 @@ def log(message, options = {})
self.class.log(project, message, options)
end

def summary(options = {})
self.class.summary(project, options)
end

def ==(other)
project == other.project
end
Expand Down
50 changes: 50 additions & 0 deletions spec/punch_instance_spec.rb
Expand Up @@ -382,6 +382,56 @@
end
end

it 'should give project summary' do
@punch.should.respond_to(:summary)
end

describe 'giving project summary' do
before do
@summary = 'summary val'
Punch.stub!(:summary).and_return(@summary)
end

it 'should accept options' do
lambda { @punch.summary(:format => true) }.should.not.raise(ArgumentError)
end

it 'should not require options' do
lambda { @punch.summary }.should.not.raise(ArgumentError)
end

it 'should delegate to the class' do
Punch.should.receive(:summary)
@punch.summary
end

it 'should pass the project when delegating to the class' do
Punch.should.receive(:summary) do |proj, _|
proj.should == @project
end
@punch.summary
end

it 'should pass the options when delegating to the class' do
options = { :format => true }
Punch.should.receive(:summary) do |_, opts|
opts.should == options
end
@punch.summary(options)
end

it 'should pass an empty hash if no options given' do
Punch.should.receive(:summary) do |_, opts|
opts.should == {}
end
@punch.summary
end

it 'should return the value returned by the class method' do
@punch.summary.should == @summary
end
end

describe 'equality' do
it 'should be equal to another instance for the same project' do
Punch.new('proj').should == Punch.new('proj')
Expand Down

0 comments on commit 01a0a2d

Please sign in to comment.