This file contains 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 Price | |
attr_reader :price_code | |
def get_price_code | |
@price_code | |
end | |
def get_charge(days_rented) | |
# To implement in the subclass | |
raise NotImplemeted |
This file contains 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 File.join(File.dirname(__FILE__), 'refactoring_example.rb') | |
describe Price do | |
let(:prices) do | |
{ | |
:regular => RegularPrice.new, | |
:new_release => NewReleasePrice.new, | |
:children => ChildrenPrice.new, | |
} | |
end |
This file contains 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 Fixnum | |
def to_roman | |
return '' unless self < 5000 | |
roman_thousands(self) << roman_hundreds(self) << roman_tens(self) << roman_units(self) | |
end | |
private | |
def roman_units(unit) |
This file contains 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 'roman_number' | |
describe Fixnum, "Roman Number" do | |
context "when try to convert a number" do | |
io_expections = { | |
0 => '', | |
1 => 'I', | |
2 => 'II', |
This file contains 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 Game | |
def initialize | |
@rolls = Array.new(21) {0} | |
@current_roll = 0 | |
end | |
def roll(pins) | |
@rolls[@current_roll] = pins | |
@current_roll += 1 | |
end |
This file contains 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 File.join(File.dirname(__FILE__), 'kata_bowling_game.rb') | |
describe Game, "Bowling main game class" do | |
let(:game) { Game.new } | |
def rolls_many(n, pins) | |
n.times { game.roll pins } | |
end | |
def rolls_spare |
This file contains 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 StringCalculator | |
attr_reader :array_numbers | |
def add(string) | |
return 0 if string == '' | |
@array_numbers = extract_array_of_numbers_from string | |
raise "negative not allowed #{negative_numbers.to_s}" if negative_numbers.size > 0 | |
This file contains 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 File.join(File.dirname(__FILE__), 'string_calculator.rb') | |
describe StringCalculator do | |
context "sum with an empty string" do | |
it "returns zero" do | |
subject.add("").should == 0 | |
end | |
end | |
context "sum with a string that contains one number" do |
This file contains 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
-----BEGIN RSA PRIVATE KEY----- | |
MIIEpAIBAAKCAQEA1OPvqP1NzRSrTRPEWp0E8ja21coB2xVGqEhONTAI33Zw576v | |
zAc4G0PWZbqtTOf4oZR7GUt9fHq1dMIn6O6OqBmi79GxhKBFIYQ+62MTAtc/Vy1I | |
Pk88YMATekn8Ir2qXo8zrzF2ujPjT7f1JhUvT0w+gRgGDdnfEREL0N2eWUmUcX6e | |
hvvSHgeEX6DsKVLhzhfF55nAKy/cKiTjhlHCiInPEUb4J4pJaK/Y0lu2RaB7GECO | |
Fnc7KA+IW/2UK29ZYPoVxsnIQAas6krPLUKi7qfK0WS3x0kBpIY1t+wYtw7uZIKl | |
s78X/8kGCHVrnazc9Sx1FUsVxShtU5hM6yDAewIDAQABAoIBAGhlpn8OSHrLKf3Q | |
NbfhzC0jG6HXP/W5hz66xm9asN80a8WZQwggeikUqSyV0KooD0rdT0hmNpE2c4lg | |
NMYLRjW07KwB/rV1CrGW8mvn18jK2Src79JudMNVLbgIU/aNX+CjBMtizEAfddb/ | |
9N3KAbs3Pmd76mwcbUEnRM4V/7L0dximA27deWA05UIE1t686x/bSAWXmvXFo9xr |
OlderNewer