Sha256: 1df1f19e82d32296e41063326a3e2ad8e81462170fe52049517642d59b5c17cc

Contents?: true

Size: 1.42 KB

Versions: 19

Compression:

Stored size: 1.42 KB

Contents

require 'spec_helper'

module Deface

  describe Precompiler do
    include_context "mock Rails.application"

    before do
      # start with a clean file system
      FileUtils.rm_rf('spec/dummy/app/compiled_views')
      environment = Deface::Environment.new
      overrides = Deface::Environment::Overrides.new
      allow(overrides).to receive_messages(:all => {}) # need to do this before creating an override
      allow(overrides).to receive_messages(:all => {"posts/precompileme".to_sym => {"precompileme".parameterize => Deface::Override.new(:virtual_path => "posts/precompileme", :name => "precompileme", :insert_bottom => 'li', :text => "Added to li!")}})
      allow(environment).to receive_messages(:overrides => overrides)

      allow(Rails.application.config).to receive_messages :deface => environment

      #stub view paths to be local spec/assets directory
      allow(ActionController::Base).to receive(:view_paths).and_return([File.join(File.dirname(__FILE__), '..', "assets")])

      Precompiler.precompile()
    end

    after do
      # cleanup the file system
      FileUtils.rm_rf('spec/dummy/app/compiled_views')
    end

    it "writes precompiles the overrides" do

      filename = 'spec/dummy/app/compiled_views/posts/precompileme.html.erb'

      expect(File.exists?(filename)).to be_truthy

      file = File.open(filename, "rb")
      contents = file.read

      expect(contents).to match(/precompile/)
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

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