Sha256: b75c7f6fbae49a5c78635be8873099a03dffdea94530d4b3254d385ce6fe804d

Contents?: true

Size: 1.18 KB

Versions: 19

Compression:

Stored size: 1.18 KB

Contents

require 'spec_helper'

module Deface
  module Actions
    describe ReplaceContents do
      include_context "mock Rails.application"
      before { Dummy.all.clear }

      describe "with a single replace_contents override defined" do
        before { Deface::Override.new(:virtual_path => "posts/index", :name => "Posts#index", :replace_contents => "p", :text => "<h1>Argh!</h1>") }
        let(:source) { "<p><span>Hello</span>I am not a <em>pirate</em></p>" }

        it "should return modified source" do
          expect(Dummy.apply(source, {:virtual_path => "posts/index"})).to eq("<p><h1>Argh!</h1></p>")
        end
      end

      describe "with a single replace_contents override with closing_selector defined" do
        before { Deface::Override.new(:virtual_path => "posts/index", :name => "Posts#index", :replace_contents => "h1", :closing_selector => "h2", :text => "<span>Argh!</span>") }
        let(:source) { "<h1>start</h1><p>some junk</p><div>more junk</div><h2>end</h2>" }

        it "should return modified source" do
          expect(Dummy.apply(source, {:virtual_path => "posts/index"})).to eq("<h1>start</h1><span>Argh!</span><h2>end</h2>")
        end
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
deface-1.9.0 spec/deface/actions/replace_contents_spec.rb
deface-1.8.2 spec/deface/actions/replace_contents_spec.rb
deface-1.8.1 spec/deface/actions/replace_contents_spec.rb
deface-1.8.0 spec/deface/actions/replace_contents_spec.rb
deface-1.7.0 spec/deface/actions/replace_contents_spec.rb
deface-1.6.2 spec/deface/actions/replace_contents_spec.rb
deface-1.6.1 spec/deface/actions/replace_contents_spec.rb
deface-1.6.0 spec/deface/actions/replace_contents_spec.rb
deface-1.5.3 spec/deface/actions/replace_contents_spec.rb
deface-1.5.2 spec/deface/actions/replace_contents_spec.rb
deface-1.5.1 spec/deface/actions/replace_contents_spec.rb
deface-1.5.0 spec/deface/actions/replace_contents_spec.rb
deface-1.4.0 spec/deface/actions/replace_contents_spec.rb
deface-1.3.2 spec/deface/actions/replace_contents_spec.rb
deface-1.3.1 spec/deface/actions/replace_contents_spec.rb
deface-1.3.0 spec/deface/actions/replace_contents_spec.rb
deface-1.2.0 spec/deface/actions/replace_contents_spec.rb
deface-1.1.0 spec/deface/actions/replace_contents_spec.rb
deface-1.0.2 spec/deface/actions/replace_contents_spec.rb