-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
Showing
3 changed files
with
50 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |