This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Patient | |
attr_reader :name, :cured | |
attr_accessor :room, :id | |
def initialize(attributes = {}) | |
@id = attributes[:id] | |
@name = attributes[:name] | |
@cured = attributes[:cured] || false | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
musicians = ["paul", "simon", "ringo"] | |
def method(parameter) | |
puts "#{parameter}" | |
end | |
# block multi line |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |