Sha256: 7c9db6b9a03d741f659cad5a1067d0ee8141c2afb10ead71afe6bf980b87597c

Contents?: true

Size: 749 Bytes

Versions: 4

Compression:

Stored size: 749 Bytes

Contents

require 'coverage_helper'
require 'minitest/autorun'
require 'minitest/colorin'
require 'yaml'
require 'datacenter'
require 'pry-nav'

class Module
  include Minitest::Spec::DSL
end

module Datacenter
  module Shell
    class Mock

      def initialize(file=nil)
        @commands = file ? YAML.load_file(file) : {}
      end

      def stub(command, value=nil, &block)
        commands[command] = value || block.call
      end

      def run(command)
        raise "Undefined command: #{command}" unless commands.key? command
        commands[command]
      end

      private

      attr_reader :commands

    end

  end
end

class Minitest::Spec
  let(:mock_shell) { Datacenter::Shell::Mock.new File.expand_path('../commands.yml', __FILE__) }
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
datacenter-0.5.1 spec/minitest_helper.rb
datacenter-0.5.0 spec/minitest_helper.rb
datacenter-0.4.4 spec/minitest_helper.rb
datacenter-0.4.3 spec/minitest_helper.rb