Skip to content

Instantly share code, notes, and snippets.

@hahcho
Created December 14, 2015 21:06
Show Gist options
  • Save hahcho/b7b83757f02d713e0fd7 to your computer and use it in GitHub Desktop.
Save hahcho/b7b83757f02d713e0fd7 to your computer and use it in GitHub Desktop.
ruby-match-array
expect(agenda.notes.size).to eq(2)
expect(agenda.notes.first.file_name).to eq('todo_list')
expect(agenda.notes.first.header).to eq('one')
expect(agenda.notes.first.date.class).to eq(LazyMode::Date)
expect(agenda.notes.first.date.year).to eq(2012)
expect(agenda.notes.first.date.month).to eq(8)
expect(agenda.notes.first.date.day).to eq(7)
expect(agenda.notes.first.status).to eq(:postponed)
expect(agenda.notes.first.body).to eq('one body lies here...')
expect(agenda.notes.last.file_name).to eq('todo_list')
expect(agenda.notes.last.header).to eq('three')
expect(agenda.notes.last.date.class).to eq(LazyMode::Date)
expect(agenda.notes.last.date.year).to eq(2012)
expect(agenda.notes.last.date.month).to eq(8)
expect(agenda.notes.last.date.day).to eq(7)
expect(agenda.notes.last.status).to eq(:topostpone)
expect(agenda.notes.last.body).to eq('three bodies lie here...')
expect(agenda.notes).to match_array([
NoteWithDate.new('todo_list', 'one', 'one body lies here', [], :postponed, 7, 8, 2012),
NoteWithDate.new('todo_list', 'three', 'three body lies here', [], :topostpone, 7, 8, 2012)
])
NoteWithDate = Struct.new(:file_name, :header, :body, :tags, :status, :day, :month, :year) do
def ==(note)
puts 'WTF?@?@'
note.date.is_a?(LazyMode::Date)
# &&
# file_name == note.file_name &&
# header == note.header &&
# body == note.body &&
# status == note.status &&
# day == note.date.day &&
# month == note.date.month &&
# year == note.date.year
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment