Sha256: bd202a16f7f58b49f3c34ec600d53fca8b82d0b0a1b706b67d21709d17d27e0e

Contents?: true

Size: 1.02 KB

Versions: 19

Compression:

Stored size: 1.02 KB

Contents

require "aruba"
require "aruba/api"
require "pathname"

module RSpec
  module Support
    module Cli
      def self.included(spec)
        spec.before do
          aruba = Pathname.new(Dir.pwd).join('tmp', 'aruba')
          aruba.rmtree if aruba.exist?

          setup_aruba
        end
      end

      private

      def run_command(cmd, output = nil, exit_status: 0)
        run_simple "bundle exec #{cmd}", fail_on_error: false

        match_output(output)
        expect(last_command_started).to have_exit_status(exit_status)
      end

      def match_output(output)
        case output
        when String
          expect(all_output).to include(output)
        when Regexp
          expect(all_output).to match(output)
        when Array
          output.each { |o| match_output(o) }
        end
      end

      def all_output
        all_commands.map(&:output).join("\n")
      end
    end
  end
end

RSpec.configure do |config|
  config.include Aruba::Api,          type: :cli
  config.include RSpec::Support::Cli, type: :cli
end

Version data entries

19 entries across 19 versions & 2 rubygems

Version Path
dry-web-web_pipe-0.2.0 spec/support/cli.rb
dry-web-roda-0.13.1 spec/support/cli.rb
dry-web-roda-0.13.0 spec/support/cli.rb
dry-web-web_pipe-0.1.0 spec/support/cli.rb
dry-web-roda-0.12.0 spec/support/cli.rb
dry-web-roda-0.11.0 spec/support/cli.rb
dry-web-roda-0.10.0 spec/support/cli.rb
dry-web-roda-0.9.1 spec/support/cli.rb
dry-web-roda-0.9.0 spec/support/cli.rb
dry-web-roda-0.8.0 spec/support/cli.rb
dry-web-roda-0.7.5 spec/support/cli.rb
dry-web-roda-0.7.4 spec/support/cli.rb
dry-web-roda-0.7.3 spec/support/cli.rb
dry-web-roda-0.7.2 spec/support/cli.rb
dry-web-roda-0.7.1 spec/support/cli.rb
dry-web-roda-0.7.0 spec/support/cli.rb
dry-web-roda-0.6.3 spec/support/cli.rb
dry-web-roda-0.6.2 spec/support/cli.rb
dry-web-roda-0.6.1 spec/support/cli.rb