Sha256: 02a0d739b8220cc9d93b79f8b75e0776037d9fa40c7cdf37c55f23e2d2946f64

Contents?: true

Size: 878 Bytes

Versions: 6

Compression:

Stored size: 878 Bytes

Contents

class Lono::CLI
  class Test
    def initialize(options={})
      @options = options
    end

    def run
      config = Lono.config
      test_command = config.test.framework
      execute(test_command)
    end

    def execute(command)
      command = adjust_command(command)
      puts "=> #{command}"
      Kernel.exec(command)
    end

    def adjust_command(command)
      if cd_into_test?
        command = "bundle exec #{command}" unless command.include?("bundle exec")
        command = "cd test && #{command}"
      else
        command
      end
    end

    # Automatically cd into the test folder in case running within the root of a module.
    # Detect/guess that we're in a module folder vs the lono project
    def cd_into_test?
      !File.exist?("app") && File.exist?("test") &&
      (File.exist?("template.rb") || File.exist?("template"))
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
lono-8.0.0.pre.rc6 lib/lono/cli/test.rb
lono-8.0.0.pre.rc5 lib/lono/cli/test.rb
lono-8.0.0.pre.rc4 lib/lono/cli/test.rb
lono-8.0.0.pre.rc3 lib/lono/cli/test.rb
lono-8.0.0.pre.rc2 lib/lono/cli/test.rb
lono-8.0.0.pre.rc1 lib/lono/cli/test.rb