I want to test an action called with javascript. The action is: def index unless params[:customer_full_name].blank? full_name = params[:customer_full_name] @customers = Customer.search_full_name(full_name).paginate(:per_page => 10, :page => params[:page]) else @customers = Customer.all.paginate(:per_page => 10, :page => params[:page]) end render :layout => false if request.xhr? end In the view I have a form with a search field. When I put values in this field it calls a javascript function. I''ve tried to write this test: require ''spec_helper'' require ''capybara/rspec'' describe CustomersController do include Devise::TestHelpers describe "search with js", :js => true do before(:each) do @customers = mock_model(Customer, :full_name => "User-1") end context "when full_name is ''user''" do it "should find customers" do login page.should have_content "Customers" page.should have_content "Dashboard" click_link(''Customers'') fill_in "customer_full_name", :with => "User" @full_name = "User" Customer.should_receive(:search_full_name).with(@full_name).and_return(@customers) @customers.should_receive(:paginate) do_get assigns(:customers).should_not be_nil end end def login User.make! visit ''/d/users/sign_in/'' fill_in "user_email", :with => "user0001-hcDgGtZH8xNBDgjK7y7TUQ@public.gmane.org" fill_in "user_password", :with => "password" click_button "Sign in" end def do_get page= nil, format = ''html'' get ''index'', :customer_full_name => @full_name, :format => format end Doesn''t work. Any advise? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.