Михаела обнови решението на 11.01.2016 16:55 (преди около 9 години)
+class Spreadsheet
+ def initialize(value = string.new)
+ @rows = value.scan(/\n/).size + 1
+ @column = (value.scan(/\t/).size) / rows
+ end
+end
Към профила на Михаела Чуренска
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF Failures: 1) Spreadsheet#new can be called with no arguments or with a single string argument Failure/Error: Spreadsheet.new NameError: undefined local variable or method `string' for #<Spreadsheet:0x007fce14a83150> # /tmp/d20160121-5693-1qkr8mk/solution.rb:2:in `initialize' # /tmp/d20160121-5693-1qkr8mk/spec.rb:4:in `new' # /tmp/d20160121-5693-1qkr8mk/spec.rb:4:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>' 2) Spreadsheet#new creates a blank sheet when no arguments are passed Failure/Error: expect(Spreadsheet.new).to be_empty NameError: undefined local variable or method `string' for #<Spreadsheet:0x007fce14a812b0> # /tmp/d20160121-5693-1qkr8mk/solution.rb:2:in `initialize' # /tmp/d20160121-5693-1qkr8mk/spec.rb:10:in `new' # /tmp/d20160121-5693-1qkr8mk/spec.rb:10:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>' 3) Spreadsheet#new creates a blank sheet when a blank string is passed Failure/Error: expect(Spreadsheet.new('')).to be_empty NameError: undefined local variable or method `rows' for #<Spreadsheet:0x007fce14a32890 @rows=1> # /tmp/d20160121-5693-1qkr8mk/solution.rb:4:in `initialize' # /tmp/d20160121-5693-1qkr8mk/spec.rb:14:in `new' # /tmp/d20160121-5693-1qkr8mk/spec.rb:14:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>' 4) Spreadsheet#new creates a non-empty sheet when a non-blank string is passed Failure/Error: expect(Spreadsheet.new('foo')).not_to be_empty NameError: undefined local variable or method `rows' for #<Spreadsheet:0x007fce14a2be50 @rows=1> # /tmp/d20160121-5693-1qkr8mk/solution.rb:4:in `initialize' # /tmp/d20160121-5693-1qkr8mk/spec.rb:18:in `new' # /tmp/d20160121-5693-1qkr8mk/spec.rb:18:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>' 5) Spreadsheet#to_s returns blank tables as blank strings Failure/Error: expect(Spreadsheet.new.to_s).to eq '' NameError: undefined local variable or method `string' for #<Spreadsheet:0x007fce14a28700> # /tmp/d20160121-5693-1qkr8mk/solution.rb:2:in `initialize' # /tmp/d20160121-5693-1qkr8mk/spec.rb:24:in `new' # /tmp/d20160121-5693-1qkr8mk/spec.rb:24:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>' 6) Spreadsheet#to_s returns one-cell tables as a string Failure/Error: expect(Spreadsheet.new('foo').to_s).to eq 'foo' NameError: undefined local variable or method `rows' for #<Spreadsheet:0x007fce14a23b88 @rows=1> # /tmp/d20160121-5693-1qkr8mk/solution.rb:4:in `initialize' # /tmp/d20160121-5693-1qkr8mk/spec.rb:28:in `new' # /tmp/d20160121-5693-1qkr8mk/spec.rb:28:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>' 7) Spreadsheet#to_s returns multi-cell, oneline tables as a string Failure/Error: expect(Spreadsheet.new("foo\tbar\tbaz").to_s).to eq "foo\tbar\tbaz" NameError: undefined local variable or method `rows' for #<Spreadsheet:0x007fce14a21540 @rows=1> # /tmp/d20160121-5693-1qkr8mk/solution.rb:4:in `initialize' # /tmp/d20160121-5693-1qkr8mk/spec.rb:32:in `new' # /tmp/d20160121-5693-1qkr8mk/spec.rb:32:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>' 8) Spreadsheet#to_s returns multi-cell, multiline tables as a string Failure/Error: expect(Spreadsheet.new("foo\tbar\nbaz\tlarodi").to_s).to eq "foo\tbar\nbaz\tlarodi" NameError: undefined local variable or method `rows' for #<Spreadsheet:0x007fce14a1d8a0 @rows=2> # /tmp/d20160121-5693-1qkr8mk/solution.rb:4:in `initialize' # /tmp/d20160121-5693-1qkr8mk/spec.rb:36:in `new' # /tmp/d20160121-5693-1qkr8mk/spec.rb:36:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>' 9) Spreadsheet#to_s splits cells by two or more spaces Failure/Error: expect(Spreadsheet.new("foo bar 42\nbaz larodi 100").to_s).to eq "foo\tbar\t42\nbaz\tlarodi\t100" NameError: undefined local variable or method `rows' for #<Spreadsheet:0x007fce14a0bec0 @rows=2> # /tmp/d20160121-5693-1qkr8mk/solution.rb:4:in `initialize' # /tmp/d20160121-5693-1qkr8mk/spec.rb:40:in `new' # /tmp/d20160121-5693-1qkr8mk/spec.rb:40:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>' 10) Spreadsheet#to_s returns the evaluated spreadsheet as a table Failure/Error: sheet = Spreadsheet.new <<-TABLE NameError: undefined local variable or method `rows' for #<Spreadsheet:0x007fce14a07bb8 @rows=4> # /tmp/d20160121-5693-1qkr8mk/solution.rb:4:in `initialize' # /tmp/d20160121-5693-1qkr8mk/spec.rb:44:in `new' # /tmp/d20160121-5693-1qkr8mk/spec.rb:44:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>' 11) Spreadsheet#cell_at raises and exception for non-existant cells Failure/Error: expect { Spreadsheet.new('foo')['B10'] }.to raise_error(Spreadsheet::Error, /Cell 'B10' does not exist/) NameError: uninitialized constant Spreadsheet::Error # /tmp/d20160121-5693-1qkr8mk/spec.rb:59:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>' 12) Spreadsheet#cell_at returns the raw value of existing cells Failure/Error: sheet = Spreadsheet.new <<-TABLE NameError: undefined local variable or method `rows' for #<Spreadsheet:0x007fce149ba2c8 @rows=3> # /tmp/d20160121-5693-1qkr8mk/solution.rb:4:in `initialize' # /tmp/d20160121-5693-1qkr8mk/spec.rb:63:in `new' # /tmp/d20160121-5693-1qkr8mk/spec.rb:63:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>' 13) Spreadsheet#[] raises an exception for non-existant cells Failure/Error: expect { Spreadsheet.new()['A1'] }.to raise_error(Spreadsheet::Error, /Cell 'A1' does not exist/) NameError: uninitialized constant Spreadsheet::Error # /tmp/d20160121-5693-1qkr8mk/spec.rb:75:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>' 14) Spreadsheet#[] returns the value of existing cells for simple cell indexes Failure/Error: sheet = Spreadsheet.new <<-TABLE NameError: undefined local variable or method `rows' for #<Spreadsheet:0x007fce149a7470 @rows=3> # /tmp/d20160121-5693-1qkr8mk/solution.rb:4:in `initialize' # /tmp/d20160121-5693-1qkr8mk/spec.rb:79:in `new' # /tmp/d20160121-5693-1qkr8mk/spec.rb:79:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>' 15) Spreadsheet#[] returns the value of existing cells for complex cell indexes Failure/Error: sheet = Spreadsheet.new (["a#{"\tb" * 30}c"] * 20).join("\n") NameError: undefined local variable or method `rows' for #<Spreadsheet:0x007fce149a4b08 @rows=20> # /tmp/d20160121-5693-1qkr8mk/solution.rb:4:in `initialize' # /tmp/d20160121-5693-1qkr8mk/spec.rb:91:in `new' # /tmp/d20160121-5693-1qkr8mk/spec.rb:91:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>' 16) Spreadsheet#[] returns the calculated value of formulae cells Failure/Error: sheet = Spreadsheet.new "foo\tADD(2, 2)\t=ADD(2, 2)" NameError: undefined local variable or method `rows' for #<Spreadsheet:0x007fce1498d8e0 @rows=1> # /tmp/d20160121-5693-1qkr8mk/solution.rb:4:in `initialize' # /tmp/d20160121-5693-1qkr8mk/spec.rb:99:in `new' # /tmp/d20160121-5693-1qkr8mk/spec.rb:99:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>' 17) Spreadsheet#[] adds two numbers with ADD Failure/Error: sheet = Spreadsheet.new("=ADD(2, 2)") NameError: undefined local variable or method `rows' for #<Spreadsheet:0x007fce1497a330 @rows=1> # /tmp/d20160121-5693-1qkr8mk/solution.rb:4:in `initialize' # /tmp/d20160121-5693-1qkr8mk/spec.rb:107:in `new' # /tmp/d20160121-5693-1qkr8mk/spec.rb:107:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>' 18) Spreadsheet#[] adds five numbers with ADD Failure/Error: sheet = Spreadsheet.new("=ADD(1, 2, 3, 4, 5)") NameError: undefined local variable or method `rows' for #<Spreadsheet:0x007fce14977ef0 @rows=1> # /tmp/d20160121-5693-1qkr8mk/solution.rb:4:in `initialize' # /tmp/d20160121-5693-1qkr8mk/spec.rb:113:in `new' # /tmp/d20160121-5693-1qkr8mk/spec.rb:113:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>' 19) Spreadsheet#[] raises an exception for less than two arguments passed to ADD Failure/Error: Spreadsheet::Error, /Wrong number of arguments for 'ADD': expected at least 2, got 1/ NameError: uninitialized constant Spreadsheet::Error # /tmp/d20160121-5693-1qkr8mk/spec.rb:120:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>' 20) Spreadsheet#[] adds numbers from cell references and as immediate arguments with ADD Failure/Error: sheet = Spreadsheet.new("42 =ADD(1, A1, 2, C1) 10") NameError: undefined local variable or method `rows' for #<Spreadsheet:0x007fce1494fe00 @rows=1> # /tmp/d20160121-5693-1qkr8mk/solution.rb:4:in `initialize' # /tmp/d20160121-5693-1qkr8mk/spec.rb:129:in `new' # /tmp/d20160121-5693-1qkr8mk/spec.rb:129:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>' 21) Spreadsheet#[] adds numbers only from cell references with ADD Failure/Error: sheet = Spreadsheet.new("2 3 5 =ADD(B1, A1, C1) 20") NameError: undefined local variable or method `rows' for #<Spreadsheet:0x007fce1494d470 @rows=1> # /tmp/d20160121-5693-1qkr8mk/solution.rb:4:in `initialize' # /tmp/d20160121-5693-1qkr8mk/spec.rb:135:in `new' # /tmp/d20160121-5693-1qkr8mk/spec.rb:135:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>' 22) Spreadsheet#[] multiplies numbers with MULTIPLY Failure/Error: sheet1 = Spreadsheet.new("=MULTIPLY(1, 2, 3, 4, 5)") NameError: undefined local variable or method `rows' for #<Spreadsheet:0x007fce1494ba30 @rows=1> # /tmp/d20160121-5693-1qkr8mk/solution.rb:4:in `initialize' # /tmp/d20160121-5693-1qkr8mk/spec.rb:141:in `new' # /tmp/d20160121-5693-1qkr8mk/spec.rb:141:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>' 23) Spreadsheet#[] raises an exception for less than two arguments to MULTIPLY Failure/Error: Spreadsheet::Error, /Wrong number of arguments for 'MULTIPLY': expected at least 2, got 1/ NameError: uninitialized constant Spreadsheet::Error # /tmp/d20160121-5693-1qkr8mk/spec.rb:150:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>' 24) Spreadsheet#[] subtracts two numbers with SUBTRACT Failure/Error: sheet = Spreadsheet.new("=SUBTRACT(5, 3) 10") NameError: undefined local variable or method `rows' for #<Spreadsheet:0x007fce14944910 @rows=1> # /tmp/d20160121-5693-1qkr8mk/solution.rb:4:in `initialize' # /tmp/d20160121-5693-1qkr8mk/spec.rb:159:in `new' # /tmp/d20160121-5693-1qkr8mk/spec.rb:159:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>' 25) Spreadsheet#[] subtracts numbers via cell references Failure/Error: sheet = Spreadsheet.new("2 3 5 =SUBTRACT(C1, 1) 20") NameError: undefined local variable or method `rows' for #<Spreadsheet:0x007fce14942cc8 @rows=1> # /tmp/d20160121-5693-1qkr8mk/solution.rb:4:in `initialize' # /tmp/d20160121-5693-1qkr8mk/spec.rb:165:in `new' # /tmp/d20160121-5693-1qkr8mk/spec.rb:165:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>' 26) Spreadsheet#[] raises an exception when SUBTRACT is called with a wrong number of arguments Failure/Error: Spreadsheet::Error, /Wrong number of arguments for 'SUBTRACT': expected 2, got 1/ NameError: uninitialized constant Spreadsheet::Error # /tmp/d20160121-5693-1qkr8mk/spec.rb:172:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>' 27) Spreadsheet#[] divides two numbers with DIVIDE Failure/Error: sheet = Spreadsheet.new("=DIVIDE(84, 2) 10") NameError: undefined local variable or method `rows' for #<Spreadsheet:0x007fce149334d0 @rows=1> # /tmp/d20160121-5693-1qkr8mk/solution.rb:4:in `initialize' # /tmp/d20160121-5693-1qkr8mk/spec.rb:181:in `new' # /tmp/d20160121-5693-1qkr8mk/spec.rb:181:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>' 28) Spreadsheet#[] divides numbers via cell references Failure/Error: sheet1 = Spreadsheet.new("2 84 =DIVIDE(B1, A1) 20") NameError: undefined local variable or method `rows' for #<Spreadsheet:0x007fce149311d0 @rows=1> # /tmp/d20160121-5693-1qkr8mk/solution.rb:4:in `initialize' # /tmp/d20160121-5693-1qkr8mk/spec.rb:187:in `new' # /tmp/d20160121-5693-1qkr8mk/spec.rb:187:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>' 29) Spreadsheet#[] raises an exception when DIVIDE is called with a wrong number of arguments Failure/Error: Spreadsheet::Error, /Wrong number of arguments for 'DIVIDE': expected 2, got 1/ NameError: uninitialized constant Spreadsheet::Error # /tmp/d20160121-5693-1qkr8mk/spec.rb:196:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>' 30) Spreadsheet#[] calculates the modulo of two numbers with MOD Failure/Error: expect(Spreadsheet.new('=MOD(42, 5)')['A1']).to eq('2') NameError: undefined local variable or method `rows' for #<Spreadsheet:0x007fce14903320 @rows=1> # /tmp/d20160121-5693-1qkr8mk/solution.rb:4:in `initialize' # /tmp/d20160121-5693-1qkr8mk/spec.rb:205:in `new' # /tmp/d20160121-5693-1qkr8mk/spec.rb:205:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>' 31) Spreadsheet#[] calculates the modulo of two numbers with MOD via cell references Failure/Error: sheet1 = Spreadsheet.new("10 84 =MOD(B1, A1) 20") NameError: undefined local variable or method `rows' for #<Spreadsheet:0x007fce14901728 @rows=1> # /tmp/d20160121-5693-1qkr8mk/solution.rb:4:in `initialize' # /tmp/d20160121-5693-1qkr8mk/spec.rb:211:in `new' # /tmp/d20160121-5693-1qkr8mk/spec.rb:211:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>' 32) Spreadsheet#[] raises an exception when MOD is called with a wrong number of arguments Failure/Error: Spreadsheet::Error, /Wrong number of arguments for 'MOD': expected 2, got 1/ NameError: uninitialized constant Spreadsheet::Error # /tmp/d20160121-5693-1qkr8mk/spec.rb:220:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>' 33) Spreadsheet#[] adds floating point numbers with ADD Failure/Error: expect(Spreadsheet.new('10 =ADD(A1, 1.1)')['B1']).to eq '11.10' NameError: undefined local variable or method `rows' for #<Spreadsheet:0x007fce143ca4a8 @rows=1> # /tmp/d20160121-5693-1qkr8mk/solution.rb:4:in `initialize' # /tmp/d20160121-5693-1qkr8mk/spec.rb:229:in `new' # /tmp/d20160121-5693-1qkr8mk/spec.rb:229:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>' 34) Spreadsheet#[] subtracts floating point numbers with SUBTRACT Failure/Error: expect(Spreadsheet.new('10 =SUBTRACT(A1, 1.1)')['B1']).to eq '8.90' NameError: undefined local variable or method `rows' for #<Spreadsheet:0x007fce145cb630 @rows=1> # /tmp/d20160121-5693-1qkr8mk/solution.rb:4:in `initialize' # /tmp/d20160121-5693-1qkr8mk/spec.rb:234:in `new' # /tmp/d20160121-5693-1qkr8mk/spec.rb:234:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>' 35) Spreadsheet#[] multiplies floating point numbers with MULTIPLY Failure/Error: expect(Spreadsheet.new('10 =MULTIPLY(A1, 1.1)')['B1']).to eq '11' NameError: undefined local variable or method `rows' for #<Spreadsheet:0x007fce145bad80 @rows=1> # /tmp/d20160121-5693-1qkr8mk/solution.rb:4:in `initialize' # /tmp/d20160121-5693-1qkr8mk/spec.rb:239:in `new' # /tmp/d20160121-5693-1qkr8mk/spec.rb:239:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>' 36) Spreadsheet#[] divides floating point numbers with DIVIDE Failure/Error: expect(Spreadsheet.new('10 =DIVIDE(A1, 4)')['B1']).to eq '2.50' NameError: undefined local variable or method `rows' for #<Spreadsheet:0x007fce145b5060 @rows=1> # /tmp/d20160121-5693-1qkr8mk/solution.rb:4:in `initialize' # /tmp/d20160121-5693-1qkr8mk/spec.rb:244:in `new' # /tmp/d20160121-5693-1qkr8mk/spec.rb:244:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>' 37) Spreadsheet#[] evaluates deeply-nested cell references Failure/Error: expect(Spreadsheet.new('10 =ADD(5, A1) 3 =DIVIDE(B1, C1) =MOD(D1, 4)')['E1']).to eq '1' NameError: undefined local variable or method `rows' for #<Spreadsheet:0x007fce145a9760 @rows=1> # /tmp/d20160121-5693-1qkr8mk/solution.rb:4:in `initialize' # /tmp/d20160121-5693-1qkr8mk/spec.rb:250:in `new' # /tmp/d20160121-5693-1qkr8mk/spec.rb:250:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>' 38) Spreadsheet#[] raises an exception for unknown functions Failure/Error: Spreadsheet::Error, /Unknown function 'FOO'/ NameError: uninitialized constant Spreadsheet::Error # /tmp/d20160121-5693-1qkr8mk/spec.rb:255:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>' 39) Spreadsheet#[] raises an exception for missing cells passed as function arguments Failure/Error: Spreadsheet::Error, /Cell 'B4' does not exist/ NameError: uninitialized constant Spreadsheet::Error # /tmp/d20160121-5693-1qkr8mk/spec.rb:261:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>' 40) Spreadsheet#[] raises an exception for invalid expressions Failure/Error: Spreadsheet::Error, /Invalid expression 'FOO'/ NameError: uninitialized constant Spreadsheet::Error # /tmp/d20160121-5693-1qkr8mk/spec.rb:267:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (3 levels) in <top (required)>' # ./lib/language/ruby/run_with_timeout.rb:5:in `block (2 levels) in <top (required)>' Finished in 0.02903 seconds 40 examples, 40 failures Failed examples: rspec /tmp/d20160121-5693-1qkr8mk/spec.rb:3 # Spreadsheet#new can be called with no arguments or with a single string argument rspec /tmp/d20160121-5693-1qkr8mk/spec.rb:9 # Spreadsheet#new creates a blank sheet when no arguments are passed rspec /tmp/d20160121-5693-1qkr8mk/spec.rb:13 # Spreadsheet#new creates a blank sheet when a blank string is passed rspec /tmp/d20160121-5693-1qkr8mk/spec.rb:17 # Spreadsheet#new creates a non-empty sheet when a non-blank string is passed rspec /tmp/d20160121-5693-1qkr8mk/spec.rb:23 # Spreadsheet#to_s returns blank tables as blank strings rspec /tmp/d20160121-5693-1qkr8mk/spec.rb:27 # Spreadsheet#to_s returns one-cell tables as a string rspec /tmp/d20160121-5693-1qkr8mk/spec.rb:31 # Spreadsheet#to_s returns multi-cell, oneline tables as a string rspec /tmp/d20160121-5693-1qkr8mk/spec.rb:35 # Spreadsheet#to_s returns multi-cell, multiline tables as a string rspec /tmp/d20160121-5693-1qkr8mk/spec.rb:39 # Spreadsheet#to_s splits cells by two or more spaces rspec /tmp/d20160121-5693-1qkr8mk/spec.rb:43 # Spreadsheet#to_s returns the evaluated spreadsheet as a table rspec /tmp/d20160121-5693-1qkr8mk/spec.rb:58 # Spreadsheet#cell_at raises and exception for non-existant cells rspec /tmp/d20160121-5693-1qkr8mk/spec.rb:62 # Spreadsheet#cell_at returns the raw value of existing cells rspec /tmp/d20160121-5693-1qkr8mk/spec.rb:74 # Spreadsheet#[] raises an exception for non-existant cells rspec /tmp/d20160121-5693-1qkr8mk/spec.rb:78 # Spreadsheet#[] returns the value of existing cells for simple cell indexes rspec /tmp/d20160121-5693-1qkr8mk/spec.rb:90 # Spreadsheet#[] returns the value of existing cells for complex cell indexes rspec /tmp/d20160121-5693-1qkr8mk/spec.rb:98 # Spreadsheet#[] returns the calculated value of formulae cells rspec /tmp/d20160121-5693-1qkr8mk/spec.rb:106 # Spreadsheet#[] adds two numbers with ADD rspec /tmp/d20160121-5693-1qkr8mk/spec.rb:112 # Spreadsheet#[] adds five numbers with ADD rspec /tmp/d20160121-5693-1qkr8mk/spec.rb:118 # Spreadsheet#[] raises an exception for less than two arguments passed to ADD rspec /tmp/d20160121-5693-1qkr8mk/spec.rb:128 # Spreadsheet#[] adds numbers from cell references and as immediate arguments with ADD rspec /tmp/d20160121-5693-1qkr8mk/spec.rb:134 # Spreadsheet#[] adds numbers only from cell references with ADD rspec /tmp/d20160121-5693-1qkr8mk/spec.rb:140 # Spreadsheet#[] multiplies numbers with MULTIPLY rspec /tmp/d20160121-5693-1qkr8mk/spec.rb:148 # Spreadsheet#[] raises an exception for less than two arguments to MULTIPLY rspec /tmp/d20160121-5693-1qkr8mk/spec.rb:158 # Spreadsheet#[] subtracts two numbers with SUBTRACT rspec /tmp/d20160121-5693-1qkr8mk/spec.rb:164 # Spreadsheet#[] subtracts numbers via cell references rspec /tmp/d20160121-5693-1qkr8mk/spec.rb:170 # Spreadsheet#[] raises an exception when SUBTRACT is called with a wrong number of arguments rspec /tmp/d20160121-5693-1qkr8mk/spec.rb:180 # Spreadsheet#[] divides two numbers with DIVIDE rspec /tmp/d20160121-5693-1qkr8mk/spec.rb:186 # Spreadsheet#[] divides numbers via cell references rspec /tmp/d20160121-5693-1qkr8mk/spec.rb:194 # Spreadsheet#[] raises an exception when DIVIDE is called with a wrong number of arguments rspec /tmp/d20160121-5693-1qkr8mk/spec.rb:204 # Spreadsheet#[] calculates the modulo of two numbers with MOD rspec /tmp/d20160121-5693-1qkr8mk/spec.rb:210 # Spreadsheet#[] calculates the modulo of two numbers with MOD via cell references rspec /tmp/d20160121-5693-1qkr8mk/spec.rb:218 # Spreadsheet#[] raises an exception when MOD is called with a wrong number of arguments rspec /tmp/d20160121-5693-1qkr8mk/spec.rb:228 # Spreadsheet#[] adds floating point numbers with ADD rspec /tmp/d20160121-5693-1qkr8mk/spec.rb:233 # Spreadsheet#[] subtracts floating point numbers with SUBTRACT rspec /tmp/d20160121-5693-1qkr8mk/spec.rb:238 # Spreadsheet#[] multiplies floating point numbers with MULTIPLY rspec /tmp/d20160121-5693-1qkr8mk/spec.rb:243 # Spreadsheet#[] divides floating point numbers with DIVIDE rspec /tmp/d20160121-5693-1qkr8mk/spec.rb:249 # Spreadsheet#[] evaluates deeply-nested cell references rspec /tmp/d20160121-5693-1qkr8mk/spec.rb:253 # Spreadsheet#[] raises an exception for unknown functions rspec /tmp/d20160121-5693-1qkr8mk/spec.rb:259 # Spreadsheet#[] raises an exception for missing cells passed as function arguments rspec /tmp/d20160121-5693-1qkr8mk/spec.rb:265 # Spreadsheet#[] raises an exception for invalid expressions