2014-08-30 17:38:47 +00:00
|
|
|
require 'rails_helper'
|
2013-08-10 14:51:21 +00:00
|
|
|
|
2013-12-09 22:16:41 +00:00
|
|
|
routes = proc do
|
|
|
|
get '/test/widget/:id' => 'test_widget#show'
|
|
|
|
end
|
|
|
|
|
|
|
|
Rails.application.routes.eval_block(routes)
|
|
|
|
|
2013-08-10 14:51:21 +00:00
|
|
|
class TestWidgetController < ActionController::Base
|
|
|
|
|
|
|
|
def show
|
2013-08-25 14:34:02 +00:00
|
|
|
src = "http://0.0.0.0:#{request.port}/a/#{params[:id]}.js"
|
|
|
|
id = "asciicast-#{params[:id]}"
|
|
|
|
|
2013-08-10 14:51:21 +00:00
|
|
|
render :text => <<EOS
|
|
|
|
<html>
|
|
|
|
<head></head>
|
|
|
|
<body>
|
2013-08-25 14:34:02 +00:00
|
|
|
<script type="text/javascript" src="#{src}" id="#{id}" async></script>
|
2013-08-10 14:51:21 +00:00
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
EOS
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
feature "Embeddable widget", :js => true do
|
|
|
|
|
|
|
|
let!(:asciicast) { create(:asciicast) }
|
|
|
|
|
|
|
|
scenario 'Visiting a page with the widget embed script' do
|
|
|
|
visit "/test/widget/#{asciicast.id}"
|
|
|
|
|
|
|
|
within_frame "asciicast-iframe-#{asciicast.id}" do
|
|
|
|
expect(page).to have_selector('.play-button')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|