Guest User

Untitled

a guest
Jul 15th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. require 'spec_helper'
  2.  
  3. describe Artist, "Chart" do
  4.  
  5. before(:each) do
  6. floyd = Artist.make(:name => "Pink Floyd")
  7. 3.times{ |index| floyd.mentions.make }
  8. 20.times{ |index| floyd.mentions.make(:older) }
  9.  
  10. wizard = Artist.make(:name => "Electric Wizard")
  11. 10.times{ |index| wizard.mentions.make }
  12. 10.times{ |index| wizard.mentions.make(:older) }
  13.  
  14. zeppelin = Artist.make(:name => "Led Zeppelin")
  15. 15.times{ |index| zeppelin.mentions.make }
  16. 5.times{ |index| zeppelin.mentions.make(:older) }
  17. end
  18.  
  19. it "should get the order of a weekly chart correctly" do
  20. chart = Artist.weekly_chart
  21. chart[0].name.should == "Led Zeppelin"
  22. chart[1].name.should == "Electric Wizard"
  23. chart[2].name.should == "Pink Floyd"
  24. end
  25.  
  26. it "should get the order of a custom chart correctly" do
  27. start_date = 1.month.ago
  28. end_date = Time.now
  29.  
  30. chart = Artist.chart(start_date, end_date)
  31. chart[0].name.should == "Pink Floyd"
  32. chart[1].name.should == "Electric Wizard"
  33. chart[2].name.should == "Led Zeppelin"
  34. end
  35.  
  36. end
Add Comment
Please, Sign In to add comment