Sha256: 9ce1b6c8d9c011aaec44a5cf0816a90a2a1d0f5d2044f4fd85c952533a779adc

Contents?: true

Size: 1.15 KB

Versions: 1

Compression:

Stored size: 1.15 KB

Contents

# frozen_string_literal: true

require 'spec_helper'
require 'generator_spec'
require 'generators/solidus_starter_frontend/views/override_generator'

RSpec.describe SolidusStarterFrontend::Views::OverrideGenerator, type: :generator do
  destination Rails.root.join('app', 'views', 'spree')

  before(:all) do
    prepare_destination
  end

  subject! do
    run_generator arguments
  end

  let(:src) do
    ::SolidusStarterFrontend::Engine.root.join('app', 'views', 'spree')
  end

  let(:dest) do
    Rails.root.join('app', 'views', 'spree')
  end

  context 'without any arguments' do
    let(:arguments) { %w() }

    it 'copies all views into the host app' do
      expect(src.entries).to match_array(dest.entries)
    end
  end

  context 'when "products" is passed as --only argument' do
    let(:arguments) { %w(--only products) }

    context 'as folder' do
      it 'exclusively copies views whose name contains "products"' do
        Dir.glob(dest.join("**", "*")).each do |file|
          next if File.directory?(file)
          expect(file.to_s).to match("products")
        end
      end
    end
  end

  after do
    FileUtils.rm_rf destination_root
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
solidus_starter_frontend-0.1.0 spec/generators/solidus/views/override_generator_spec.rb