Sha256: ae124c6c423afeeafe513657c400edd5372b235aa8f80b17b84e32de35b626e7
Contents?: true
Size: 1.48 KB
Versions: 3
Compression:
Stored size: 1.48 KB
Contents
require 'rails_helper' RSpec.describe 'Faml with Rails', type: :request do it 'renders views' do get '/books/hello' expect(response).to be_ok expect(response).to render_template('books/hello') expect(response).to render_template('layouts/application') expect(response.body).to include('<span>Hello, World</span>') end it 'renders views with variables' do get '/books/with_variables?title=nanika' expect(response).to be_ok expect(response).to render_template('books/with_variables') expect(response).to render_template('layouts/application') expect(response.body).to include('<p>nanika</p>') end it 'escapes non-html_safe string' do uri = URI.parse('/books/with_variables') uri.query = URI.encode_www_form(title: '<script>alert(1)</script>') get uri.to_s expect(response).to be_ok expect(response).to render_template('books/with_variables') expect(response).to render_template('layouts/application') expect(response.body).to include('<a href="/books/hello">hello</a>') expect(response.body).to include('<p><script>alert(1)</script></p>') end it 'does not escape object which returns html_safe string by to_s' do get '/books/with_variables?title=nanika' expect(response.body).to include('<span>nanika</span>') end it 'works with capture method' do get '/books/with_capture' expect(response).to be_ok expect(response.body).to include("<div><div>\n<p>Hello</p>\n</div>\n</div>\n") end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
faml-0.2.2 | spec/rails/spec/requests/faml_spec.rb |
faml-0.2.1 | spec/rails/spec/requests/faml_spec.rb |
faml-0.2.0 | spec/rails/spec/requests/faml_spec.rb |