Sha256: afb59ee75d67e4c3c36d4febfa34b2892c5f538a562de9a888574756885f50d3

Contents?: true

Size: 1.27 KB

Versions: 10

Compression:

Stored size: 1.27 KB

Contents

require './test/test_helper'
require './lib/versioncake/cli'

class CliTest < ActiveSupport::TestCase

  setup do
    File.stubs :rename
    capture_stdout(true)
  end

  teardown do
    capture_stdout(false)
  end

  def capture_stdout(flag=true)
    if flag
      out     = StringIO.new
      $stdout = out
    else
      $stdout = STDOUT
    end
  end

  test 'it can detect old file names' do
    renamed_files = VersionCake::Cli.new.migrate('./test/fixtures/templates')
    assert_equal 2, renamed_files.size
  end

  test 'it renames old filenames to new filenames' do
    renamed_files = VersionCake::Cli.new.migrate('./test/fixtures/templates')
    expected_renamed_files = [
        ['./test/fixtures/templates/v1_extension_scheme.v3.html.erb', './test/fixtures/templates/v1_extension_scheme.html.v3.erb'],
        ['./test/fixtures/templates/v1_extension_scheme.v6.json', './test/fixtures/templates/v1_extension_scheme.json.v6']
    ]
    assert_empty expected_renamed_files - renamed_files
  end

  test 'it reports no files changed when new filenames exist' do
    assert_empty VersionCake::Cli.new.migrate('./test/app/views')
  end

  test 'it raises if it cannot find the path' do
    assert_raises ArgumentError do
      VersionCake::Cli.new.migrate('./a/missing/path')
    end
  end

end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
solidus_backend-1.0.0.pre3 vendor/bundle/gems/versioncake-2.3.1/test/unit/cli_test.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/versioncake-2.3.1/test/unit/cli_test.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/versioncake-2.3.1/test/unit/cli_test.rb
versioncake-2.5.0 test/unit/cli_test.rb
versioncake-2.4.0 test/unit/cli_test.rb
versioncake-2.3.1 test/unit/cli_test.rb
versioncake-2.3.0 test/unit/cli_test.rb
versioncake-2.2.0 test/unit/cli_test.rb
versioncake-2.1.0 test/unit/cli_test.rb
versioncake-2.0.0 test/unit/cli_test.rb