Skip to content

Instantly share code, notes, and snippets.

View Oceantidote's full-sized avatar

Leonard Percival Oceantidote

View GitHub Profile
require_relative "../slot_machine"
def test_scenario(reels, expected_score)
it "should return a score of #{expected_score} for #{reels[0]}, #{reels[1]}, #{reels[2]}" do
score = SlotMachine.new.score(reels)
expect(score).to eq(expected_score)
end
end
describe SlotMachine do
class SlotMachine
SLOTS = %w[cherry seven bell star joker]
SCORES = { cherry: 1, seven: 2, bell: 3, star: 4, joker: 5 }
def score(reels)
if reels.uniq.length == 1
return (SLOTS.index(reels[0]) + 1) * 10
elsif reels.uniq.size == 2 && reels.include?('joker')
return (SLOTS.index(reels.sort[1]) + 1) * 5
require_relative "models/patient"
require_relative "models/room"
require_relative "repositories/patient_repository"
require_relative "repositories/room_repository"
require "pry-byebug"
room_repo = RoomRepository.new("data/rooms.csv")
repo = PatientRepository.new("data/patients.csv", room_repo)
require_relative "models/patient"
require_relative "models/room"
require_relative "repositories/patient_repository"
require_relative "repositories/room_repository"
require "pry-byebug"
room_repo = RoomRepository.new("data/rooms.csv")
repo = PatientRepository.new("data/patients.csv", room_repo)
class Patient
attr_reader :name, :cured
attr_accessor :room, :id
def initialize(attributes = {})
@id = attributes[:id]
@name = attributes[:name]
@cured = attributes[:cured] || false
end
require "pry-byebug"
require 'csv'
require_relative "../models/patient"
class PatientRepository
def initialize(csv_file_path, room_repo)
@room_repo = room_repo
@csv_file_path = csv_file_path
@patients = []
load_csv
require_relative "../acronymize"
describe "#acronymize" do
it "return an empty string when passed an empty string" do
result = acronymize("")
expect(result).to eq("")
end
it "should return an acronymized version of a lowercased sentence" do
result = acronymize("national baskebal association")
def acronymize(string)
if string.class == String
string.split(" ").map { |word| word[0].upcase }.join
else
raise Exception.new("Must provide a string")
end
end
musicians = ["paul", "simon", "ringo"]
def method(parameter)
puts "#{parameter}"
end
# block multi line
require_relative "../animal"
describe Animal do
# SPECIFIY THE CLASS WE WANT TO TEST
describe "#initialize" do
# SPECIFY METHOD WE WANT TO TEST
it "creates an instance of animal" do
# DESCRIBE WHAT THE METHOD SHOULD DO
animal = Animal.new("babe")