pax_global_header00006660000000000000000000000064121454741310014514gustar00rootroot0000000000000052 comment=358153cb62e84471fbf693e0afc940625591d854 ruby-shindo-0.3.5/000077500000000000000000000000001214547413100137645ustar00rootroot00000000000000ruby-shindo-0.3.5/Gemfile000066400000000000000000000000461214547413100152570ustar00rootroot00000000000000source "http://rubygems.org" gemspec ruby-shindo-0.3.5/README.rdoc000066400000000000000000000104741214547413100156000ustar00rootroot00000000000000= shindo Simple depth first ruby testing, watch and learn. == Writing tests Tests group similar assertions, but their return value is ignored. After that you just test based on the two things a ruby thing should do, raise or return. Returns takes what you expect and checks a block to see if the return value matches: Shindo.tests do returns(true) { true } returns(false) { false } end Raises takes what error you expect and checks to see if the block will raise it: Shindo.tests do raises(StandardError) { raise StandardError.new } end For one off simple tests like this you can also chain the calls like this: Shindo.tests('raises').raises(StandardError) { raise StandardError.new } You can also override the default descriptions: Shindo.tests('foo/bar') do returns('foo', 'returns foo when bar') { 'foo' } raises(StandardError, 'raises StandardError when baz') { raise StandardError } end Or nest things inside tests blocks: Shindo.tests do tests('returns') do returns('foo', 'returns foo when bar') { 'foo' } returns('bar', 'returns bar when baz') { 'bar' } end tests('raises') do raises(StandardError, 'raises StandardError when baz') { raise StandardError } raises(StandardError, 'raises StandardError when qux') { raise StandardError } end end Then, if you want to get real fancy you can also tag your tests, to help narrow down which ones to run Shindo.tests('tests for foo', 'foo') do test('foo') { true } end Shindo.tests('tests for bar', 'bar') do test('bar') { true } end Note: you'll have to supply a non-default description first, and then follow up with tags. == Setup and Teardown Tests get evaluated in the file just like you see it so you can add setup and teardown easily: Shindo.tests do foo = 'bar' # setup tests('foo').returns('bar') { foo } foo = 'baz' # cleanup after last tests('foo').returns('baz') { foo } foo = nil # teardown end That can get pretty tedious if it needs to happen before or after every single test though, so there are helpers: Shindo.tests do before do @object = Object.new end after do @object = nil end tests('@object.class').returns(Object) { @object.class } end == Running tests Run tests with the shindo command, the easiest is to specify a file name: shindo something_tests.rb You can also give directories and it will run all files ending in _tests.rb and include all files ending in _helper.rb (recurses through subdirectories) shindo some_test_directory That leaves tags, which use +/-. So run just tests with the 'foo' tag: shindo some_test_directory +foo Or those without the 'bar' tag: shindo some_test_directory -bar Or combine to run everything with a foo tag, but no bar tag shindo some_test_directory +foo -bar If you are running in a non-interactive mode, or one where speed matters (i.e. continuous integration), you can run shindo with (n)o (t)race and much quieter output. It takes all the same arguments, but uses the shindont bin file. shindont something_tests.rb == Command line tools When tests fail you'll get lots of options to help you debug the problem, just enter '?' at the prompt to see your options. == Copyright (The MIT License) Copyright (c) 2009 {geemus (Wesley Beary)}[http://github.com/geemus] Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ruby-shindo-0.3.5/Rakefile000066400000000000000000000067441214547413100154440ustar00rootroot00000000000000require 'rubygems' require 'rake' require 'date' ############################################################################# # # Helper functions # ############################################################################# def name @name ||= Dir['*.gemspec'].first.split('.').first end def version line = File.read("lib/#{name}.rb")[/^\s*VERSION\s*=\s*.*/] line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1] end def date Date.today.to_s end def rubyforge_project name end def gemspec_file "#{name}.gemspec" end def gem_file "#{name}-#{version}.gem" end def replace_header(head, header_name) head.sub!(/(\.#{header_name}\s*= ').*'/) { "#{$1}#{send(header_name)}'"} end ############################################################################# # # Standard tasks # ############################################################################# require File.join(File.dirname(__FILE__), 'lib', 'shindo', 'rake') Shindo::Rake.new task :default => :tests desc "Generate RCov test coverage and open in your browser" task :coverage do require 'rcov' sh "rm -fr coverage" sh "rcov test/test_*.rb" sh "open coverage/index.html" end require 'rdoc/task' Rake::RDocTask.new do |rdoc| rdoc.rdoc_dir = 'rdoc' rdoc.title = "#{name} #{version}" rdoc.rdoc_files.include('README*') rdoc.rdoc_files.include('lib/**/*.rb') end desc "Open an irb session preloaded with this library" task :console do sh "irb -rubygems -r ./lib/#{name}.rb" end ############################################################################# # # Custom tasks (add your own tasks here) # ############################################################################# ############################################################################# # # Packaging tasks # ############################################################################# task :release => :build do unless `git branch` =~ /^\* master$/ puts "You must be on the master branch to release!" exit! end sh "gem install pkg/#{name}-#{version}.gem" sh "git commit --allow-empty -a -m 'Release #{version}'" sh "git tag v#{version}" sh "git push origin master" sh "git push origin v#{version}" sh "gem push pkg/#{name}-#{version}.gem" end task :build => :gemspec do sh "mkdir -p pkg" sh "gem build #{gemspec_file}" sh "mv #{gem_file} pkg" end task :gemspec => :validate do # read spec file and split out manifest section spec = File.read(gemspec_file) head, manifest, tail = spec.split(" # = MANIFEST =\n") # replace name version and date replace_header(head, :name) replace_header(head, :version) replace_header(head, :date) #comment this out if your rubyforge_project has a different name replace_header(head, :rubyforge_project) # determine file list from git ls-files files = `git ls-files`. split("\n"). sort. reject { |file| file =~ /^\./ }. reject { |file| file =~ /^(rdoc|pkg)/ }. map { |file| " #{file}" }. join("\n") # piece file back together and write manifest = " s.files = %w[\n#{files}\n ]\n" spec = [head, manifest, tail].join(" # = MANIFEST =\n") File.open(gemspec_file, 'w') { |io| io.write(spec) } puts "Updated #{gemspec_file}" end task :validate do libfiles = Dir['lib/*'] - ["lib/#{name}.rb", "lib/#{name}"] unless libfiles.empty? puts "Directory `lib` should only contain a `#{name}.rb` file and `#{name}` dir." exit! end unless Dir['VERSION*'].empty? puts "A `VERSION` file at root level violates Gem best practices." exit! end end ruby-shindo-0.3.5/bin/000077500000000000000000000000001214547413100145345ustar00rootroot00000000000000ruby-shindo-0.3.5/bin/shindo000077500000000000000000000003661214547413100157530ustar00rootroot00000000000000#!/usr/bin/env ruby @thread_locals = { :interactive => true } require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'shindo', 'verbose')) require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'shindo', 'bin')) ruby-shindo-0.3.5/bin/shindont000077500000000000000000000003701214547413100163100ustar00rootroot00000000000000#!/usr/bin/env ruby @thread_locals = { :interactive => false } require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'shindo', 'taciturn')) require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'shindo', 'bin')) ruby-shindo-0.3.5/lib/000077500000000000000000000000001214547413100145325ustar00rootroot00000000000000ruby-shindo-0.3.5/lib/shindo.rb000066400000000000000000000140501214547413100163430ustar00rootroot00000000000000require 'formatador' module Shindo class Pending < StandardError; end unless const_defined?(:VERSION) VERSION = '0.3.5' end def self.tests(description = nil, tags = [], &block) STDOUT.sync = true Shindo::Tests.new(description, tags, &block) end class Tests def initialize(description, tags = [], &block) @afters = [] @befores = [] @description_stack = [] @tag_stack = [] Thread.current[:reload] = false Thread.current[:tags] ||= [] Thread.current[:totals] ||= { :failed => 0, :pending => 0, :skipped => 0, :succeeded => 0 } @if_tagged = [] @unless_tagged = [] for tag in Thread.current[:tags] case tag[0...1] when '+' @if_tagged << tag[1..-1] when '-' @unless_tagged << tag[1..-1] end end Formatador.display_line tests(description, tags, &block) end def after(&block) @afters.last.push(block) end def before(&block) @befores.last.push(block) end def pending raise(Shindo::Pending.new) end def tests(description, tags = [], &block) return self if Thread.main[:exit] || Thread.current[:reload] tags = [*tags].collect { |tag| tag.to_s } @tag_stack.push(tags) @befores.push([]) @afters.push([]) @description = nil @inline = false description ||= 'Shindo.tests' description = "[bold]#{description}[normal]" unless tags.empty? description << " (#{tags.join(', ')})" end @description_stack.push(description) # if the test includes +tags and discludes -tags, evaluate it if (@if_tagged.empty? || !(@if_tagged & @tag_stack.flatten).empty?) && (@unless_tagged.empty? || (@unless_tagged & @tag_stack.flatten).empty?) if block_given? begin display_description(description) # HACK: increase indent indent = Thread.current[:formatador].instance_variable_get(:@indent) Thread.current[:formatador].instance_variable_set(:@indent, indent + 1) instance_eval(&block) rescue Shindo::Pending display_pending(description) rescue => error display_error(error) ensure # HACK: decrease indent indent = Thread.current[:formatador].instance_variable_get(:@indent) Thread.current[:formatador].instance_variable_set(:@indent, indent - 1) end else @inline = true display_description(description) end else display_description("[light_black]#{description}[/]") end @description_stack.pop @afters.pop @befores.pop @tag_stack.pop Thread.exit if Thread.main[:exit] || Thread.current[:reload] self end def raises(error, description = "raises #{error.inspect}", &block) assert(:raises, error, description, &block) end def returns(expectation, description = "returns #{expectation.inspect}", &block) assert(:returns, expectation, description, &block) end def test(description = 'returns true', &block) assert(:returns, true, description, &block) end private def assert(type, expectation, description, &block) return if Thread.main[:exit] || Thread.current[:reload] description = [@description, description].compact.join(' ') if block_given? begin for before in @befores.flatten.compact before.call end value, success = case type when :raises value = begin instance_eval(&block) rescue Shindo::Pending @pending = true rescue => error error end [value, value.is_a?(expectation)] when :returns [value = instance_eval(&block), value == expectation] end for after in @afters.flatten.compact after.call end rescue Shindo::Pending @pending = true rescue => error success = false value = error end if @pending @pending = false display_pending(description) elsif success display_success(description) else display_failure(description) case value when Exception, Interrupt display_error(value) else @message ||= [ "expected => #{expectation.inspect}", "returned => #{value.inspect}" ] Formatador.indent do Formatador.display_lines([*@message].map {|message| "[red]#{message}[/]"}) end @message = nil end if Thread.current[:interactive] && STDOUT.tty? prompt(description, &block) end end else display_pending(description) end success end def prompt(description, &block) return if Thread.main[:exit] || Thread.current[:reload] Formatador.display("Action? [c,q,r,?]? ") choice = STDIN.gets.strip continue = false Formatador.display_line Formatador.indent do case choice when 'c', 'continue' continue = true when 'q', 'quit', 'exit' Formatador.display_line("Exiting...") Thread.main[:exit] = true when 'r', 'reload' Formatador.display_line("Reloading...") Thread.current[:reload] = true when '?', 'help' Formatador.display_lines([ 'c - ignore this error and continue', 'q - quit Shindo', 'r - reload and run the tests again', '? - display help' ]) else Formatador.display_line("[red]#{choice} is not a valid choice, please try again.[/]") end Formatador.display_line end unless continue || Thread.main[:exit] Formatador.display_line("[red]- #{description}[/]") prompt(description, &block) end end end end ruby-shindo-0.3.5/lib/shindo/000077500000000000000000000000001214547413100160165ustar00rootroot00000000000000ruby-shindo-0.3.5/lib/shindo/bin.rb000066400000000000000000000044731214547413100171230ustar00rootroot00000000000000require File.join(File.dirname(__FILE__), '..', 'shindo') @interrupt = lambda do unless Thread.main[:exit] Formatador.display_line('Gracefully Exiting... (ctrl-c to force)') Thread.main[:exit] = true else Formatador.display_line('Exiting...') Thread.exit end end Kernel.trap('INT', @interrupt) # if lib dir is available add it to load path if File.directory?('lib') lib_dir = File.expand_path('lib') unless $LOAD_PATH.include?(lib_dir) $LOAD_PATH.unshift(lib_dir) end end helpers = Dir.glob(File.join('tests', '**', '*helper.rb')).sort_by {|helper| helper.count(File::SEPARATOR)} tags = [] for argument in ARGV if argument.match(/^[\+\-]/) tags << argument else path = File.expand_path(argument) if File.directory?(path) tests ||= [] tests |= Dir.glob(File.join(path, '**', '*tests.rb')) elsif File.exists?(path) tests ||= [] tests << path else Formatador.display_line("[red][bold]#{argument}[/] [red]does not exist, please fix this path and try again.[/]") Kernel.exit(1) end end end # ARGV was empty or only contained tags unless tests tests = Dir.glob(File.join('tests', '**', '*tests.rb')) end @started_at = Time.now def run_in_thread(helpers, tests, thread_locals) shindo = Thread.new { for key, value in thread_locals Thread.current[key] = value end for file in helpers unless Thread.main[:exit] load(file) end end for file in tests Thread.current[:file] = file unless Thread.main[:exit] load(file) end end } shindo.join if shindo[:reload] run_in_thread(helpers, tests, thread_locals) else @totals = shindo[:totals] end end run_in_thread(helpers, tests, @thread_locals.merge({:tags => tags})) @totals ||= { :failed => 0, :pending => 0, :succeeded => 0 } @success = @totals[:failed] == 0 status = [] status << "[red]#{@totals[:failed]} failed[/]," if @totals[:failed] > 0 status << "[yellow]#{@totals[:pending]} pending[/]," if @totals[:pending] > 0 status << "[green]#{@totals[:succeeded]} succeeded[/]" status = status[0...-2].join(', ') << ' and ' << status[-1] if status.length > 3 status << "in [bold]#{Time.now - @started_at}[/] seconds" Formatador.display_lines(['', status.join(' '), '']) if @success Kernel.exit(0) else Kernel.exit(1) end ruby-shindo-0.3.5/lib/shindo/rake.rb000066400000000000000000000002621214547413100172650ustar00rootroot00000000000000module Shindo class Rake include ::Rake::DSL def initialize desc "Run shindo tests" task :tests do system 'shindo' end end end end ruby-shindo-0.3.5/lib/shindo/taciturn.rb000066400000000000000000000024631214547413100202010ustar00rootroot00000000000000module Shindo class Tests private def display_description_stack Formatador.indent do @description_stack.length.times do Formatador.display_line(@description_stack.pop) end end end def display_description(description) unless @described Thread.current[:formatador].display(@description_stack.first) print ' ' @described = true end end def display_error(error) Formatador.display_lines(['', Thread.current[:file]]) display_description_stack Formatador.display_line("[red]#{error.message} (#{error.class})[/]") unless error.backtrace.empty? Formatador.indent do Formatador.display_lines(error.backtrace.map {|line| "[red]#{line}[/]"}) end end end def display_failure(description) Thread.current[:totals][:failed] += 1 Formatador.display_lines(['', Thread.current[:file]]) display_description_stack Formatador.display_line("[red]- #{description}[/]") end def display_pending(description) Thread.current[:totals][:pending] += 1 print Formatador.parse("[yellow]#[/]") end def display_success(description) Thread.current[:totals][:succeeded] += 1 print Formatador.parse("[green]+[/]") end end end ruby-shindo-0.3.5/lib/shindo/verbose.rb000066400000000000000000000024271214547413100200150ustar00rootroot00000000000000module Shindo class Tests private def display_description(description) unless @inline Formatador.display_line(description) else Formatador.display(description) print ' ' end end def display_error(error) Formatador.display_line("[red]#{error.message} (#{error.class})[/]") unless error.backtrace.empty? Formatador.indent do Formatador.display_lines(error.backtrace.map {|line| "[red]#{line}[/]"}) end end end def display_failure(description) Thread.current[:totals][:failed] += 1 unless @inline Formatador.display_line("[red]- #{description}[/]") else print Formatador.parse("[red]- #{description}[/]\n") end end def display_pending(description) Thread.current[:totals][:pending] += 1 unless @inline Formatador.display_line("[yellow]# #{description}[/]") else print Formatador.parse("[yellow]# #{description}[/]\n") end end def display_success(description) Thread.current[:totals][:succeeded] += 1 unless @inline Formatador.display_line("[green]+ #{description}[/]") else print Formatador.parse("[green]+ #{description}[/]\n") end end end end ruby-shindo-0.3.5/metadata.yml000066400000000000000000000035231214547413100162720ustar00rootroot00000000000000--- !ruby/object:Gem::Specification name: shindo version: !ruby/object:Gem::Version version: 0.3.5 prerelease: platform: ruby authors: - geemus (Wesley Beary) autorequire: bindir: bin cert_chain: [] date: 2012-11-30 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: formatador requirement: !ruby/object:Gem::Requirement none: false requirements: - - ! '>=' - !ruby/object:Gem::Version version: 0.1.1 type: :runtime prerelease: false version_requirements: !ruby/object:Gem::Requirement none: false requirements: - - ! '>=' - !ruby/object:Gem::Version version: 0.1.1 description: Work with your tests, not against them. email: geemus@gmail.com executables: - shindo - shindont extensions: [] extra_rdoc_files: - README.rdoc files: - Gemfile - README.rdoc - Rakefile - bin/shindo - bin/shindont - lib/shindo.rb - lib/shindo/bin.rb - lib/shindo/rake.rb - lib/shindo/taciturn.rb - lib/shindo/verbose.rb - shindo.gemspec - tests/basic_tests.rb - tests/bin_tests.rb - tests/data/exception - tests/data/failure - tests/data/negative - tests/data/pending - tests/data/positive - tests/data/success - tests/tag_tests.rb - tests/tests_helper.rb homepage: http://github.com/geemus/shindo licenses: [] post_install_message: rdoc_options: - --charset=UTF-8 require_paths: - lib required_ruby_version: !ruby/object:Gem::Requirement none: false requirements: - - ! '>=' - !ruby/object:Gem::Version version: '0' segments: - 0 hash: -213069165045248108 required_rubygems_version: !ruby/object:Gem::Requirement none: false requirements: - - ! '>=' - !ruby/object:Gem::Version version: '0' requirements: [] rubyforge_project: shindo rubygems_version: 1.8.23 signing_key: specification_version: 2 summary: Simple depth first Ruby testing. test_files: [] ruby-shindo-0.3.5/shindo.gemspec000066400000000000000000000066401214547413100166230ustar00rootroot00000000000000## This is the rakegem gemspec template. Make sure you read and understand ## all of the comments. Some sections require modification, and others can ## be deleted if you don't need them. Once you understand the contents of ## this file, feel free to delete any comments that begin with two hash marks. ## You can find comprehensive Gem::Specification documentation, at ## http://docs.rubygems.org/read/chapter/20 Gem::Specification.new do |s| s.specification_version = 2 if s.respond_to? :specification_version= s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.rubygems_version = '1.3.5' ## Leave these as is they will be modified for you by the rake gemspec task. ## If your rubyforge_project name is different, then edit it and comment out ## the sub! line in the Rakefile s.name = 'shindo' s.version = '0.3.5' s.date = '2012-11-30' s.rubyforge_project = 'shindo' ## Make sure your summary is short. The description may be as long ## as you like. s.summary = "Simple depth first Ruby testing." s.description = "Work with your tests, not against them." ## List the primary authors. If there are a bunch of authors, it's probably ## better to set the email to an email list or something. If you don't have ## a custom homepage, consider using your GitHub URL or the like. s.authors = ["geemus (Wesley Beary)"] s.email = 'geemus@gmail.com' s.homepage = 'http://github.com/geemus/shindo' ## This gets added to the $LOAD_PATH so that 'lib/NAME.rb' can be required as ## require 'NAME.rb' or'/lib/NAME/file.rb' can be as require 'NAME/file.rb' s.require_paths = %w[lib] ## This sections is only necessary if you have C extensions. # s.require_paths << 'ext' # s.extensions = %w[ext/extconf.rb] ## If your gem includes any executables, list them here. s.executables = ['shindo', 'shindont'] s.default_executable = 'shindo' ## Specify any RDoc options here. You'll want to add your README and ## LICENSE files to the extra_rdoc_files list. s.rdoc_options = ["--charset=UTF-8"] s.extra_rdoc_files = %w[README.rdoc] ## List your runtime dependencies here. Runtime dependencies are those ## that are needed for an end user to actually USE your code. s.add_dependency('formatador', '>=0.1.1') ## List your development dependencies here. Development dependencies are ## those that are only needed during development # s.add_development_dependency('DEVDEPNAME', [">= 1.1.0", "< 2.0.0"]) ## Leave this section as-is. It will be automatically generated from the ## contents of your Git repository via the gemspec task. DO NOT REMOVE ## THE MANIFEST COMMENTS, they are used as delimiters by the task. # = MANIFEST = s.files = %w[ Gemfile README.rdoc Rakefile bin/shindo bin/shindont lib/shindo.rb lib/shindo/bin.rb lib/shindo/rake.rb lib/shindo/taciturn.rb lib/shindo/verbose.rb shindo.gemspec tests/basic_tests.rb tests/bin_tests.rb tests/data/exception tests/data/failure tests/data/negative tests/data/pending tests/data/positive tests/data/success tests/tag_tests.rb tests/tests_helper.rb ] # = MANIFEST = ## Test files will be grabbed from the file list. Make sure the path glob ## matches what you actually use. s.test_files = s.files.select { |path| path =~ /^[spec|tests]\/.*_[spec|tests]\.rb/ } end ruby-shindo-0.3.5/tests/000077500000000000000000000000001214547413100151265ustar00rootroot00000000000000ruby-shindo-0.3.5/tests/basic_tests.rb000066400000000000000000000002311214547413100177520ustar00rootroot00000000000000Shindo.tests('basics') do returns(false) { false } raises(StandardError) { raise StandardError.new } test('returns true') { true } end ruby-shindo-0.3.5/tests/bin_tests.rb000066400000000000000000000016271214547413100174530ustar00rootroot00000000000000Shindo.tests('bin') do tests('exception') do @output = bin(path('exception')) includes('- exception') { @output } tests('$?.exitstatus').returns(1) { $?.exitstatus } end tests('failure') do @output = bin(path('failure')) includes('- failure') { @output } tests('$?.exitstatus').returns(1) { $?.exitstatus } end tests('pending') do @output = bin(path('pending')) includes('# test implicit pending') { @output } includes('# test explicit pending') { @output } includes('# tests explicit pending') { @output } tests('$?.exitstatus').returns(0) { $?.exitstatus } end tests('success') do @output = bin(path('success')) includes('+ success') { @output } includes('inline tests') { @output } includes('+ returns false') { @output } tests('$?.exitstatus').returns(0) { $?.exitstatus } end endruby-shindo-0.3.5/tests/data/000077500000000000000000000000001214547413100160375ustar00rootroot00000000000000ruby-shindo-0.3.5/tests/data/exception000066400000000000000000000001201214547413100177510ustar00rootroot00000000000000Shindo.tests do test('exception') { raise StandardError.new('exception') } endruby-shindo-0.3.5/tests/data/failure000066400000000000000000000000571214547413100174130ustar00rootroot00000000000000Shindo.tests do test('failure') { false } endruby-shindo-0.3.5/tests/data/negative000066400000000000000000000002071214547413100175630ustar00rootroot00000000000000Shindo.tests('success') do test('is tested') { true } end Shindo.tests('skipped', 'negative') do test('is skipped') { false } end ruby-shindo-0.3.5/tests/data/pending000066400000000000000000000002151214547413100174040ustar00rootroot00000000000000Shindo.tests do test('test implicit pending') test('test explicit pending') { pending } tests('tests explicit pending') { pending } endruby-shindo-0.3.5/tests/data/positive000066400000000000000000000002101214547413100176150ustar00rootroot00000000000000Shindo.tests('success', 'positive') do test('is tested') { true } end Shindo.tests('skipped') do test('is skipped') { false } end ruby-shindo-0.3.5/tests/data/success000066400000000000000000000001371214547413100174330ustar00rootroot00000000000000Shindo.tests do test('success') { true } tests('inline tests').returns(false) { false } endruby-shindo-0.3.5/tests/tag_tests.rb000066400000000000000000000010121214547413100174420ustar00rootroot00000000000000Shindo.tests('tag') do tests("negative -negative") do @output = bin("#{path('negative')} -negative") includes('+ is tested') { @output } includes('skipped (negative)') { @output } tests('$?.exitstatus').returns(0) { $?.exitstatus } end tests("positive +positive") do @output = bin("#{path('positive')} +positive") includes('+ is tested') { @output } includes('skipped') { @output } tests('$?.exitstatus').returns(0) { $?.exitstatus } end end ruby-shindo-0.3.5/tests/tests_helper.rb000066400000000000000000000011451214547413100201550ustar00rootroot00000000000000require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'shindo')) BIN = File.join(File.dirname(__FILE__), '..', 'bin', 'shindo') def bin(arguments) `RUBYOPT="-rubygems" #{BIN} #{arguments}` end def path(name) File.join(File.dirname(__FILE__), 'data', name) end module Shindo class Tests def includes(expectation, description = "includes #{expectation.inspect}", &block) test(description) do value = instance_eval(&block) @message = "expected #{value.inspect} to include #{expectation.inspect}" value.include?(expectation) end end end end