Hi all,
I may be missing something simple here, but I’m having problems with
attempting to get a javascript request test going. I’m not sure if
this is the correct place to ask but perhaps someone will be able to
direct me to the right place if not.
The problem I’m having is that in my before(:each) block in the test I
create about 60 records (using FactoryGirl) so that I can test
filtering/searching data. Here’s my code for that:
before(:each) do
# create records for pagination and filtering
@consumers = FactoryGirl.create_list(:user, 50)
@providers = FactoryGirl.create_list(:provider, 10)
# create and log in with an admin user
@user = Factory(:admin)
visit log_in_path
fill_in "email", :with => @user.EmailAddress
fill_in "password", :with => "foobar"
click_button "Log in"
end
So in effect that just populates some data and logs in with an admin
user.
The problem is, when I run a test with :js => true, I do not see any
users in the list. Take the following two tests:
it "should show users", :focus => true, :solr => true do
visit users_path
save_and_open_page
page.should have_css('.row')
end
it "should show users with javascript", :focus => true, :js =>
true, :solr => true do
visit users_path
save_and_open_page
page.should have_css(’.row’)
end
The first one passes, and opens up a saved page showing a nice list of
users. The second one fails, and opens up an empty user listing. I’ve
tried with both selenium and capybara-webkit and both exhibit the same
result.
Any idea why this may be?