Skip to content

Commit

Permalink
added ability to use IMDB
Browse files Browse the repository at this point in the history
  • Loading branch information
drapergeek committed May 23, 2012
1 parent c02d496 commit dc9138a
Show file tree
Hide file tree
Showing 11 changed files with 15,738 additions and 15 deletions.
5 changes: 4 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ gem 'pg'
gem "haml-rails"
gem "devise"
gem 'simple_form'
gem 'imdb'
gem 'vcr'
gem 'fakeweb'


group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', :platform => :ruby
gem 'therubyracer', :platform => :ruby
gem 'uglifier', '>= 1.0.3'
gem "twitter-bootstrap-rails"
end
Expand Down
30 changes: 20 additions & 10 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ GEM
coffee-script (2.2.0)
coffee-script-source
execjs
coffee-script-source (1.3.2)
coffee-script-source (1.3.3)
commonjs (0.2.6)
cucumber (1.2.0)
builder (>= 2.1.2)
Expand All @@ -60,20 +60,21 @@ GEM
cucumber (>= 1.1.8)
nokogiri (>= 1.5.0)
database_cleaner (0.7.2)
devise (2.0.4)
devise (2.1.0)
bcrypt-ruby (~> 3.0)
orm_adapter (~> 0.0.3)
orm_adapter (~> 0.0.7)
railties (~> 3.1)
warden (~> 1.1.1)
diff-lcs (1.1.3)
erubis (2.7.0)
execjs (1.3.2)
execjs (1.4.0)
multi_json (~> 1.0)
factory_girl (3.3.0)
activesupport (>= 3.0.0)
factory_girl_rails (3.3.0)
factory_girl (~> 3.3.0)
railties (>= 3.0.0)
fakeweb (1.3.0)
ffi (1.0.11)
gherkin (2.10.0)
json (>= 1.4.6)
Expand All @@ -87,19 +88,22 @@ GEM
guard-cucumber (0.8.0)
cucumber (>= 1.2.0)
guard (>= 0.8.3)
guard-rspec (0.7.2)
guard-rspec (0.7.3)
guard (>= 0.10.0)
guard-spork (0.8.0)
guard (>= 0.10.0)
spork (>= 0.8.4)
haml (3.1.5)
haml (3.1.6)
haml-rails (0.3.4)
actionpack (~> 3.0)
activesupport (~> 3.0)
haml (~> 3.0)
railties (~> 3.0)
hike (1.2.1)
hpricot (0.8.6)
i18n (0.6.0)
imdb (0.6.8)
hpricot (~> 0.8.4)
journey (1.0.3)
jquery-rails (2.0.2)
railties (>= 3.2.0, < 5.0)
Expand Down Expand Up @@ -162,7 +166,7 @@ GEM
rspec-core (~> 2.10.0)
rspec-expectations (~> 2.10.0)
rspec-mocks (~> 2.10.0)
rspec-core (2.10.0)
rspec-core (2.10.1)
rspec-expectations (2.10.0)
diff-lcs (~> 1.1.3)
rspec-mocks (2.10.1)
Expand All @@ -183,12 +187,13 @@ GEM
libwebsocket (~> 0.1.3)
multi_json (~> 1.0)
rubyzip
shoulda-matchers (1.0.0)
shoulda-matchers (1.1.0)
activesupport (>= 3.0.0)
simple_form (2.0.2)
actionpack (~> 3.0)
activemodel (~> 3.0)
slop (2.4.4)
spork (0.9.1)
spork (0.9.2)
sprockets (2.1.3)
hike (~> 1.2)
rack (~> 1.0)
Expand All @@ -200,7 +205,7 @@ GEM
treetop (1.4.10)
polyglot
polyglot (>= 0.3.1)
twitter-bootstrap-rails (2.0.7)
twitter-bootstrap-rails (2.0.8)
actionpack (>= 3.1)
less-rails (~> 2.2.2)
railties (>= 3.1)
Expand All @@ -209,6 +214,7 @@ GEM
uglifier (1.2.4)
execjs (>= 0.3.0)
multi_json (>= 1.0.2)
vcr (2.1.1)
warden (1.1.1)
rack (>= 1.0)
xpath (0.1.4)
Expand All @@ -223,13 +229,15 @@ DEPENDENCIES
database_cleaner
devise
factory_girl_rails
fakeweb
growl
guard
guard-bundler
guard-cucumber
guard-rspec
guard-spork
haml-rails
imdb
jquery-rails
launchy
mocha
Expand All @@ -241,5 +249,7 @@ DEPENDENCIES
shoulda-matchers
simple_form
spork
therubyracer
twitter-bootstrap-rails
uglifier (>= 1.0.3)
vcr
5 changes: 4 additions & 1 deletion app/controllers/movie_recommendations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ def index
@recommendations = MovieRecommendation.all
end

