pwd=Dir.pwd Dir.chdir("../../") require "IMDB.rb" Dir.chdir(pwd) require 'test/unit' #class Test::Unit::TestCase $movie = IMDB.new("office_space") class OfficeSpaceTest < Test::Unit::TestCase def setup @office_space = $movie end def test_class_title_search assert(IMDB.title_search("office space")=={"Titles (Exact Matches)"=>["Office Space"], "Titles (Partial Matches)"=>["'Office Space': Out of the Office"], "Popular Titles"=>["Office Space"], "Titles (Approx Matches)"=>["Spice Girls: One Hour of Girl Power"]}) end def test_title assert_equal(@office_space.title.downcase.strip,"office space") end def test_poster_link assert_equal(@office_space.poster_link,"http://ia.imdb.com/media/imdb/01/I/79/05/84m.jpg") end def test_actors actors = {"Stephen Root"=>"Milton Waddams", "Paul Willson"=>"Bob Porter", "Ajay Naidu"=>"Samir Nagheenanajar", "Jennifer Aniston"=>"Joanna", "Alexandra Wentworth"=>"Anne", "Ron Livingston"=>"Peter Gibbons", "Joe Bays"=>"Dom Portwood", "Gary Cole"=>"Bill Lumbergh", "David Herman"=>"Michael Bolton", "Greg Pitts"=>"Drew", "Diedrich Bader"=>"Lawrence", "Kinna McInroe"=>"Nina", "Todd Duffey"=>"Brian - Chotchkie's Waiter", "John C. McGinley"=>"Bob Slydell", "Richard Riehle"=>"Tom Smykowski"} assert_equal(@office_space.actors,actors) assert_equal(@office_space.cast,actors) end def test_rating rating = "Rated R for language and brief sexuality." assert_equal(@office_space.rating,rating) assert_equal(@office_space.mpaa,rating) assert_equal(@office_space.ratings,rating) end def test_aka assert_equal(@office_space.aka,"Cubiculos de la oficina (USA: Spanish title)") end def test_aspect assert_equal(@office_space.aspect_ratio,"1.85 : 1") end def test_awards assert_equal(@office_space.awards,"2 nominations") end def test_certs certs ={"UK"=>"15", "Ireland"=>"15", "Chile"=>"TE", "Australia"=>"M", "Argentina"=>"Atp", "Iceland"=>"L", "Sweden"=>"Btl", "Portugal"=>"M/12", "Spain"=>"T", "USA"=>"R", "Finland"=>"S", "France"=>"U", "Peru"=>"PT", "Canada"=>"AA", "Norway"=>"7", "Germany"=>"12", "Netherlands"=>"AL"} assert_equal(@office_space.certification,certs) assert_equal(@office_space.certifications,certs) assert_equal(@office_space.certs,certs) end def test_color assert_equal(@office_space.color,"Color") end def test_company assert_equal(@office_space.company,"Twentieth Century-Fox Film Corporation") end def test_country assert_equal(@office_space.country,"USA") end def test_date assert_equal(@office_space.date.to_s,"1999-02-19") assert(@office_space.date.class.to_s=="Date") end def test_directors assert_equal(@office_space.director,["Mike Judge"]) end def test_genre assert_equal(@office_space.genre,["Comedy", "Crime"]) end def test_keywords assert_equal(@office_space.keywords.sort,["Hypnosis", "Post\240It", "Kung\240Fu", "Cult\240Comedy", "Arson"].sort) end def test_lang assert_equal(@office_space.language,"English") end def test_plots plot = "Comedic tale of company workers who hate their jobs and decide to rebel against their greedy boss." plot_key = ["Cult\240Comedy", "Hypnosis", "Post\240It", "Kung\240Fu", "Arson"] plot_out = "Comedic tale of company workers who hate their jobs and decide to rebel against their greedy boss." assert_equal(@office_space.plot,plot) assert_equal(@office_space.plot_keywords,plot_key) assert_equal(@office_space.plot_outline,plot_out) end def test_runtime assert_equal(@office_space.runtime,"89 min") end def test_tagline assert_equal(@office_space.tagline,"Work Sucks.") end def test_user_comments #comment changes @office_space.user_comments #assert_equal(@office_space.user_comments,"The best no-budget movie you'll ever see") end def test_writers assert_equal(@office_space.writer,["Mike Judge"]) assert_equal(@office_space.writers,["Mike Judge"]) end def test_xml #if comment changes this breaks #pi_xml = "Stephen RootMilton WaddamsPaul WillsonBob PorterAjay NaiduSamir NagheenanajarJennifer AnistonJoannaAlexandra WentworthAnneRon LivingstonPeter GibbonsJoe BaysDom PortwoodGary ColeBill LumberghDavid HermanMichael BoltonGreg PittsDrewDiedrich BaderLawrenceKinna McInroeNinaTodd DuffeyBrian - Chotchkie's WaiterJohn C. McGinleyBob SlydellRichard RiehleTom Smykowski89 minComedic tale of company workers who hate their jobs and decide to rebel against their greedy boss.Mike JudgeMike Judgehttp://www.imdb.com/title/tt0151804/Office Space 1999-02-19Rated R for language and brief sexuality.Best Movie I've Ever SeenWork Sucks.Comedic tale of company workers who hate their jobs and decide to rebel against their greedy boss.ComedyCrime" #assert_equal(@office_space.to_xml,pi_xml) end def test_html @office_space.to_html end end