Skip to content

Instantly share code, notes, and snippets.

@Kuz-man
Kuz-man / sample_rspec.rb
Created October 21, 2016 22:13
Task 2 tests
describe 'Hash#fetch_deep' do
input = {meal: 'musaka'}
order = {
dessert: {
type: 'cake',
variant: 'chocolate',
rating: 10,
"test" => {
t1: 15,
@Kuz-man
Kuz-man / sample_rspec.rb
Last active October 26, 2016 18:54
Challenge 2
describe '#ordinalize' do
it 'can ordinalize' do
expect(ordinalize(1)).to eq '1st'
expect(ordinalize(5)).to eq '5th'
expect(ordinalize(12)).to eq '12th'
expect(ordinalize(-11)).to eq '-11th'
expect(ordinalize(-13)).to eq '-13th'
expect(ordinalize(1)).to eq '1st'
expect(ordinalize(2)).to eq '2nd'
expect(ordinalize(3)).to eq '3rd'
@Kuz-man
Kuz-man / sample_rspec.rb
Last active October 28, 2016 18:43
Challenge 3
describe '#fibonacci_like?' do
it { expect(fibonacci_like?([0, 1, 1, 2, 3, 5, 8, 13])).to be true }
it { expect(fibonacci_like?([2, 6, 8, 14, 22, 36])).to be true }
it { expect(fibonacci_like?([0, 1, 1, 2, 3, 8])).to be false }
it { expect(fibonacci_like?([2, -1, 1, 0, 1, 1 , 2, 3])).to be true }
it { expect(fibonacci_like?([0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 45, 50])).to be false }
it { expect(fibonacci_like?([0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89])).to be true }
it { expect(fibonacci_like?([0.1, 0.1, 0.2, 0.3, 0.5, 0.8, 1.3, 2.1, 3.4, 5.5, 8.9, 14.4])).to be true }
it { expect(fibonacci_like?([-1, -1, -2, -3, -5, -8, -13, -21, -34, -55, -89])).to be true }
it { expect(fibonacci_like?([0, -1, -1, -2, -3, -5, -8, -13, -21, -34, -45, -50])).to be false }
@Kuz-man
Kuz-man / sample_rspec.rb
Created November 8, 2016 16:33
Task 03 tests
describe CommandParser do
describe '#argument' do
it 'adds an argument' do
parser = CommandParser.new('rspec')
parser.argument('FILE') do |runner, value|
runner[:file] = value
end
command_runner = {}
parser.parse(command_runner, ['spec.rb'])