require File.dirname(__FILE__) + '/../test_helper'

class MovieServiceTestCase < Test::Unit::TestCase

  class Rating < ActiveRecord::Base
    establish_connection(
      :adapter => "postgresql",
      :database => "movies_development",
      :host => "localhost"
    )
  end

  class Movie < ActiveRecord::Base
    establish_connection(
      :adapter => "postgresql",
      :database => "movies_development",
      :host => "localhost"
    )
  end

  def test_movie_get
    r = Rating.find('PG-13')
    p = Movie.create!(
      :name => 'Hedwig and the Angry Inch' + rand(100).to_s,
      :length_minutes => 120,
      :rating_id => r.id)
    m = MoviesServiceClient.get_movie(p.id)
    assert m.name == p.name
    assert m.length_minutes == p.length_minutes
    assert m.rating_id == p.rating_id
    assert m.rating_description == p.rating_ description
    p.destroy
  end

end


