Created
June 19, 2017 14:17
-
-
Save garethrees/7b2da11adc1e521f5ae18d0cf1a18f9b to your computer and use it in GitHub Desktop.
Anonymous controller integration spec
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -*- 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('<foo>') | |
| 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