Skip to content

Instantly share code, notes, and snippets.

@gbelote
Created September 14, 2010 04:52
Show Gist options
  • Select an option

  • Save gbelote/578565 to your computer and use it in GitHub Desktop.

Select an option

Save gbelote/578565 to your computer and use it in GitHub Desktop.
class Recording < ActiveRecord::Base
has_many :frames, :order => "time_ms"
end
describe Recording do
it 'should order frames properly' do
recording = Recording.new
frame3 = recording.frames.build :time_ms => 3
frame1 = recording.frames.build :time_ms => 1
frame2 = recording.frames.build :time_ms => 2
recording.save.should == true
recording.frames.should == [ frame1, frame2, frame3 ]
end
end
'Recording should order frames properly' FAILED
expected: [#<Frame id: 2, recording_id: 1, time_ms: 1>, #<Frame id: 3, recording_id: 1, time_ms: 2>, #<Frame id: 1, recording_id: 1, time_ms: 3>],
got: [#<Frame id: 1, recording_id: 1, time_ms: 3">, #<Frame id: 2, recording_id: 1, time_ms: 1>, #<Frame id: 3, recording_id: 1, time_ms: 2>] (using ==)
@gbelote
Copy link
Copy Markdown
Author

gbelote commented Sep 14, 2010

The solution was to add a recording.reload at recording_spec.rb:8 (to flush from memory).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment