Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Philippe Hanrigou
committed
Oct 28, 2008
1 parent
3ebbc0b
commit b7ad1f7
Showing
179 changed files
with
10,735 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
= Dust | ||
|
||
Dust adds descriptive block syntax test definition. | ||
|
||
by Jay[http://blog.jayfields.com] Fields[http://blog.jayfields.com] | ||
|
||
== Download and Installation | ||
|
||
You can download Dust from here[http://rubyforge.org/projects/dust] or install it with the following command. | ||
|
||
$ gem install dust | ||
|
||
== License | ||
|
||
You may use, copy and redistribute this library under the same terms as Ruby itself (see http://www.ruby-lang.org/en/LICENSE.txt). | ||
|
||
== Examples | ||
|
||
unit_tests do | ||
|
||
test "assert true" do | ||
assert_equal true, true | ||
end | ||
|
||
end | ||
|
||
See the tests for more examples | ||
|
||
== IDE specific files | ||
|
||
You can download TextMate and JEdit Run Focused Test Commands from http://rubyforge.org/projects/dust/ (in Files) | ||
|
||
== Contributors | ||
|
||
Dan Manges, David Vollbracht, Shane Harvie |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class Array #:nodoc: | ||
def arrayize | ||
self | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
module Dust #:nodoc: | ||
# Dust::DefinitionError is raised when you attempt to define a disallowed method within a test file. | ||
# | ||
# Test::Unit::TestCase.disallow_setup! | ||
# | ||
# unit_tests do | ||
# def setup | ||
# ... | ||
# end | ||
# | ||
# test "name" do | ||
# ... | ||
# end | ||
# end | ||
# | ||
# The above code will generate the following error | ||
# Dust::DefinitionError: setup is not allowed on class Units::[TestClassName] | ||
class DefinitionError < StandardError | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
require 'test/unit' | ||
require File.expand_path(File.dirname(__FILE__) + '/object_extension') | ||
require File.expand_path(File.dirname(__FILE__) + '/array_extension') | ||
require File.expand_path(File.dirname(__FILE__) + '/nil_extension') | ||
require File.expand_path(File.dirname(__FILE__) + '/string_extension') | ||
require File.expand_path(File.dirname(__FILE__) + '/symbol_extension') | ||
require File.expand_path(File.dirname(__FILE__) + '/test_case_extension') | ||
require File.expand_path(File.dirname(__FILE__) + '/definition_error') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class NilClass #:nodoc: | ||
def arrayize | ||
[] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
class Object | ||
# call-seq: unit_tests(options={}, &block) | ||
# | ||
# Used to define a block of unit tests. | ||
# | ||
# unit_tests do | ||
# test "verify something" do | ||
# ... | ||
# end | ||
# end | ||
# | ||
# Configuration Options: | ||
# * allow - Allows you to specify the methods that are allowed despite being disallowed. | ||
# See Test::Unit::TestCase.disallow_helpers! or Test::Unit::TestCase.disallow_setup! for more info | ||
def unit_tests(options={}, &block) | ||
do_tests("Units", options, &block) | ||
end | ||
|
||
# call-seq: functional_tests(options={}, &block) | ||
# | ||
# Used to define a block of functional tests. | ||
# | ||
# functional_tests do | ||
# test "verify something" do | ||
# ... | ||
# end | ||
# end | ||
# | ||
# Configuration Options: | ||
# * allow - Allows you to specify the methods that are allowed despite being disallowed. | ||
# See Test::Unit::TestCase.disallow_helpers! or Test::Unit::TestCase.disallow_setup! for more info | ||
def functional_tests(options={}, &block) | ||
do_tests("Functionals", options, &block) | ||
end | ||
|
||
protected | ||
def do_tests(type, options, &block) #:nodoc: | ||
options[:allow] = options[:allow].arrayize | ||
full_path_file_name = eval "__FILE__", block.binding | ||
test_name = File.basename(full_path_file_name, ".rb") | ||
test_class = eval "module #{type}; class #{test_name.to_class_name} < Test::Unit::TestCase; self; end; end" | ||
test_class.class_eval &block | ||
check_for_setup(test_class, options) | ||
check_for_helpers(test_class, options) | ||
end | ||
|
||
def check_for_setup(test_class, options) #:nodoc: | ||
if test_class.instance_methods(false).include?("setup") && Test::Unit::TestCase.disallow_setup? && | ||
!options[:allow].include?(:setup) | ||
raise Dust::DefinitionError.new("setup is not allowed on class #{test_class.name}") | ||
end | ||
end | ||
|
||
def check_for_helpers(test_class, options) #:nodoc: | ||
test_class.instance_methods(false).each do |method_name| | ||
if method_name !~ /^test_/ && Test::Unit::TestCase.disallow_helpers? && !options[:allow].include?(method_name.to_sym) | ||
p method_name.to_sym | ||
raise Dust::DefinitionError.new("helper methods are not allowed on class #{test_class.name}") | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class String #:nodoc: | ||
def to_class_name | ||
gsub(/(^|_)(.)/) { $2.upcase } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class Symbol #:nodoc: | ||
def arrayize | ||
[self] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
module Test #:nodoc: | ||
module Unit #:nodoc: | ||
class TestCase | ||
# call-seq: disallow_setup! | ||
# | ||
# Used to disallow setup methods in test specifications. | ||
# | ||
# Test::Unit::TestCase.disallow_setup! | ||
# | ||
# A test specification can override this behavior by passing :setup in the :allow options. | ||
# | ||
# unit_tests :allow => :setup do | ||
# def setup | ||
# ... | ||
# end | ||
# | ||
# test "verify something" do | ||
# ... | ||
# end | ||
# end | ||
def self.disallow_setup! | ||
@disallow_setup = true | ||
end | ||
|
||
def self.disallow_setup? #:nodoc: | ||
@disallow_setup | ||
end | ||
|
||
# call-seq: disallow_helpers! | ||
# | ||
# Used to disallow helper methods in test specifications. | ||
# | ||
# Test::Unit::TestCase.disallow_helper! | ||
# | ||
# A test specification can override this behavior by passing the helper name (as a symbol) in the :allow options. | ||
# | ||
# unit_tests :allow => [:create_something, :destroy_something] do | ||
# test "verify something" do | ||
# ... | ||
# end | ||
# | ||
# def create_something | ||
# ... | ||
# end | ||
# | ||
# def destroy_something | ||
# ... | ||
# end | ||
# end | ||
def self.disallow_helpers! | ||
@disallow_helpers = true | ||
end | ||
|
||
def self.disallow_helpers? #:nodoc: | ||
@disallow_helpers | ||
end | ||
|
||
# call-seq: test(name, &block) | ||
# | ||
# Used to define a test and assign it a descriptive name. | ||
# | ||
# unit_tests do | ||
# test "verify something" do | ||
# ... | ||
# end | ||
# end | ||
def self.test(name, &block) | ||
test_name = "test_#{name.gsub(/[\s]/,'_')}".to_sym | ||
raise "#{test_name} is already defined in #{self}" if self.instance_methods.include? test_name.to_s | ||
define_method test_name do | ||
instance_eval &block | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
require 'rubygems' | ||
require 'rake/gempackagetask' | ||
require 'rake/rdoctask' | ||
require 'rake/contrib/sshpublisher' | ||
|
||
task :default => :test | ||
|
||
task :test do | ||
require File.dirname(__FILE__) + '/test/all_tests.rb' | ||
end | ||
|
||
desc 'Generate RDoc' | ||
Rake::RDocTask.new do |task| | ||
task.main = 'README' | ||
task.title = 'Dust' | ||
task.rdoc_dir = 'doc' | ||
task.options << "--line-numbers" << "--inline-source" | ||
task.rdoc_files.include('README', 'lib/**/*.rb') | ||
end | ||
|
||
desc "Upload RDoc to RubyForge" | ||
task :publish_rdoc => [:rdoc] do | ||
Rake::SshDirPublisher.new("jaycfields@rubyforge.org", "/var/www/gforge-projects/dust", "doc").upload | ||
end | ||
|
||
Gem::manage_gems | ||
|
||
specification = Gem::Specification.new do |s| | ||
s.name = "dust" | ||
s.summary = "Dust is an add on for Test::Unit that allows an alternative test definintion syntax." | ||
s.version = "0.1.6" | ||
s.author = 'Jay Fields' | ||
s.description = "Dust is an add on for Test::Unit that allows an alternative test definintion syntax." | ||
s.email = 'dust-developer@rubyforge.org' | ||
s.homepage = 'http://dust.rubyforge.org' | ||
s.rubyforge_project = 'dust' | ||
|
||
s.has_rdoc = true | ||
s.extra_rdoc_files = ['README'] | ||
s.rdoc_options << '--title' << 'Dust' << '--main' << 'README' << '--line-numbers' | ||
|
||
s.autorequire = 'dust' | ||
s.files = FileList['{lib,test}/**/*.rb', '[A-Z]*$', 'rakefile.rb'].to_a | ||
s.test_file = "test/all_tests.rb" | ||
end | ||
|
||
Rake::GemPackageTask.new(specification) do |package| | ||
package.need_zip = false | ||
package.need_tar = false | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Dir['**/*_test.rb'].each { |test_case| require test_case } |
16 changes: 16 additions & 0 deletions
16
vendor/gems/dust-0.1.6/test/failing_with_helper_unit_test.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
require File.expand_path(File.dirname(__FILE__) + "/test_helper") | ||
|
||
begin | ||
unit_tests do | ||
Test::Unit::TestCase.disallow_helpers! | ||
def helper_method | ||
end | ||
|
||
test("true"){} | ||
end | ||
raise "shouldn't be here" | ||
rescue Dust::DefinitionError => ex | ||
raise unless ex.message == "helper methods are not allowed on class Units::FailingWithHelperUnitTest" | ||
ensure | ||
Test::Unit::TestCase.class_eval { @disallow_helpers = nil } | ||
end |
16 changes: 16 additions & 0 deletions
16
vendor/gems/dust-0.1.6/test/failing_with_setup_unit_test.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
require File.expand_path(File.dirname(__FILE__) + "/test_helper") | ||
|
||
begin | ||
unit_tests do | ||
Test::Unit::TestCase.disallow_setup! | ||
def setup | ||
end | ||
|
||
test("true"){} | ||
end | ||
raise "shouldn't be here" | ||
rescue Dust::DefinitionError => ex | ||
raise unless ex.message == "setup is not allowed on class Units::FailingWithSetupUnitTest" | ||
ensure | ||
Test::Unit::TestCase.class_eval { @disallow_setup = nil } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
require File.expand_path(File.dirname(__FILE__) + "/test_helper") | ||
|
||
functional_tests do | ||
test "assert true" do | ||
assert_equal true, true | ||
end | ||
|
||
test "class name is Functionals::FunctionalTest" do | ||
assert_equal "Functionals::FunctionalTest", self.class.name | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
require File.expand_path(File.dirname(__FILE__) + "/test_helper") | ||
|
||
unit_tests do | ||
test "assert true" do | ||
assert_equal true, true | ||
end | ||
|
||
test "class name is Units::PassingUnitTest" do | ||
assert_equal "Units::PassingUnitTest", self.class.name | ||
end | ||
end |
10 changes: 10 additions & 0 deletions
10
vendor/gems/dust-0.1.6/test/passing_with_helper_unit_test.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
require File.expand_path(File.dirname(__FILE__) + "/test_helper") | ||
|
||
Test::Unit::TestCase.disallow_helpers! | ||
unit_tests :allow => :helper do | ||
def helper | ||
end | ||
|
||
test("true"){} | ||
end | ||
Test::Unit::TestCase.class_eval { @disallow_helpers = nil } |
13 changes: 13 additions & 0 deletions
13
vendor/gems/dust-0.1.6/test/passing_with_helpers_unit_test.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
require File.expand_path(File.dirname(__FILE__) + "/test_helper") | ||
|
||
Test::Unit::TestCase.disallow_helpers! | ||
unit_tests :allow => [:helper, :helper2] do | ||
def helper | ||
end | ||
|
||
def helper2 | ||
end | ||
|
||
test("true"){} | ||
end | ||
Test::Unit::TestCase.class_eval { @disallow_helpers = nil } |
Oops, something went wrong.