File tree 3 files changed +55
-24
lines changed 3 files changed +55
-24
lines changed Original file line number Diff line number Diff line change @@ -30,4 +30,12 @@ def lost
30
30
def available?
31
31
@status == :available
32
32
end
33
+
34
+ def hold
35
+ @status = :on_hold
36
+ end
37
+
38
+ def release
39
+ @status = :available
40
+ end
33
41
end
Original file line number Diff line number Diff line change 1
- ---
2
- - !ruby/object:Book
1
+ ---
2
+ - !ruby/object:Book
3
+ title : ! ' JavaScript: The Good Parts'
3
4
author : Douglas Crockford
4
5
category : :development
5
6
status : :available
6
- title : " JavaScript: The Good Parts "
7
- - !ruby/object:Book
7
+ - !ruby/object:Book
8
+ title : Designing with Web Standards
8
9
author : Jeffrey Zeldman
9
10
category : :design
10
11
status : :available
11
- title : Designing with Web Standards
12
- - !ruby/object:Book
12
+ - !ruby/object:Book
13
+ title : Don't Make me Think
13
14
author : Steve Krug
14
15
category : :usability
15
16
status : :available
16
- title : Don't Make me Think
17
- - !ruby/object:Book
17
+ - !ruby/object:Book
18
+ title : JavaScript Patterns
18
19
author : Stoyan Stefanov
19
20
category : :development
20
21
status : :available
21
- title : JavaScript Patterns
22
- - !ruby/object:Book
22
+ - !ruby/object:Book
23
+ title : Responsive Web Design
23
24
author : Ethan Marcotte
24
25
category : :design
25
26
status : :available
26
- title : Responsive Web Design
27
- - !ruby/object:Book
27
+ - !ruby/object:Book
28
+ title : The Clean Coder
28
29
author : Uncle Bob Martin
29
30
category : :development
30
31
status : :available
31
- title : The Clean Coder
Original file line number Diff line number Diff line change 27
27
end
28
28
end
29
29
30
- describe "#checkout" do
30
+ describe "checking out a book" do
31
+ before :each do
32
+ @book . checkout
33
+ end
34
+
31
35
context "when book is available" do
32
- it "changes status to loaned" do
33
- @book . status . should eql :available
34
- @book . checkout
35
- @book . status . should eql :on_loan
36
- end
36
+ it { @book . status . should eql :on_loan }
37
37
end
38
38
context "when book is not available" do
39
- it "raises an error" do
40
- @book . checkout
41
- @book . status . should eql :on_loan
42
- lambda { @book . checkout } . should raise_error
43
- end
39
+ it { lambda { @book . checkout } . should raise_error }
44
40
end
45
41
end
46
42
60
56
end
61
57
end
62
58
end
59
+
63
60
64
61
describe "#lost" do
65
62
it "changes status to lost" do
71
68
describe "when a book is available" do
72
69
it { @book . should be_available }
73
70
end
71
+
72
+ describe "placeing a book on hold" do
73
+ before :each do
74
+ @book . hold
75
+ end
76
+
77
+ context "the book is available" do
78
+ it "should change status to on hold" do
79
+ @book . status . should == :on_hold
80
+ end
81
+ end
82
+ end
83
+
84
+ describe "when removing a book from hold" do
85
+ before :each do
86
+ @book . hold
87
+ @book . release
88
+ end
89
+
90
+ context "the book is on hold" do
91
+ it "should change status to available" do
92
+ @book . status . should == :available
93
+ end
94
+ end
95
+ end
96
+
74
97
end
You can’t perform that action at this time.
0 commit comments