dust-0.1.7/0000755000076400007640000000000011700330504011523 5ustar pravipravidust-0.1.7/lib/0000755000076400007640000000000011700330504012271 5ustar pravipravidust-0.1.7/lib/definition_error.rb0000644000076400007640000000077711700330504016172 0ustar pravipravimodule 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 enddust-0.1.7/lib/test_case_extension.rb0000644000076400007640000000470411700330504016671 0ustar pravipravimodule 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 enddust-0.1.7/lib/object_extension.rb0000644000076400007640000000510211700330504016156 0ustar pravipraviclass 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 if full_path_file_name == "(eval)" # jruby 1.0.2 compatibility full_path_file_name = caller[1].gsub(/\.rb:\d+.*$/, "") end 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).map { |e| e.to_s }.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 dust-0.1.7/lib/dust.rb0000644000076400007640000000100311700330504013567 0ustar pravipravirequire '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')dust-0.1.7/lib/symbol_extension.rb0000644000076400007640000000007111700330504016215 0ustar pravipraviclass Symbol #:nodoc: def arrayize [self] end enddust-0.1.7/lib/nil_extension.rb0000644000076400007640000000006711700330504015477 0ustar pravipraviclass NilClass #:nodoc: def arrayize [] end enddust-0.1.7/lib/string_extension.rb0000644000076400007640000000013111700330504016213 0ustar pravipraviclass String #:nodoc: def to_class_name gsub(/(^|_)(.)/) { $2.upcase } end end dust-0.1.7/lib/array_extension.rb0000644000076400007640000000006711700330504016033 0ustar pravipraviclass Array #:nodoc: def arrayize self end enddust-0.1.7/README0000644000076400007640000000140211700330504012400 0ustar pravipravi= 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 Harviedust-0.1.7/metadata.yml0000644000076400007640000000317011700330504014027 0ustar pravipravi--- !ruby/object:Gem::Specification name: dust version: !ruby/object:Gem::Version prerelease: version: 0.1.7 platform: ruby authors: - Jay Fields autorequire: dust bindir: bin cert_chain: [] date: 2011-12-31 00:00:00 Z dependencies: [] description: Dust is an add on for Test::Unit that allows an alternative test definintion syntax. email: dust-developer@rubyforge.org executables: [] extensions: [] extra_rdoc_files: - README files: - lib/dust.rb - lib/nil_extension.rb - lib/object_extension.rb - lib/definition_error.rb - lib/symbol_extension.rb - lib/string_extension.rb - lib/test_case_extension.rb - lib/array_extension.rb - test/passing_with_helper_unit_test.rb - test/failing_with_helper_unit_test.rb - test/functional_test.rb - test/all_tests.rb - test/failing_with_setup_unit_test.rb - test/test_helper.rb - test/passing_unit_test.rb - test/passing_with_helpers_unit_test.rb - test/passing_with_setup_unit_test.rb - rakefile.rb - README homepage: http://dust.rubyforge.org licenses: [] post_install_message: rdoc_options: - --title - Dust - --main - README - --line-numbers require_paths: - lib required_ruby_version: !ruby/object:Gem::Requirement none: false requirements: - - ">=" - !ruby/object:Gem::Version version: "0" required_rubygems_version: !ruby/object:Gem::Requirement none: false requirements: - - ">=" - !ruby/object:Gem::Version version: "0" requirements: [] rubyforge_project: dust rubygems_version: 1.7.2 signing_key: specification_version: 3 summary: Dust is an add on for Test::Unit that allows an alternative test definintion syntax. test_files: - test/all_tests.rb dust-0.1.7/rakefile.rb0000644000076400007640000000263311700330504013636 0ustar pravipravirequire '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 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.7" 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 dust-0.1.7/test/0000755000076400007640000000000011700330504012502 5ustar pravipravidust-0.1.7/test/passing_with_helper_unit_test.rb0000644000076400007640000000036111700330504021163 0ustar pravipravirequire 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 }dust-0.1.7/test/failing_with_helper_unit_test.rb0000644000076400007640000000066011700330504021132 0ustar pravipravirequire 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 } enddust-0.1.7/test/test_helper.rb0000644000076400007640000000006011700330504015341 0ustar pravipravirequire File.dirname(__FILE__) + '/../lib/dust' dust-0.1.7/test/all_tests.rb0000644000076400007640000000011511700330504015016 0ustar pravipravi$LOAD_PATH << '.' Dir['**/*_test.rb'].each { |test_case| require test_case } dust-0.1.7/test/passing_with_setup_unit_test.rb0000644000076400007640000000035311700330504021045 0ustar pravipravirequire File.expand_path(File.dirname(__FILE__) + "/test_helper") Test::Unit::TestCase.disallow_setup! unit_tests :allow => :setup do def setup end test("true"){} end Test::Unit::TestCase.class_eval { @disallow_setup = nil }dust-0.1.7/test/passing_unit_test.rb0000644000076400007640000000040311700330504016566 0ustar pravipravirequire 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 enddust-0.1.7/test/passing_with_helpers_unit_test.rb0000644000076400007640000000042211700330504021344 0ustar pravipravirequire 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 }dust-0.1.7/test/functional_test.rb0000644000076400007640000000042411700330504016230 0ustar pravipravirequire 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 enddust-0.1.7/test/failing_with_setup_unit_test.rb0000644000076400007640000000067711700330504021023 0ustar pravipravirequire File.expand_path(File.dirname(__FILE__) + "/test_helper") module Units begin unit_tests do Test::Unit::TestCase.disallow_setup! def setup end test("true") { assert_equal true, 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 end