Skip to content

Commit

Permalink
to_s and inspect for tubes and jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
seanxiesx committed Nov 21, 2013
1 parent 6f6c9a0 commit 4d578d8
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/mock_beaneater/job/record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@ def ==(other_job)
def to_s
"#<MockBeaneater::Job id=#{@id} body=#{@body.inspect}>"
end
alias :inspect :to_s
end
end
5 changes: 5 additions & 0 deletions lib/mock_beaneater/tube/record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ def release(job)
@ready.push(job, job.pri)
end

def to_s
"#<MockBeaneater::Tube name=#{@name.inspect}>"
end
alias :inspect :to_s

private

def refresh_tube
Expand Down
7 changes: 7 additions & 0 deletions spec/job/record_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,11 @@
job.to_s.should == "#<MockBeaneater::Job id=#{job.id} body=#{job.body.inspect}>"
end
end

describe "#inspect" do
it "should output only job id and body" do
job = MockBeaneater::Job.new('body', double)
job.inspect.should == "#<MockBeaneater::Job id=#{job.id} body=#{job.body.inspect}>"
end
end
end
16 changes: 16 additions & 0 deletions spec/tube/record_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,22 @@
end
end

describe "#to_s" do
it "should output only tube name" do
name = 'my-tube'
tube = MockBeaneater::Tube.new(double, name)
tube.to_s.should == "#<MockBeaneater::Tube name=#{name.inspect}>"
end
end

describe "#inspect" do
it "should output only tube name" do
name = 'my-tube'
tube = MockBeaneater::Tube.new(double, name)
tube.inspect.should == "#<MockBeaneater::Tube name=#{name.inspect}>"
end
end

describe "#refresh_tube" do
it "should move jobs which should be visible from delayed to ready" do
tube = MockBeaneater::Tube.new(double, double)
Expand Down

0 comments on commit 4d578d8

Please sign in to comment.