Sha256: 279f2d10c38aba1e413349aa07abcd6c69cc741354a2a3508111b097b6b7702e

Contents?: true

Size: 1.49 KB

Versions: 3

Compression:

Stored size: 1.49 KB

Contents

require 'rails_helper'
require 'byebug'

RSpec.describe KepplerFrontend::Views::HtmlHandler, type: :services do

  before(:each) do
    @view = create(:keppler_frontend_views, method: "GET")
    @html = KepplerFrontend::Views::HtmlHandler.new(@view)
  end

  let(:front) { KepplerFrontend::Urls::Front.new }

  let(:view_installed) { @html.install }

  let(:view_html) { File.read(front.view(@view.name)) }

  context 'install' do
    it { expect(view_installed).to eq(true) }
    it { expect(File.exist?(front.view(@view.name))).to eq(true) }
    it { expect(view_html).to eq("<keppler-view id=\"test_index\">\n  <h1> test_index template </h1>\n</keppler-view>\n") }
  end

  context 'output' do 
    it { expect(@html.output).to eq("  <h1> test_index template </h1>\n") }
  end

  context 'save code' do
    it { expect(@html.save('<h1> New Title </h1>')).to eq(true) }
    it { expect(@html.output).to eq("  <h1> New Title </h1>\n") }
  end

  context 'update' do
    let(:view_updated) { @html.update("other_name") }

    it { expect(view_updated).to eq(true) }
    it { expect(File.exist?(front.view("other_name"))).to eq(true) }
    it { expect(File.exist?(front.view(@view.name))).to eq(false) }
  end

  context 'uninstall' do
    let(:view_uninstalled) do
      @view.name = 'other_name'
      @html = KepplerFrontend::Views::HtmlHandler.new(@view)
      @html.uninstall
    end
    
    it { expect(view_uninstalled).to eq(true) }
    it { expect(File.exist?(front.view(@view.name))).to eq(false) }
  end

  
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
keppler-2.1.18 installer/core/spec/services/keppler_frontend/views/html_handler_spec.rb
keppler-2.1.17 installer/core/spec/services/keppler_frontend/views/html_handler_spec.rb
keppler-2.1.16 installer/core/spec/services/keppler_frontend/views/html_handler_spec.rb