Sha256: 9f3eff8c5aeb19dc51a1475a246fb5c9bdd0b897cd66e2ebc40466d9439f15a5

Contents?: true

Size: 1.66 KB

Versions: 6

Compression:

Stored size: 1.66 KB

Contents

require 'test_helper'
require_relative '../../../../lib/nesta/commands'

describe 'nesta theme:install' do
  include TemporaryFiles

  def theme_name
    'test'
  end

  def repo_url
    "../../fixtures/nesta-theme-#{theme_name}.git"
  end

  def theme_dir
    project_path("themes/#{theme_name}")
  end

  before do
    FileUtils.mkdir_p(project_root)
  end

  after do
    remove_temp_directory
  end

  def process_stub
    Object.new.tap do |stub|
      def stub.run(*args); end
    end
  end

  it 'clones the repository' do
    process = Minitest::Mock.new
    process.expect(:run, true, ['git', 'clone', repo_url, "themes/#{theme_name}"])
    in_temporary_project do
      Nesta::Commands::Theme::Install.new(repo_url).execute(process)
    end
  end

  it "removes the theme's .git directory" do
    in_temporary_project do
      Nesta::Commands::Theme::Install.new(repo_url).execute(process_stub)
      refute File.exist?("#{theme_dir}/.git"), '.git folder found'
    end
  end

  it 'enables the freshly installed theme' do
    in_temporary_project do
      Nesta::Commands::Theme::Install.new(repo_url).execute(process_stub)
      assert_match /theme: #{theme_name}/, File.read('config/config.yml')
    end
  end

  it 'determines name of theme from name of repository' do
    url = 'https://foobar.com/path/to/nesta-theme-the-name.git'
    command = Nesta::Commands::Theme::Install.new(url)
    assert_equal 'the-name', command.theme_name
  end

  it "falls back to name of repo when theme name doesn't match correct format" do
    url = 'https://foobar.com/path/to/mytheme.git'
    command = Nesta::Commands::Theme::Install.new(url)
    assert_equal 'mytheme', command.theme_name
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
nesta-0.18.0 test/integration/commands/theme/install_test.rb
nesta-0.17.0 test/integration/commands/theme/install_test.rb
nesta-0.16.0 test/integration/commands/theme/install_test.rb
nesta-0.15.0 test/integration/commands/theme/install_test.rb
nesta-0.14.0 test/integration/commands/theme/install_test.rb
nesta-0.13.0 test/integration/commands/theme/install_test.rb