def new
end

def create
@recommendation = current_user.from_me.new(params[:movie_recommendation])
@recommendation = current_user.from_me.new
if @recommendation.save
redirect_to friend_path(@recommendation.recommendee), notice: "You have added #{@recommendation.name}"
end
Expand Down
5 changes: 5 additions & 0 deletions app/controllers/movie_searches_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class MovieSearchesController < ApplicationController
def new
@movies = Imdb::Search.new(params[:search][:movie_name]).movies
end
end
5 changes: 2 additions & 3 deletions app/views/friends/show.html.haml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
%ul.recommendations
-@recommendations.each do |recommendation|
%li.recommendation= link_to recommendation.name, recommendation
=simple_form_for @recommendation do |f|
%li.recommendation=link_to recommendation.name, recommendation
=simple_form_for :search, url: new_movie_search_path , method: :get do |f|
=f.input :movie_name
=f.input :recommendee_id, as: :hidden
=f.submit "Add recommendation"
6 changes: 6 additions & 0 deletions app/views/movie_searches/new.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-@movies[0..5].each do |movie|
.movie[movie]
%h3.movie_title=movie.title
-if movie.poster.present?
=image_tag movie.poster, size: '100x155'
=button_to "Add Recommendation", movie_recommendations_path(id: movie.id)
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
resources :movie_recommendations, only: [:index, :show, :create]
resources :my_recommendations, only: [:index]
resources :friends, only: [:index, :show]
resources :movie_searches, only: [:new]
root to: "movie_recommendations#index"
end
7 changes: 7 additions & 0 deletions features/friends.feature
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,19 @@ Feature: Interact with other users
| Iron Man |
| The Goonies |

@imdb
Scenario: Add a recommendation for a friend
Given a user "sam@example.com" with 5 recommendations
Given I am signed in as "person@example.com"
When I visit my friends page
And I click the "sam@example.com" link
And I fill in "Men In Black" for a movie recommendation
And I click the "Add recommendation" button
Then I should see the following movies:
| name |
| Men in Black |
| Men in Black II |
| Men in Black III |
When I select "Men In Black"
Then I should see "Men In Black" in his recommendations
And I should see "You have added Men In Black"
10 changes: 10 additions & 0 deletions features/step_definitions/friend_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,13 @@
page.should have_content text
end

Then /^I should see the following movies:$/ do |table|
table.hashes.each do |hash|
page.should have_content hash[:name]
end
end

When /^I select "(.*?)"$/ do |arg1|
pending # express the regexp above with the code you wish you had
end

10 changes: 10 additions & 0 deletions features/support/env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@

Cucumber::Rails::Database.javascript_strategy = :truncation
World FactoryGirl::Syntax::Methods

VCR.configure do |c|
c.cassette_library_dir = 'features/vcr_cassettes'
c.hook_into :fakeweb
c.allow_http_connections_when_no_cassette = true
end

VCR.cucumber_tags do |t|
t.tag '@imdb'
end
end

Spork.each_run do
Expand Down
Loading

0 comments on commit dc9138a

Please sign in to comment.