diff --git a/spec/deck_spec.rb b/spec/deck_spec.rb index 9447f6918..7c346f0e7 100644 --- a/spec/deck_spec.rb +++ b/spec/deck_spec.rb @@ -15,23 +15,16 @@ expect(@deck).to be_instance_of(Deck) end - it 'returns_cards' do + it 'loads cards into the deck' do expect(@deck.cards).to eq(@cards) end - it 'counts_cards' do + it 'counts the number of cards in the deck' do expect(@deck.count).to eq(3) end - it 'identifies cards in each category' do + it 'identifies all of the cards in each category' do expect(@deck.cards_in_category(:STEM)).to eq([@card_2, @card_3]) expect(@deck.cards_in_category(:Geography)).to eq([@card_1]) end - - it 'can_add_cards' do - card_4 = Card.new("What is Danielle's cat's name", "Furriosa", :Turing_students) - - expect(@deck.add_card(card_4)). to eq([@card_1, @card_2, @card_3, card_4]) - end - end diff --git a/spec/round_spec.rb b/spec/round_spec.rb index b07e567f1..357e1fe47 100644 --- a/spec/round_spec.rb +++ b/spec/round_spec.rb @@ -2,7 +2,6 @@ require './lib/turn' require './lib/deck' require './lib/round' -require 'pry' RSpec.describe Round do @@ -21,51 +20,51 @@ expect(@round).to be_instance_of(Round) end - it 'loads_deck_into_round' do + it 'loads the deck into the round' do expect(@round.deck).to eq(@deck) end - it 'starts_turns' do + it 'starts the turn with an empty turns array' do expect(@round.turns).to eq([]) end - it 'pulls_current_card' do + it 'pulls the current card in the deck' do expect(@round.current_card).to eq(@card_1) end - it 'starts_with_empty_turns_array' do - expect(@round.turns).to eq([]) - end - - it 'logs the new turn into the turns array' do + it 'logs each new turn into the turns array' do new_turn = @round.take_turn("Juneau") expect(@round.turns.last).to eq(new_turn) -# require 'pry'; binding.pry end - it 'add to number correct' do + it 'add correct answers to the number correct counter' do new_turn = @round.take_turn("Juneau") expect(@round.number_correct).to eq(1) end - it 'identifies percent correct' do + it 'identifies the percent of correct answers per round' do new_turn = @round.take_turn("Juneau") expect(@round.percent_correct).to eq(100) end - it 'identifies number of cards correct by category' do + it 'identifies the number of correct answers in the round by category' do new_turn = @round.take_turn("Juneau") -# require 'pry'; binding.pry + expect(@round.number_correct_by_category(:Geography)).to eq(1) end - it 'adds to number correct by category' do + it 'calculates the percent of correct answers in the round by category' do new_turn = @round.take_turn("Juneau") - # require 'pry'; binding.pry + expect(@round.percent_correct_by_category(:Geography)).to eq(100) end - + + it 'identifies each unique category in the round' do + new_turn = @round.take_turn("Juneau") + + expect(@round.deck.cards.map(&:category).uniq).to eq([:Geography, :STEM]) + end end \ No newline at end of file diff --git a/spec/turn_spec.rb b/spec/turn_spec.rb index 955109889..32d68f563 100644 --- a/spec/turn_spec.rb +++ b/spec/turn_spec.rb @@ -2,44 +2,43 @@ require './lib/turn' RSpec.describe Turn do + + before(:each) do + @card = Card.new("What is the capital of Alaska?", "Juneau", :Geography) + end + it 'exists' do - card = Card.new("What is the capital of Alaska?", "Juneau", :Geography) - turn = Turn.new("Juneau", card) + turn = Turn.new("Juneau", @card) expect(turn).to be_instance_of(Turn) end it 'is Juneau by default' do - card = Card.new("What is the capital of Alaska?", "Juneau", :Geography) - turn = Turn.new("Juneau", card) + turn = Turn.new("Juneau", @card) expect(turn.guess).to eq("Juneau") end it "does not have to be Juneau" do - card = Card.new("What is the capital of Alaska?", "Juneau", :Geography) - turn = Turn.new("Spain", card) + turn = Turn.new("Spain", @card) expect(turn.guess).to eq("Spain") end it 'returns the Card' do - card = Card.new("What is the capital of Alaska?", "Juneau", :Geography) - turn = Turn.new("Juneau", card) + turn = Turn.new("Juneau", @card) - expect(turn.card).to eq(card) + expect(turn.card).to eq(@card) end it 'indicates if the guess matched the answer on the card' do - card = Card.new("What is the capital of Alaska?", "Juneau", :Geography) - turn = Turn.new("Juneau", card) + turn = Turn.new("Juneau", @card) expect(turn.correct?).to eq(true) end it 'provides feedback' do - card = Card.new("What is the capital of Alaska?", "Juneau", :Geography) - turn = Turn.new("Juneau", card) + turn = Turn.new("Juneau", @card) expect(turn.feedback).to eq("Correct!") end