From c7e05d2a9d9aa5987a723968dfa15870a168c25d Mon Sep 17 00:00:00 2001 From: Patil Varvarian Date: Wed, 6 Nov 2013 17:15:49 -0800 Subject: [PATCH 1/5] Page structure --- adv.rb | 6 ++++ adventure.rb | 35 --------------------- config/database.yml.sample | 6 ---- db/migrate/001_creates_page.rb | 18 +++++------ db/setup.rb | 2 +- models/book.rb | 20 +----------- models/page.rb | 19 ++++++++---- spec/book_spec.rb | 33 -------------------- spec/page_spec.rb | 56 +++++++++++++++------------------- spec/spec_helper.rb | 5 --- 10 files changed, 55 insertions(+), 145 deletions(-) create mode 100644 adv.rb delete mode 100644 adventure.rb delete mode 100644 config/database.yml.sample diff --git a/adv.rb b/adv.rb new file mode 100644 index 0000000..9378ce6 --- /dev/null +++ b/adv.rb @@ -0,0 +1,6 @@ +require 'rubygems' +require 'bundler/setup' + +require_relative 'db/setup' + +puts 'sanity check ' \ No newline at end of file diff --git a/adventure.rb b/adventure.rb deleted file mode 100644 index d65f616..0000000 --- a/adventure.rb +++ /dev/null @@ -1,35 +0,0 @@ -require 'rubygems' -require 'bundler/setup' - -require_relative 'db/setup' -require_relative 'models/page' -require_relative 'models/book' - -page = Page.create(starting_point: true, content: "You wake up on a road. It's foggy and dampy. In your bag is 30 gold pieces and a bacon sandwich. Which do you choose?") -Page.create(conclusion: true, parent_id: page.id, content: "Go into the forest") -Page.create(conclusion: true, parent_id: page.id, content: "Walk down the road") - -book = Book.new(page) - -until book.complete_game? do - puts book.current_page.content - puts "your options: " - puts " - [#{book.current_page.options.first.content}]" - puts " - [#{book.current_page.options.last.content}]" - puts "What do you want to do? Enter A or B" - - book.input( gets ) - -end -puts "------------------------------------------" -puts "| |" -puts "| |" -puts "| ADVENTURE COMPLETE |" -puts "| |" -puts "| |" -puts "------------------------------------------" - - -puts book.current_page.content - -puts "hope you won!" diff --git a/config/database.yml.sample b/config/database.yml.sample deleted file mode 100644 index 2e5c2a9..0000000 --- a/config/database.yml.sample +++ /dev/null @@ -1,6 +0,0 @@ -host: 'localhost' -adapter: 'postgresql' -database: 'episode5' -username: XXXXXXX -encoding: 'utf8' -pool: 5 diff --git a/db/migrate/001_creates_page.rb b/db/migrate/001_creates_page.rb index 8a293c0..058f2d7 100644 --- a/db/migrate/001_creates_page.rb +++ b/db/migrate/001_creates_page.rb @@ -1,10 +1,10 @@ class CreatesPage < ActiveRecord::Migration - def change - create_table :pages do |t| - t.text :content - t.integer :parent_id - t.boolean :starting_point, default: false - t.boolean :conclusion, default: false - end - end -end + def change + create_table :pages do |t| + t.text :content + t.integer :parent_id + t.boolean :starting_point, default: false + t.boolean :conclusion, default: false + end + end +end \ No newline at end of file diff --git a/db/setup.rb b/db/setup.rb index 0e80690..1cbf7ce 100644 --- a/db/setup.rb +++ b/db/setup.rb @@ -12,4 +12,4 @@ # connect to it ActiveRecord::Base.establish_connection(connection_details) # Migrate all the things -ActiveRecord::Migrator.migrate("db/migrate/") +ActiveRecord::Migrator.migrate("db/migrate/") \ No newline at end of file diff --git a/models/book.rb b/models/book.rb index 5eb6f53..8f59cc5 100644 --- a/models/book.rb +++ b/models/book.rb @@ -1,21 +1,3 @@ class Book - attr_reader :current_page - - def initialize(starting_page) - @current_page = starting_page - end - - def input(input_string) - if input_string.chomp == "A" - @current_page = current_page.options.first - elsif input_string.chomp == "B" - @current_page = current_page.options.last - end - end - - def complete_game? - current_page.conclusion? - end - -end +end \ No newline at end of file diff --git a/models/page.rb b/models/page.rb index 2b88343..0233a8e 100644 --- a/models/page.rb +++ b/models/page.rb @@ -1,11 +1,18 @@ class Page < ActiveRecord::Base - def self.starting_point - Page.where(starting_point: true).first - end + +def self.starting_point + Page.where(starting_point: true).first +end + - def options - Page.where(:parent_id => id).limit(2) - end + def options + Page.where(:parent_id => id).limit(2) + end + def end_of_road? + conclusion? + end end + + diff --git a/spec/book_spec.rb b/spec/book_spec.rb index b429112..e69de29 100644 --- a/spec/book_spec.rb +++ b/spec/book_spec.rb @@ -1,33 +0,0 @@ -require_relative "spec_helper" - -describe Book do - let!(:page) {Page.create(starting_point: true)} - subject { Book.new(page) } - - it "should have a page" do - subject.current_page.should eq(page) - end - - describe "#input" do - let!(:option_a) { Page.create(parent_id: page.id)} - let!(:option_b) { Page.create(parent_id: page.id)} - - it "should receive input and opens page" do - subject.input("A") - subject.current_page.should eq(option_a) - end - it "should receive input and opens page" do - subject.input("B") - subject.current_page.should eq(option_b) - end - - end - - describe "#complete_game?" do - - it "should know when it's done" do - subject.stub(:current_page) { stub(:conclusion? => true)} - subject.complete_game?.should be_true - end - end -end diff --git a/spec/page_spec.rb b/spec/page_spec.rb index 5951cdd..21394c1 100644 --- a/spec/page_spec.rb +++ b/spec/page_spec.rb @@ -1,43 +1,37 @@ -require_relative "spec_helper" +require "rspec" +require 'bundler/setup' +require_relative '../db/setup' +require_relative "../models/page" describe Page do - before(:each) do - Page.delete_all - end - - it "should know if it's at the end of the road" do - page = Page.create(conclusion: true) - page.conclusion?.should be_true + it "should know it's at the end of the road" do + subject.conclusion = true + subject.end_of_road?.should eq(true) end it "should have awesome content" do page = Page.create(content: "The fox and hound get along") Page.find(page.id).content.should eq("The fox and hound get along") - end + end - context "#options" do + 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) } - - it "should have options for the next pages" do - subject.options.should eq([option_a, option_b]) - end - end - - it "should not be a starting point by default" do - Page.create.starting_point.should eq(false) - end - it "should not be a conclusion by default" do - Page.create.conclusion.should eq(false) - end - - - it "should have a starting point" do - the_page = Page.create(starting_point: true) - Page.starting_point.should eq(the_page) - end + let(:option_a) {Page.create(parent_id: subject.id)} + let(:option_b) {Page.create(parent_id: subject.id)} + let(:option_c) {Pate.create(parent_id: subject.id)} + + it "should have options for the next pages" do + subject.options.should eq([option_a, option_b]) + end + end + + it "should have a starting point by default" do + Page.create.starting_point.should eq(false) + end + it "should not be a conclusion by default" do + Page.create.conclusion.should eq(false) + end end + diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index bdb95b8..e69de29 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,5 +0,0 @@ -require "rspec" -require 'bundler/setup' -require_relative '../db/setup' -require_relative "../models/page" -require_relative "../models/book" From 9fee571fc69b1460ddd564457a27657f4b9eae3b Mon Sep 17 00:00:00 2001 From: Patil Varvarian Date: Thu, 7 Nov 2013 10:58:06 -0800 Subject: [PATCH 2/5] Book structure --- db/migrate/001_creates_page.rb | 13 +++++++------ models/book.rb | 18 ++++++++++++++++++ models/page.rb | 5 +---- spec/book_spec.rb | 34 ++++++++++++++++++++++++++++++++++ spec/page_spec.rb | 29 ++++++++++++++++++++--------- spec/spec_helper.rb | 5 +++++ 6 files changed, 85 insertions(+), 19 deletions(-) diff --git a/db/migrate/001_creates_page.rb b/db/migrate/001_creates_page.rb index 058f2d7..0b98bcb 100644 --- a/db/migrate/001_creates_page.rb +++ b/db/migrate/001_creates_page.rb @@ -1,10 +1,11 @@ class CreatesPage < ActiveRecord::Migration def change - create_table :pages do |t| - t.text :content - t.integer :parent_id - t.boolean :starting_point, default: false - t.boolean :conclusion, default: false + create_table :pages do |t| + t.text :content + t.integer :parent_id + t.boolean :starting_point, default: false + t.boolean :conclusion, default: false end end -end \ No newline at end of file +end + diff --git a/models/book.rb b/models/book.rb index 8f59cc5..a2d5112 100644 --- a/models/book.rb +++ b/models/book.rb @@ -1,3 +1,21 @@ class Book + attr_reader :current_page + + def initialize(starting_page) + @current_page = starting_page + end + + def input(input_string) + if input_string.chomp == "A" + @current_page = current_page.options.first + elsif input_string.chomp == "B" + @current_page = current_page.options.last + end + end + + def complete_game? + current_page.conclusion? + + end end \ No newline at end of file diff --git a/models/page.rb b/models/page.rb index 0233a8e..b345924 100644 --- a/models/page.rb +++ b/models/page.rb @@ -2,7 +2,7 @@ class Page < ActiveRecord::Base def self.starting_point - Page.where(starting_point: true).first + Page.where(starting_point: true).first end @@ -10,9 +10,6 @@ def options Page.where(:parent_id => id).limit(2) end - def end_of_road? - conclusion? - end end diff --git a/spec/book_spec.rb b/spec/book_spec.rb index e69de29..10a4f21 100644 --- a/spec/book_spec.rb +++ b/spec/book_spec.rb @@ -0,0 +1,34 @@ +require_relative "spec_helper" + +describe Book do + let!(:page) {Page.create(starting_point: true)} + subject { Book.new(page) } + + it "should have a page" do + subject.current_page.should eq(page) + end + + describe "#input" do + let!(:option_a) {Page.create(parent_id: page.id)} + let!(:option_b) {Page.create(parent_id: page.id)} + + it "should receive input and opens page" do + subject.input("A") + subject.current_page.should eq(option_a) + end + it "should receive input and opens page" do + subject.input("B") + subject.current_page.should eq(option_b) + end + +end + +describe "#complete_game?" do + let!(:page) {Page.create(starting_point: true)} + subject { Book.new(page) } + it "should know when it's done" do + subject.stub(:current_page) { stub(:conclusion? => true)} + subject.complete_game?.should be_true + end + end +end \ No newline at end of file diff --git a/spec/page_spec.rb b/spec/page_spec.rb index 21394c1..d25e434 100644 --- a/spec/page_spec.rb +++ b/spec/page_spec.rb @@ -1,13 +1,15 @@ -require "rspec" -require 'bundler/setup' -require_relative '../db/setup' -require_relative "../models/page" +require_relative "spec_helper" describe Page do + before(:each) do + Page.delete_all + end + it "should know it's at the end of the road" do - subject.conclusion = true - subject.end_of_road?.should eq(true) + page = Page.create(conclusion: true) + page.conclusion?.should be_true + end it "should have awesome content" do @@ -17,9 +19,9 @@ 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) {Pate.create(parent_id: subject.id)} + 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) } it "should have options for the next pages" do subject.options.should eq([option_a, option_b]) @@ -29,9 +31,18 @@ it "should have a starting point by default" do Page.create.starting_point.should eq(false) end + it "should not be a conclusion by default" do Page.create.conclusion.should eq(false) end + it "should have a starting point" do + the_page = Page.create(starting_point: true) + Page.starting_point.should eq(the_page) + + end end + + + \ No newline at end of file diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index e69de29..0cf24dc 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -0,0 +1,5 @@ +require "rspec" +require 'bundler/setup' +require_relative '../db/setup' +require_relative "../models/page" +require_relative "../models/book" From 6251bade72d0c85df39398c9981eacf4489dbf63 Mon Sep 17 00:00:00 2001 From: Patil Varvarian Date: Mon, 11 Nov 2013 14:20:27 -0800 Subject: [PATCH 3/5] Just Panda --- adv.rb | 30 +++++++++++++++++++++++++++++- db/migrate/001_creates_page.rb | 5 ++++- db/seed.rb | 12 +++++++++++- models/book.rb | 1 + 4 files changed, 45 insertions(+), 3 deletions(-) diff --git a/adv.rb b/adv.rb index 9378ce6..095262e 100644 --- a/adv.rb +++ b/adv.rb @@ -2,5 +2,33 @@ require 'bundler/setup' require_relative 'db/setup' +Dir.glob('./models/*').each { |r| require r} +require "./db/seed" +#require_relative 'models/page' +#require_relative 'models/book' -puts 'sanity check ' \ No newline at end of file + +page = Page.create(starting_point: true, preview: 'Adventure road', content: "you wake up on a road. + It's foggy and dampy. In your bag is 30 gold pieces and bacon sandwich. + Which do you choose?") + +Page.create(conclusion: true, parent_id: page.id, preview: "Go into the Forest", content: "Omg...you just won 30 bags of gold: WINNER") +Page.create(conclusion: true, parent_id: page.id, preview: "Sail across the River", content: "Shat...you just got ripped to pieces by a clan of hungry paranas. LOSER") + + + +book = Book.new(page) + +until book.complete_game? do + puts book.current_page.content + puts "your options: " + puts " - [#{book.current_page.options.first.preview}]" + puts " - [#{book.current_page.options.last.preview}]" + puts "What do you want to do? Enter A or B" + + book.input( gets ) +end + +puts book.current_page.content + +puts book.current_page.conclusion diff --git a/db/migrate/001_creates_page.rb b/db/migrate/001_creates_page.rb index 0b98bcb..b9021f2 100644 --- a/db/migrate/001_creates_page.rb +++ b/db/migrate/001_creates_page.rb @@ -1,11 +1,14 @@ class CreatesPage < ActiveRecord::Migration def change create_table :pages do |t| + t.text :preview t.text :content - t.integer :parent_id + t.integer :parent_id t.boolean :starting_point, default: false t.boolean :conclusion, default: false end + end + end diff --git a/db/seed.rb b/db/seed.rb index 1abe902..7e1e4c7 100644 --- a/db/seed.rb +++ b/db/seed.rb @@ -1 +1,11 @@ -# Cleaning Out + + +page = Page.create(starting_point: true, content: "you wake up on a road. + It's foggy and dampy. In your bag is 30 gold pieces and bacon sandwich. + Whihc do you choose?") + + Page.create(conclusion: true, parent_id: page.id, content: "WINNER") + Page.create(conclusion: true, parent_id: page.id, content: "LOSER") + + # N/A turn the 'your options' into a string. + diff --git a/models/book.rb b/models/book.rb index a2d5112..3e0ddf5 100644 --- a/models/book.rb +++ b/models/book.rb @@ -9,6 +9,7 @@ def initialize(starting_page) def input(input_string) if input_string.chomp == "A" @current_page = current_page.options.first + elsif input_string.chomp == "B" @current_page = current_page.options.last end From fb26385eaa2a7c28167e81c98f67ef33fdc821c4 Mon Sep 17 00:00:00 2001 From: Patil Varvarian Date: Mon, 11 Nov 2013 18:32:33 -0800 Subject: [PATCH 4/5] Panda, Tiger --- adv.rb | 8 +------- db/migrate/001_creates_page.rb | 4 +--- db/seed.rb | 15 +++++++++------ models/book.rb | 1 - models/page.rb | 5 ++--- 5 files changed, 13 insertions(+), 20 deletions(-) diff --git a/adv.rb b/adv.rb index 095262e..e1cb4df 100644 --- a/adv.rb +++ b/adv.rb @@ -8,17 +8,11 @@ #require_relative 'models/book' -page = Page.create(starting_point: true, preview: 'Adventure road', content: "you wake up on a road. - It's foggy and dampy. In your bag is 30 gold pieces and bacon sandwich. - Which do you choose?") -Page.create(conclusion: true, parent_id: page.id, preview: "Go into the Forest", content: "Omg...you just won 30 bags of gold: WINNER") -Page.create(conclusion: true, parent_id: page.id, preview: "Sail across the River", content: "Shat...you just got ripped to pieces by a clan of hungry paranas. LOSER") +book = Book.new(Page.starting_point) -book = Book.new(page) - until book.complete_game? do puts book.current_page.content puts "your options: " diff --git a/db/migrate/001_creates_page.rb b/db/migrate/001_creates_page.rb index b9021f2..3513934 100644 --- a/db/migrate/001_creates_page.rb +++ b/db/migrate/001_creates_page.rb @@ -6,9 +6,7 @@ def change t.integer :parent_id t.boolean :starting_point, default: false t.boolean :conclusion, default: false - end - + end end - end diff --git a/db/seed.rb b/db/seed.rb index 7e1e4c7..7fa1d7f 100644 --- a/db/seed.rb +++ b/db/seed.rb @@ -1,11 +1,14 @@ +Page.delete_all +page = Page.create(starting_point: true, preview: 'Adventure road', content: "you wake up on a road. + It's foggy and dampy. In your bag is 30 gold pieces and bacon sandwich. Which do you choose?") +Page.create(conclusion: true, parent_id: page.id, preview: "Go into the Forest", content: "Omg...you just won 30 bags of gold: WINNER") +Page.create(conclusion: true, parent_id: page.id, preview: "Sail across the River", content: "Shat...you just got ripped to pieces by a clan of hungry paranas. LOSER") -page = Page.create(starting_point: true, content: "you wake up on a road. - It's foggy and dampy. In your bag is 30 gold pieces and bacon sandwich. - Whihc do you choose?") +#forrest = Page.create(conclusion: true, id: forrest.id, preview: '', content '') - Page.create(conclusion: true, parent_id: page.id, content: "WINNER") - Page.create(conclusion: true, parent_id: page.id, content: "LOSER") - # N/A turn the 'your options' into a string. + + +#id: forrest.id \ No newline at end of file diff --git a/models/book.rb b/models/book.rb index 3e0ddf5..a2d5112 100644 --- a/models/book.rb +++ b/models/book.rb @@ -9,7 +9,6 @@ def initialize(starting_page) def input(input_string) if input_string.chomp == "A" @current_page = current_page.options.first - elsif input_string.chomp == "B" @current_page = current_page.options.last end diff --git a/models/page.rb b/models/page.rb index b345924..262a924 100644 --- a/models/page.rb +++ b/models/page.rb @@ -9,7 +9,6 @@ def self.starting_point def options Page.where(:parent_id => id).limit(2) end - +# limit(5) +# index the pages. instead of doing first/last end - - From 74936da3c603956e105d37747e5841c375e3159c Mon Sep 17 00:00:00 2001 From: Patil Varvarian Date: Wed, 13 Nov 2013 16:29:24 -0800 Subject: [PATCH 5/5] panda, tiger, eagle --- adv.rb | 15 ++++----------- db/migrate/001_creates_page.rb | 2 ++ db/seed.rb | 17 +++++++---------- models/book.rb | 1 - models/page.rb | 12 ++++-------- spec/book_spec.rb | 7 +++---- spec/page_spec.rb | 9 ++++----- 7 files changed, 24 insertions(+), 39 deletions(-) diff --git a/adv.rb b/adv.rb index e1cb4df..1813803 100644 --- a/adv.rb +++ b/adv.rb @@ -4,25 +4,18 @@ require_relative 'db/setup' Dir.glob('./models/*').each { |r| require r} require "./db/seed" -#require_relative 'models/page' -#require_relative 'models/book' - - book = Book.new(Page.starting_point) - - until book.complete_game? do puts book.current_page.content puts "your options: " - puts " - [#{book.current_page.options.first.preview}]" - puts " - [#{book.current_page.options.last.preview}]" + puts " - #{book.current_page.options.first.preview}" + puts " - #{book.current_page.options.last.preview}" puts "What do you want to do? Enter A or B" book.input( gets ) end - puts book.current_page.content - -puts book.current_page.conclusion +puts '' +puts 'Maybe you can come back again if you\'re not too rich or too dead. Hope you had fun.' \ No newline at end of file diff --git a/db/migrate/001_creates_page.rb b/db/migrate/001_creates_page.rb index 3513934..abcd9d0 100644 --- a/db/migrate/001_creates_page.rb +++ b/db/migrate/001_creates_page.rb @@ -4,6 +4,8 @@ def change t.text :preview t.text :content t.integer :parent_id + t.integer :option_a_id + t.integer :option_b_id t.boolean :starting_point, default: false t.boolean :conclusion, default: false end diff --git a/db/seed.rb b/db/seed.rb index 7fa1d7f..a0f9bd3 100644 --- a/db/seed.rb +++ b/db/seed.rb @@ -1,14 +1,11 @@ Page.delete_all -page = Page.create(starting_point: true, preview: 'Adventure road', content: "you wake up on a road. - It's foggy and dampy. In your bag is 30 gold pieces and bacon sandwich. Which do you choose?") -Page.create(conclusion: true, parent_id: page.id, preview: "Go into the Forest", content: "Omg...you just won 30 bags of gold: WINNER") -Page.create(conclusion: true, parent_id: page.id, preview: "Sail across the River", content: "Shat...you just got ripped to pieces by a clan of hungry paranas. LOSER") +steady = Page.create(conclusion: true, preview: 'You move forward', + content: 'You crash a secret conference of top teer venture capitalist. They like you so much they give you some pocket change. 30 bags of gold: WINNER') +sleep = Page.create(conclusion: true, preview: 'You lay down for a power nap', + content: 'A clan of dwarfs adopt you and name you sleepy. Unfortunately that very day grumpy\'s new pick-ax arrives from Amazon and you loose your head: LOSER') +forest = Page.create(option_a_id: steady.id, option_b_id: sleep.id, preview: "Go into the Forest", content: "You see smoke in the distance.") +lake = Page.create(option_a_id: steady.id, option_b_id: sleep.id, preview: "Sail across the Lake", content: "You begin to hear music in the distance.") +page = Page.create(starting_point: true, option_a_id: forest.id, option_b_id: lake.id, preview: "Welcome subjects", content: "You wake up on a road. It's foggy and dampy. In your bag is 30 gold pieces and a bacon sandwich. Which do you choose?") -#forrest = Page.create(conclusion: true, id: forrest.id, preview: '', content '') - - - - -#id: forrest.id \ No newline at end of file diff --git a/models/book.rb b/models/book.rb index a2d5112..1b04653 100644 --- a/models/book.rb +++ b/models/book.rb @@ -16,6 +16,5 @@ def input(input_string) def complete_game? current_page.conclusion? - end end \ No newline at end of file diff --git a/models/page.rb b/models/page.rb index 262a924..f440d9b 100644 --- a/models/page.rb +++ b/models/page.rb @@ -1,14 +1,10 @@ class Page < ActiveRecord::Base - -def self.starting_point - Page.where(starting_point: true).first -end - + def self.starting_point + Page.where(starting_point: true).first + end def options - Page.where(:parent_id => id).limit(2) + Page.find(option_a_id, option_b_id) end -# limit(5) -# index the pages. instead of doing first/last end diff --git a/spec/book_spec.rb b/spec/book_spec.rb index 10a4f21..bcb3f53 100644 --- a/spec/book_spec.rb +++ b/spec/book_spec.rb @@ -1,7 +1,9 @@ require_relative "spec_helper" describe Book do - let!(:page) {Page.create(starting_point: true)} + let!(:option_a) {Page.create(preview: 'view option_a')} + let!(:option_b) {Page.create(preview: 'view option_b')} + let!(:page) {Page.create(starting_point: true, option_a_id: option_a.id, option_b_id: option_b.id)} subject { Book.new(page) } it "should have a page" do @@ -9,8 +11,6 @@ end describe "#input" do - let!(:option_a) {Page.create(parent_id: page.id)} - let!(:option_b) {Page.create(parent_id: page.id)} it "should receive input and opens page" do subject.input("A") @@ -20,7 +20,6 @@ subject.input("B") subject.current_page.should eq(option_b) end - end describe "#complete_game?" do diff --git a/spec/page_spec.rb b/spec/page_spec.rb index d25e434..172a03f 100644 --- a/spec/page_spec.rb +++ b/spec/page_spec.rb @@ -18,13 +18,12 @@ 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(preview: "Option_a view") } + let(:option_b) {Page.create(preview: "Option_b view") } + 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]) + subject.options.should eq([option_a, option_b]) end end