Sha256: e611b1b4943899becd7a3009898f7d6d160a34c6642864e7a3907a0ccd630862

Contents?: true

Size: 966 Bytes

Versions: 3

Compression:

Stored size: 966 Bytes

Contents

require 'pathname'

module Assertions
  def assert_file(path)
    assert Pathname.new(path).exist?, "#{path} does not exist."
  end

  def assert_file_removed(*expected, &block)
    files = find_files
    block.call
    assert_equal expected, files - find_files
  end

  def assert_task(expected)
    assert find_tasks.include?(expected)
  end

  def assert_task_added(*expected, &block)
    tasks = find_tasks
    block.call
    assert_equal expected, find_tasks - tasks
  end

  def assert_task_removed(*expected, &block)
    tasks = find_tasks
    block.call
    assert_equal expected, tasks - find_tasks
  end

  private

  def find_files
    pwd = Pathname.pwd
    pwd.enum_for(:find).
      select  { |path| path.file? }.
      collect { |path| path.relative_path_from(pwd) }.
      collect { |path| path.to_s }
  end

  def find_tasks
    system('rake --tasks').lines.grep(/^rake/) { |l| l.split(' ')[1] }
  end
end

Shoe::TestCase.send(:include, Assertions)

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
shoe-0.8.0 test/support/assertions.rb
shoe-0.7.1 test/support/assertions.rb
shoe-0.7.0 test/support/assertions.rb