From the course: Ruby: Testing with RSpec
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Solution: Restaurant - Ruby Tutorial
From the course: Ruby: Testing with RSpec
Solution: Restaurant
- Hopefully you had good luck solving the restaurant challenge. Now, let me show you my solution. So in my restraurant_spec file, the first thing I did was the attributes. Notice here that I'm using the implicitly defined subject because I'm describing Restaurant, and I'm using the actual class name, not a string, then I can call subject right here and have an implicitly defined subject. So remember, that's the same thing as calling Restaurant.new with no options at all, just Restaurant.new. So, here I'm using Restaurant.new, and I'm trying to set name = "Test" and then read it back to see if I can both read and write to it. I'm doing the same thing for the cuisine and for the price. That's all there is to setting up those attributes. Just very quickly, trying to write to them, trying to read back from them, and see if I was able to succeed. So then load_file was already done for you, so we're not gonna look at that. And then the next one is the class method for all. It returns an…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
-
(Locked)
Food-finder application6m 8s
-
(Locked)
Challenge: NumberHelper5m 49s
-
(Locked)
Solution: NumberHelper3m 8s
-
(Locked)
Challenge: StringExtend2m 6s
-
(Locked)
Solution: StringExtend3m 48s
-
(Locked)
Challenge: Restaurant5m 25s
-
(Locked)
Solution: Restaurant6m 30s
-
(Locked)
Challenge: Guide12m 49s
-
(Locked)
Solution: Guide6m 41s
-
(Locked)
-
-
-
-