#Rspec
passing tests
important to understand what the test is asking
refer to spec
refer to helpers.rb
describe - example group
context - scenario
it - example
expect - the test
model spec
RSpec.describe CardDeck, :type => :model do
describe "#shuffle" do
it "returns a shuffled array of cards" do
expect(@card_deck.shuffle).to be_an Array
shuffled_cards = @card_deck.shuffle.map(&:face)
expect(shuffled_cards).to match_array sorted_cards
expect(shuffled_cards).not_to eq sorted_cards
end
it "permanently updates the order of cards in @cards" do
shuffled_cards = @card_deck.shuffle.map(&:face)
expect(@card_deck.cards.map(&:face)).to eq shuffled_cards
end
end
before
let
subject
Use subject in the group scope to explicitly define the value that is
returned by the subject method in the example scope.