gitlab-org--gitlab-foss/spec/features/snippets/embedded_snippet_spec.rb

26 lines
927 B
Ruby
Raw Normal View History

2018-03-17 08:17:43 -04:00
require 'spec_helper'
describe 'Embedded Snippets' do
2018-03-19 09:56:18 -04:00
let(:snippet) { create(:personal_snippet, :public, file_name: 'random_dir.rb', content: content) }
let(:content) { "require 'fileutils'\nFileUtils.mkdir_p 'some/random_dir'\n" }
2018-03-17 08:17:43 -04:00
it 'loads snippet', :js do
2018-03-19 09:30:53 -04:00
script_url = "http://#{Capybara.current_session.server.host}:#{Capybara.current_session.server.port}/#{snippet_path(snippet, format: 'js')}"
embed_body = "<html><body><script src=\"#{script_url}\"></script></body></html>"
2018-03-17 08:17:43 -04:00
2018-03-19 09:30:53 -04:00
rack_app = proc do
['200', { 'Content-Type' => 'text/html' }, [embed_body]]
end
2018-03-17 08:17:43 -04:00
2018-03-19 09:30:53 -04:00
server = Capybara::Server.new(rack_app)
server.boot
2018-03-17 08:17:43 -04:00
2018-03-19 09:30:53 -04:00
visit("http://#{server.host}:#{server.port}/embedded_snippet.html")
2018-03-17 08:17:43 -04:00
2018-03-19 09:56:18 -04:00
expect(page).to have_content("random_dir.rb")
2018-03-17 08:17:43 -04:00
expect(page).to have_content("require 'fileutils'")
2018-03-19 09:30:53 -04:00
expect(page).to have_link('Open raw')
expect(page).to have_link('Download')
2018-03-17 08:17:43 -04:00
end
end