Sha256: 5a18bbb45f2e3302e4de8433529f21d94e6c4e01443f287094c2b83aa75ddd97

Contents?: true

Size: 1.09 KB

Versions: 7

Compression:

Stored size: 1.09 KB

Contents

require 'open3'
module FaaStRuby
  module Command
    module Function
      class Test < FunctionBaseCommand
        def initialize(args)
          @args = args
          load_yaml
          @function_name = @yaml_config['name']
          @test_command = @yaml_config['test_command']
        end

        def run(do_not_exit: false)
          unless @test_command
            puts "[skipped] You have no 'test_command' key/value in 'faastruby.yml'. Please consider using rspec!".yellow
            return true
          end
          spinner = spin("Running tests...")
          output, status = Open3.capture2e(@test_command)
          if status == 0
            spinner.stop('Passed!')
            puts output
            return true
          else
            spinner.stop('Failed :(')
            FaaStRuby::CLI.error(output, color: nil) unless do_not_exit
            puts output if do_not_exit
            return false
          end
        end

        def self.help
          'test'.blue
        end

        def usage
          "Usage: faastruby #{self.class.help}"
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
faastruby-0.3.1 lib/faastruby/cli/commands/function/test.rb
faastruby-0.2.6 lib/faastruby/cli/commands/function/test.rb
faastruby-0.2.5 lib/faastruby/cli/commands/function/test.rb
faastruby-0.2.3 lib/faastruby/cli/commands/function/test.rb
faastruby-0.2.2 lib/faastruby/cli/commands/function/test.rb
faastruby-0.2.1 lib/faastruby/cli/commands/function/test.rb
faastruby-0.2.0 lib/faastruby/cli/commands/function/test.rb