Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save garethrees/7b2da11adc1e521f5ae18d0cf1a18f9b to your computer and use it in GitHub Desktop.

Select an option

Save garethrees/7b2da11adc1e521f5ae18d0cf1a18f9b to your computer and use it in GitHub Desktop.
Anonymous controller integration spec
# -*- encoding : utf-8 -*-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe '#render_flash full stack integration' do
controller do
def escaped_string
flash.now[:escaped] = "<foo>"
render :inline => <<-EOF.strip_heredoc.html_safe
<%= render_flash(flash[:escaped]) %>
EOF
end
def safe_string
flash.now[:safe] = "<bar>".html_safe
render :inline => <<-EOF.strip_heredoc.html_safe
<%= render_flash(flash[:safe]) %>
EOF
end
end
describe '#render_flash' do
it 'escapes html in strings' do
routes.draw do
get 'escaped_string' => 'anonymous#escaped_string'
end
get :escaped_string
expect(response.body).to match('&lt;foo&gt')
end
it 'renders html snippets marked as html_safe' do
routes.draw do
get 'safe_string' => 'anonymous#safe_string'
end
get :safe_string
expect(response.body).to match('<bar>')
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment