Skip to content

Instantly share code, notes, and snippets.

@Prigin
Created November 15, 2019 14:13
Show Gist options
  • Save Prigin/b1b12fccb412470be9730ce6d7c70163 to your computer and use it in GitHub Desktop.
Save Prigin/b1b12fccb412470be9730ce6d7c70163 to your computer and use it in GitHub Desktop.
mkdev
require '../movie_coll.rb'
require 'rspec'
chk_list = [:link, :title, :year, :country, :date,
:genre, :duration, :rating, :director, :stars]
describe MovieCollection do
mas = MovieCollection.new('test.txt')
chk_list.each do |unit|
it "" do
expect(mas.stats(unit).map{|u| u.inspect})
.to eq(File.readlines("test_stats_#{unit}.txt").map{|u| u.chomp})
end
end
chk_list.each do |unit|
it "" do
expect(mas.sort_by(unit).map{ |u|
"#{u.link}|#{u.title}|#{u.year}|"\
"#{u.country}|#{u.date}|"\
"#{u.genre.join(',')}|"\
"#{u.duration} min|#{u.rating}|"\
"#{u.director.join(',')}|"\
"#{u.stars.join(',')}" }).to eq (File.readlines("test_sort_by_#{unit}.txt").map{|u| u.chomp})
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment