Commit 9a304721 authored by haseeb's avatar haseeb

updated integration test

parent 520c9371
require 'spec_helper' require 'spec_helper'
describe 'Embedded Snippets' do describe 'Embedded Snippets' do
include RSpec::Rails::RequestExampleGroup
let(:project) { create(:project, :repository) } let(:project) { create(:project, :repository) }
let(:snippet) { create(:personal_snippet, :public, file_name: 'popen.rb', content: content) } let(:snippet) { create(:personal_snippet, :public, file_name: 'popen.rb', content: content) }
let(:content) { project.repository.blob_at('master', 'files/ruby/popen.rb').data } let(:content) { project.repository.blob_at('master', 'files/ruby/popen.rb').data }
after do
FileUtils.rm_f([File.join(File.dirname(__FILE__), 'embedded_snippet.html'), File.join(File.dirname(__FILE__), 'snippet.js')])
end
it 'loads snippet', :js do it 'loads snippet', :js do
get "#{snippet_path(snippet)}.js" 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>"
File.write(File.join(File.dirname(__FILE__), 'snippet.js'), response.body)
script_tag = "<html><body><script src=\"snippet.js\"></script></body></html>" rack_app = proc do
File.write(File.join(File.dirname(__FILE__), 'embedded_snippet.html'), script_tag) ['200', { 'Content-Type' => 'text/html' }, [embed_body]]
end
Capybara.app = Rack::File.new File.dirname __FILE__ server = Capybara::Server.new(rack_app)
server.boot
visit('embedded_snippet.html') visit("http://#{server.host}:#{server.port}/embedded_snippet.html")
expect(page).to have_content("popen.rb") expect(page).to have_content("popen.rb")
expect(page).to have_content("require 'fileutils'") expect(page).to have_content("require 'fileutils'")
expect(page).to have_link('Open raw')
expect(page).to have_link('Download')
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment