apneadiving / Google-Maps-for-Rails

Enables easy Google map + overlays creation in Ruby apps
https://apneadiving.github.io/
MIT License
2.26k stars 382 forks source link

cucumber/caybara/rspec integration testing contents of infowindows #356

Closed tansaku closed 10 years ago

tansaku commented 11 years ago

We're just playing around with the infowindows in our project that uses gmap4rails. Pulled stuff out into a partial as recommended:

@json = @results.to_gmaps4rails do |org, marker| marker.infowindow render_to_string(:partial => "popup", :locals => { :@org => org}) end

Partial has this:

<%= link_to "#{@org.name}", organization_path(@org) %>

and we've checked that we can match xpath with it in chrome like so:

$x("//div[@class='map_container']//a[@href='/organizations/127']")

however this doesn't work in a cucumber spec like so:

expect(page).to have_xpath("//div[@class='map_container']//a[@href='#{organization_path(org)}']")

All code in a branch here: https://github.com/tansaku/LocalSupport/tree/map_links

Is there a recommended best practice for integration tests of the infowindows? I can write a view spec for the partial, or a controller spec etc., but perhaps there's no way to integration test the infowindow contents since that all gets rendered by the browser, so short of full selenium testing are there any good options?

Would http://phantomjs.org/ help here? We are already using capybara-webkit

Many thanks in advance

apneadiving commented 10 years ago

i've not found a clever way to do this, I rely on view partial specs