Created
May 9, 2012 15:55
-
-
Save phuongnd08/2645843 to your computer and use it in GitHub Desktop.
Testing the search
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
describe "matching partner movies using autocomplete", :js => true do | |
include_context "site_navigation" | |
let!(:movie1) { Factory(:movie, :title => "Mov #1") } | |
let!(:movie2) { Factory(:movie, :title => "Mov #2") } | |
let(:movies) { [movie1, movie2] } | |
let!(:partner_movie1) { Factory(:partner_movie, :movie => movie1) } | |
let!(:partner_movie2) { Factory(:partner_movie, :movie => nil) } | |
context "first visit to the matching page" do | |
it "shows the movie title and released year" do | |
visit match_admin_partner_movie_path(partner_movie1) | |
find("#movie_title")[:value].should == movie1.to_s | |
end | |
end | |
context "fill in text to trigger auto complete" do | |
def index_search_data | |
config = ThinkingSphinx::Configuration.instance | |
config.build | |
FileUtils.mkdir_p config.searchd_file_path | |
config.controller.index :verbose => true | |
end | |
before do | |
index_search_data | |
visit match_admin_partner_movie_path(partner_movie2) | |
fill_in "movie_title", :with => pattern | |
end | |
context "there are matches" do | |
let(:pattern) { "Mov" } | |
it "shows the suggestion" do | |
debugger | |
within ".ui-autocomplete" do | |
movies.each do |movie| | |
page.should have_content(movie.title) | |
page.should have_content(movie.year.to_s) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment