Commit ecaa136

mo khan <mo@mokhan.ca>
2013-10-18 00:33:17
add some sorting specs.
1 parent 6e7ea55
Changed files (2)
lib/movie.rb
@@ -1,5 +1,7 @@
 class Movie
-  def initialize(name)
-    @name = name
+  attr_reader :title
+
+  def initialize(attributes)
+    @title, @studio = attributes.values_at(:title, :studio)
   end
 end
spec/movie_library_spec.rb
@@ -98,9 +98,15 @@ describe MovieLibrary do
 
   context 'Sorting movies' do
     it 'Sorts all movies by descending title' do
+      expected_order = [ cars, chasing_amy, dumbo, fantasia, man_on_fire, monsters_inc, pinocchio, shawshank_redemption, toy_story, up]
+      results = library.sort_movies_by_title_descending
+      results.should == expected_order
     end
 
     it 'Sorts all movies by ascending title' do
+      expected_order = [up, toy_story, shawshank_redemption, pinocchio, monsters_inc, man_on_fire, fantasia, dumbo, chasing_amy, cars]
+      results = library.sort_movies_by_title_ascending
+      results.should == expected_order
     end
 
     it 'Sorts all movies by descending release date' do