diff options
| -rw-r--r-- | Rakefile | 10 | ||||
| -rw-r--r-- | test/cli_test.rb | 20 | ||||
| -rw-r--r-- | test/test_helper.rb | 34 | 
3 files changed, 64 insertions, 0 deletions
| diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..765e5bd --- /dev/null +++ b/Rakefile @@ -0,0 +1,10 @@ +require 'rubygems' +require 'rake' + +require 'rake/testtask' +Rake::TestTask.new(:test) do |test| +  test.libs << 'lib' << 'test' +  test.pattern = 'test/**/*_test.rb' +end + +task :default => [:test]
\ No newline at end of file diff --git a/test/cli_test.rb b/test/cli_test.rb new file mode 100644 index 0000000..4dc1eb3 --- /dev/null +++ b/test/cli_test.rb @@ -0,0 +1,20 @@ +require 'test_helper' +silent{ load 'bin/dashing' } + +module Thor::Actions +  def source_paths +    [File.join(File.expand_path(File.dirname(__FILE__)), '../templates')] +  end +end + +class CliTest < Dashing::Test + +  def test_project_directory_created +    temp do |dir| +      cli = Dashing::CLI.new +      silent{ cli.new 'Dashboard' } +      assert Dir.exist?(File.join(dir,'dashboard')), 'Dashing directory was not created.' +    end +  end + +end
\ No newline at end of file diff --git a/test/test_helper.rb b/test/test_helper.rb new file mode 100644 index 0000000..d2337c5 --- /dev/null +++ b/test/test_helper.rb @@ -0,0 +1,34 @@ +require 'rack/test' +require 'stringio' +require 'test/unit' +require 'tmpdir' + +ENV['RACK_ENV'] = 'test' +WORKING_DIRECTORY = Dir.pwd.freeze +ARGV.clear + +def silent +  _stdout = $stdout +  $stdout = mock = StringIO.new +  begin +    yield +  ensure +    $stdout = _stdout +  end +end + +def temp +  path = File.expand_path "#{Dir.tmpdir}/#{Time.now.to_i}#{rand(1000)}/" +  FileUtils.mkdir_p path +  Dir.chdir path +  yield path +ensure +  Dir.chdir WORKING_DIRECTORY +  FileUtils.rm_rf(path) if File.exists?(path) +end + +module Dashing +  class Test < Test::Unit::TestCase +    include Rack::Test::Methods +  end +end
\ No newline at end of file | 
