-
Notifications
You must be signed in to change notification settings - Fork 21
Panda Level: add a preview and an outcome to the page #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 4 commits
fc8126d
ef1b1fc
7fde057
a724944
abb45b3
85a8007
b757449
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| -- color --format progress |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,29 @@ | ||
| # Cleaning Out | ||
| Page.delete_all | ||
| page_two = Page.create(conclusion: true, | ||
| preview: "Go into the forest", | ||
| outcome: "You were methodically consumed by ZOMBIE DEER!!!", | ||
| content: "As soon as you stepped off the road, darkness consumed you. You tripped, fell to the ground, and a hoard of zombie deer proceeded to gobble you up.") | ||
| page_three = Page.create(conclusion: true, | ||
| preview: "Walk down the road", | ||
| outcome: "You found the circle of life (can be traded at Trapper's Den for 2 gold pieces)!", | ||
| content: "Apparently, after receiving it from his father, Simba dropped the circle of life while chasing a zombie deer.") | ||
| page_six = Page.create(option_a_id: page_two.id, | ||
| option_b_id: page_three.id, | ||
| preview: "Take a moment and taste the bacon fat in your mouth", | ||
| outcome: "Your spirits are lifted and you are ready to take on the world!", | ||
| content: "Armed with the power to take on the known world, you set forth.") | ||
| page_four = Page.create(option_a_id: page_six.id, | ||
| option_b_id: page_two.id, | ||
| preview: "Admire the 30 gold pieces", | ||
| outcome: "You were ransacked and robbed by a hoard of geriatric orcs!", | ||
| content: "They came at you slow, but because you were sucked into the glow of the gold you didn't notice 3 old orcs guided by walkers(with the little tennis balls on the fronts). You eat the bacon sandwich.") | ||
| page_five = Page.create(option_a_id: page_two.id, | ||
| option_b_id: page_six.id, | ||
| preview: "Eat the bacon sandwich", | ||
| outcome: "Your belly is happy and your mind is clear.", | ||
| content: "Obviously the only choice. Now that you've chosen wiser than Indiana Jones and the Quest For the Holy Grail, you are left with only the best decisions.") | ||
| page = Page.create(starting_point: true, | ||
| option_a_id: page_four.id, | ||
| option_b_id: page_five.id, | ||
| content: "You wake up on a road. It's foggy and damp. In your bag is 30 gold pieces and a bacon sandwich. Which do you choose?") | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,7 @@ def self.starting_point | |
| end | ||
|
|
||
| def options | ||
| Page.where(:parent_id => id).limit(2) | ||
| Page.find(option_a_id, option_b_id) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good use of find with an array :) |
||
| end | ||
|
|
||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,11 +16,20 @@ | |
| Page.find(page.id).content.should eq("The fox and hound get along") | ||
| end | ||
|
|
||
| it "should have a preview" do | ||
| page = Page.create(preview: "Walk down the road") | ||
| Page.find(page.id).preview.should eq("Walk down the road") | ||
| end | ||
|
|
||
| it "should be clear about being a winner or a loser" do | ||
| page = Page.create(outcome: "You be dead!") | ||
| Page.find(page.id).outcome.should eq("You be dead!") | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm, I would think this might read a little easier page = Page.create(outcome: "You be dead!")
page.outcome.should eq("You be dead!")Any reason to explicitly get a new object from the db?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nope... I suppose that would be bringing in details not needed.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, while there's no great harm in doing it, it might show future-you a false positive 6 months down the road. You could read, and think there was a REASON that you reloaded from the DB, when in fact it was just a thing. |
||
| end | ||
|
|
||
| context "#options" do | ||
| subject {Page.create} | ||
| let(:option_a) {Page.create(parent_id: subject.id) } | ||
| let(:option_b) {Page.create(parent_id: subject.id) } | ||
| let(:option_c) {Page.create(parent_id: subject.id) } | ||
| let(:option_a) { Page.create } | ||
| let(:option_b) { Page.create } | ||
| subject {Page.create(option_a_id: option_a.id, option_b_id: option_b.id )} | ||
|
|
||
| it "should have options for the next pages" do | ||
| subject.options.should eq([option_a, option_b]) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
page_five RULES 🤘