Skip to content

Instantly share code, notes, and snippets.

@juliends
Created October 16, 2019 14:57
Show Gist options
  • Save juliends/4455c418a67b8051f9d0df578c157850 to your computer and use it in GitHub Desktop.
Save juliends/4455c418a67b8051f9d0df578c157850 to your computer and use it in GitHub Desktop.
require_relative "../citizen"
describe Citizen do
describe "can vote" do
it "should return true for a major citizen" do
citizen = Citizen.new("", "", 25)
expect(citizen.can_vote?).to eq(true)
end
it "should return false for a minor citizen" do
citizen = Citizen.new("", "", 10)
expect(citizen.can_vote?).to eq(false)
end
end
describe "full name" do
it "should return the full name" do
citizen = Citizen.new("Boris", "Paillard", 33)
expect(citizen.full_name).to eq("Boris Paillard")
end
end
end
require_relative "../slot_machine"
describe SlotMachine do
slot_machine = SlotMachine.new
p slot_machine
it "should return 50 for Joker * 3" do
expect(slot_machine.score(%w(joker joker joker))).to eq(50)
end
it "should return 40 for Star * 3" do
expect(slot_machine.score(%w(star star star))).to eq(40)
end
it "should return 30 for Bell * 3" do
expect(slot_machine.score(%w(bell bell bell))).to eq(30)
end
it "should return 20 for Seven * 3" do
expect(slot_machine.score(%w(seven seven seven))).to eq(20)
end
it "should return 10 for Cherry * 3" do
expect(slot_machine.score(%w(cherry cherry cherry))).to eq(10)
end
it "should return 25 for Joker * 2" do
expect(slot_machine.score(%w(joker cherry joker))).to eq(25)
end
it "should return 20 for Star * 2" do
expect(slot_machine.score(%w(star star joker))).to eq(20)
end
it "should return 0 for 3 different reels" do
expect(slot_machine.score(%w(star cherry joker))).to eq(0)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment