Sha256: 7639aff92ccb1aa71b23f6f93f45e21f85386bff182c2fcb0aa438879160d6fb

Contents?: true

Size: 904 Bytes

Versions: 3

Compression:

Stored size: 904 Bytes

Contents

require File.expand_path("command", __dir__)

module Cardio
  class Commands
    # enhance standard RSpec command with some decko/card -specific options
    class RspecCommand < Command
      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]}"
      end

      private

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

      def coverage
        return if @opts[:simplecov]

        # no coverage if rspec was started with file argument
        return unless @opts[:files] || @rspec_args.any?

        "COVERAGE=false"
      end
    end
  end
end

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
card-1.104.2 lib/cardio/commands/rspec_command.rb
card-1.104.1 lib/cardio/commands/rspec_command.rb
card-1.104.0 lib/cardio/commands/rspec_command.rb