Sha256: e4a6a984a7d3ed0d8f043f8303fa95113dd85b487f09bee333749dc1977b7062

Contents?: true

Size: 1004 Bytes

Versions: 2

Compression:

Stored size: 1004 Bytes

Contents

require File.expand_path("command_base", __dir__)
require "cardio"

module Cardio
  class Command
    # enhance standard RSpec command with some decko/card -specific options
    class RspecCommand < CommandBase
      def initialize args
        require "rspec/core"

        cardio_args, @rspec_args = split_args args
        @opts = {}
        Parser.new(@opts).parse!(cardio_args)
      end

      def command
        "#{env_args} #{@opts[:executer]} #{@opts[:rescue]}" \
          "rspec #{@rspec_args.shelljoin} #{@opts[:files]}"
        # .tap { |c| puts c.yellow }
      end

      private

      def env_args
        ["RAILS_ROOT=.", coverage].compact.join " "
      end

      def coverage
        if @opts[:simplecov]
          "CARD_LOAD_STRATEGY=tmp_files"
        elsif @opts[:files]
          # explicitly no coverage if rs pec was started with file argument
          "CARD_SIMPLECOV=false"
        end
      end
    end
  end
end

require File.expand_path("rspec_command/parser", __dir__)

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
card-1.108.1 lib/cardio/command/rspec_command.rb
card-1.108.0 lib/cardio/command/rspec_command.rb