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