Using cucumber, capybara, and net/http to check dynamically injected content
Then /^I should see the API documentation$/ do
uri = URI.parse('http://api.spire.io')
request = Net::HTTP::Get.new(uri.request_uri)
request['Accept'] = 'text/html'
response = Net::HTTP.start(uri.host, uri.port) {|http|
http.request(request)
}
page.should have_css('.api-reference')
# ugh.
script = 'document.getElementsByClassName("api-reference")[0].innerHTML'
actual = page.evaluate_script(script)
script = <<-SCRIPT
var div = document.createElement('div')
div.innerHTML = #{ response.body.inspect };
return div.innerHTML;
SCRIPT
expected = page.execute_script(script)
actual.should_not be_nil
actual.should == expected
end