Skip to content

Commit

Permalink
Adding a Waiting Reservation class
Browse files Browse the repository at this point in the history
I'm still not 100% comfortable with this approach but for now I think we
can get something working and then think about something else. Otherwise
nothing will be accomplished.

Related to #2
  • Loading branch information
nhocki committed Jan 16, 2013
1 parent 51d8d36 commit 77b3bdd
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/deustorb/reservation.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
require 'deustorb/reservations/waiting'

module Deustorb
class Reservation
module Reservation
WAITING = 'waiting'
end
end
end
13 changes: 13 additions & 0 deletions lib/deustorb/reservations/waiting.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module Deustorb
module Reservation
class Waiting
attr_reader :id, :status, :position

def initialize(options)
@id = options.fetch(:id)
@position = options.fetch(:position)
@status = Reservation::WAITING
end
end
end
end
32 changes: 32 additions & 0 deletions spec/deustorb/reservations/waiting_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
require 'spec_helper'
module Deustorb
module Reservation
describe Waiting do
def reservation
Deustorb::Reservation::Waiting.new(id: 'some-id', position: 3)
end

it "has a waiting status" do
expect(reservation.status).to eql(Reservation::WAITING)
end

it "has an id" do
expect(reservation.id).to eql('some-id')
end

it "has a position" do
expect(reservation.position).to eql(3)
end

describe "#initialize options" do
it "requires an id key" do
expect{ Waiting.new(position: 3) }.to raise_error(KeyError)
end

it "requires a position key" do
expect{ Waiting.new(id: 'some-id') }.to raise_error(KeyError)
end
end
end
end
end

0 comments on commit 77b3bdd

Please sign in to comment.