<Seance[m]>
Got a question about writing tests in RSpec
<Seance[m]>
what would be the most appropriate way to test a function that modifies an array?
<Seance[m]>
if the function itself pushes to an array, it's not really returning something that I'd traditionally use .to eql for
<Seance[m]>
(also I'm a big noob so it's probably something obvious)
alem0lars has quit [Ping timeout: 245 seconds]
<Seance[m]>
For examples: expect(class_name.push_values('foo').to eql)
<Seance[m]>
if the push_values function modified a separate array, how would I test for that array's contents instead?
Esa_ has joined #ruby
<Seance[m]>
I take it I'd instantiate a test array inside the block of test
orbyt_ has joined #ruby
dviola has quit [Ping timeout: 245 seconds]
code_zombie has quit [Quit: Leaving]
yokel has quit [Read error: Connection reset by peer]
yokel has joined #ruby
codefriar has joined #ruby
codefriar has quit [Client Quit]
ghostlines has joined #ruby
fphilipe_ has joined #ruby
fphilipe_ has quit [Ping timeout: 272 seconds]
troulouliou_dev has joined #ruby
DTZUZO has joined #ruby
CCDelivery has quit [Remote host closed the connection]
fphilipe_ has joined #ruby
dbugger has joined #ruby
dbugger has quit [Remote host closed the connection]
funnel has quit [Ping timeout: 246 seconds]
hanmac has quit [Quit: Leaving.]
troulouliou_dev has quit [Quit: Leaving]
r29v has joined #ruby
fphilipe_ has quit [Ping timeout: 276 seconds]
reber has joined #ruby
funnel has joined #ruby
dhollin3 is now known as dhollinger
dbugger has joined #ruby
nowhereman has quit [Ping timeout: 258 seconds]
mosh has quit [Ping timeout: 245 seconds]
agent_white has quit [Ping timeout: 272 seconds]
agent_white has joined #ruby
Azure|dc has joined #ruby
TheBrayn has quit [Quit: poof]
TheBrayn has joined #ruby
ghostlin_ has joined #ruby
ghostlines has quit [Ping timeout: 248 seconds]
Azure has quit [Ping timeout: 248 seconds]
cschneid_ has joined #ruby
hutch has quit [Quit: WeeChat 2.5]
agent_white has quit [Ping timeout: 272 seconds]
agent_white has joined #ruby
hutch has joined #ruby
cschneid_ has quit [Ping timeout: 246 seconds]
troulouliou_dev has joined #ruby
riotjones has joined #ruby
fphilipe_ has joined #ruby
agent_white has quit [Ping timeout: 245 seconds]
agent_white has joined #ruby
cd has joined #ruby
shirak has quit [Ping timeout: 268 seconds]
schne1der has joined #ruby
planigan has quit [Ping timeout: 245 seconds]
edwardly has quit [Ping timeout: 246 seconds]
victorqueiroz has joined #ruby
planigan has joined #ruby
cd has quit [Ping timeout: 256 seconds]
cd has joined #ruby
edwardly has joined #ruby
r29v has quit [Quit: r29v]
cschneid_ has joined #ruby
troulouliou_dev has quit [Quit: Leaving]
al2o3-cr has quit [Quit: If the universe is a machine where the future is uniquely determined by its present state, it would not be possible to calculate what the future will be.]
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
idiocrash has joined #ruby
al2o3-cr has joined #ruby
fphilipe_ has quit [Ping timeout: 252 seconds]
idiocrash has quit [Remote host closed the connection]
idiocrash has joined #ruby
riotjones has quit [Ping timeout: 252 seconds]
reber_ has joined #ruby
reber has quit [Read error: Connection reset by peer]
reber_ is now known as reber
idiocrash has quit [Read error: Connection reset by peer]
reber has quit [Remote host closed the connection]
cschneid_ has quit [Ping timeout: 272 seconds]
idiocrash has joined #ruby
idiocrash has quit [Max SendQ exceeded]
dbugger has quit [Quit: Leaving]
idiocrash has joined #ruby
idiocrash has quit [Remote host closed the connection]
idiocrash has joined #ruby
dellavg_ has quit [Ping timeout: 272 seconds]
codefriar has joined #ruby
yokel has quit [Read error: Connection reset by peer]
yokel has joined #ruby
Esa_ has quit [Read error: Connection reset by peer]
ur5us has joined #ruby
schne1der has quit [Ping timeout: 268 seconds]
dionysus69 has quit [Ping timeout: 245 seconds]
Swyper has quit [Remote host closed the connection]
<leftylink>
it seems like they are both following the convention slice(start, length)
<mb4518723>
I would think [1,2,3].slice(0,0) would return [1] though?
<mb4518723>
hmm yeah
<leftylink>
if one wishes to specify a start and end index instead of a start index and a length, one might consider [1, 2, 3, 4, 5][2..4]
<mb4518723>
it's killing me right now because I'm trying to write very simple pagination function (array, page, per page) using slice. so far though I'm consistently getting one too many
<mb4518723>
oh that's interesting leftylink, using a range instead
<mb4518723>
page would be (n-1) and per_page I would think would ((page-1), (per_page+page))
<mb4518723>
[1,2,3].slice(0..0) => [1] ... [1,2,3].slice(1..1) => [2] okay! that's consistent :) with what I was originally thinking
dionysus69 has joined #ruby
sarink has joined #ruby
sarink has quit [Ping timeout: 245 seconds]
<mb4518723>
leftylink thanks a lot, I solved my problem. I had just failed to comprehend the documentation that it was #slice(start, length)!!!
<mb4518723>
the solution that I ended up with was [n,....n-1].slice((page-1)*per_page, per_page))
<mb4518723>
:) thank you so very much!
mb4518723 has quit [Ping timeout: 272 seconds]
matchaw has joined #ruby
matchaw_ has joined #ruby
matchaw has quit [Ping timeout: 258 seconds]
bambanx has joined #ruby
cschneid_ has joined #ruby
matchaw_ is now known as Matchaw
Matchaw has quit [Quit: Leaving]
fphilipe_ has joined #ruby
fphilipe_ has quit [Ping timeout: 252 seconds]
tdy has quit [Ping timeout: 272 seconds]
idiocrash has quit [Read error: Connection reset by peer]
idiocrash has joined #ruby
cschneid_ has quit [Ping timeout: 245 seconds]
idiocrash has quit [Ping timeout: 245 seconds]
ghostlin_ has quit [Remote host closed the connection]
ghostlines has joined #ruby
ghostlines has quit [Max SendQ exceeded]
ghostlines has joined #ruby
ghostlines has quit [Max SendQ exceeded]
ghostlines has joined #ruby
ghostlines has quit [Max SendQ exceeded]
ghostlines has joined #ruby
rafadc has quit [Remote host closed the connection]