require 'spec_helper' module Deface module Actions describe Surround do include_context "mock Rails.application" before { Dummy.all.clear } describe "with a single html surround override defined" do before { Deface::Override.new(:virtual_path => "posts/index", :name => "Posts#index", :surround => "p", :text => "
test
" } it "should return modified source" do Dummy.apply(source, {:virtual_path => "posts/index"}).should == "test
test
" } it "should return modified source" do Dummy.apply(source, {:virtual_path => "posts/index"}).gsub("\n", '').should == "<% some_method('test') do %>test
<% end %>" end end describe "with a single surround override defined using :closing_selector" do before { Deface::Override.new(:virtual_path => "posts/index", :name => "Posts#index", :surround => "h1", :closing_selector => "p", :text => "<% some_method('test') do %><%= render_original %><% end %>") } let(:source) { "This is the end.
" } it "should return modified source" do Dummy.apply(source, {:virtual_path => "posts/index"}).gsub("\n", '').should == "<% some_method('test') do %>This is the end.
<% end %>" end end describe "with multiple render_original calls defined" do before { Deface::Override.new(:virtual_path => "posts/index", :name => "Posts#index", :surround => "p", :text => "test
" } it "should return modified source" do Dummy.apply(source, {:virtual_path => "posts/index"}).should == "test
test
This is the end.
" } it "should return modified source" do Dummy.apply(source, {:virtual_path => "posts/index"}).gsub("\n", '').should == "<% if true %>This is the end.
<% else %>This is the end.
<% end %>" end end end end end