lundi 13 juillet 2015

poltergeist working on development, not on CI

I've been writing some tests for my site using poltergeist and capybara, and they all pass on my development machine, but are failing on the Continuous Integration platform I'm using(Codeship). I've looked it up and tried all different solutions but the only time I can get it to work is if I switch to selenium, which I would rather not do if possible. I was wondering if anyone has some advice for this, I've seen tons of topics about it online but nothing has worked for me so far.

In my code page.should have_content("Post created successfully.") is where it fails on all of my tests, as it cannot find this message on the page which is loaded whenever a map file is created (because it hasn't gotten there yet for some reason). I've tried doing all types of sleeps and the wait time is set to 20 seconds now in my spec_helper.rb.

Here is the example code:

add_mapfile_spec.rb

before(:each) do 
    sign_in_and_create_facility
end

scenario 'Creating a mapfile works from locations path' do
    add_mapfile_to_facility_from_main("Bat Cave", "save")  

    page.should have_content("Post created successfully.")
    page.should have_content("Facility: Bat Cave")
    page.should have_content("definitelynotbrucewayne@digitallumens.com")
    page.should have_content("save.map")
    page.should have_content("Cannot Move")


    visit locations_path
    page.should have_content("definitelynotbrucewayne@digitallumens.com")
    page.should have_content("save.map")
end

add mapfile function

  def add_mapfile_to_facility_from_main(name, mapfile)
    visit locations_path
    find('#create-map').click
    select "#{name}", :from => "post[location_id]"
    attach_file('post_mapfile', File.join(Rails.root.to_s, 'spec', 'fixtures', "#{mapfile}.map"))
    find('#submit-map').click
    sleep(1)
  end

Sign_in_and_create_facility works as expected so I know it is not that function. js is set to true on these.

Any help is greatly appreciated, I've been struggling with this for a few days now

Aucun commentaire:

Enregistrer un commentaire