bacon-1.2.0/0000755000004100000410000000000012072543314012625 5ustar www-datawww-databacon-1.2.0/.travis.yml0000644000004100000410000000027312072543314014740 0ustar www-datawww-datascript: bin/bacon -Ilib --automatic --quiet rvm: - 1.8.7 - 1.9.2 - 1.9.3 - rbx-18mode - rbx-19mode - jruby-18mode - jruby-19mode notifications: recipients: - gabriel.horner@gmail.com bacon-1.2.0/test/0000755000004100000410000000000012072543314013604 5ustar www-datawww-databacon-1.2.0/test/spec_should.rb0000644000004100000410000000134412072543314016443 0ustar www-datawww-datarequire File.expand_path('../../lib/bacon', __FILE__) describe "#should shortcut for #it('should')" do should "be called" do @called = true @called.should.be == true end should "save some characters by typing should" do lambda { should.satisfy { 1 == 1 } }.should.not.raise end should "save characters even on failure" do lambda { should.satisfy { 1 == 2 } }.should.raise Bacon::Error end should "work nested" do should.satisfy {1==1} end count = Bacon::Counter[:specifications] should "add new specifications" do # XXX this should +=1 but it's +=2 (count+1).should == Bacon::Counter[:specifications] end should "have been called" do @called.should.be == true end end bacon-1.2.0/test/spec_bacon.rb0000644000004100000410000002663312072543314016237 0ustar www-datawww-data$-w,w = nil, $-w require File.expand_path('../../lib/bacon', __FILE__) $-w = w # Hooray for meta-testing. module MetaTests def succeed lambda { |block| block.should.not.raise Bacon::Error true } end def fail lambda { |block| block.should.raise Bacon::Error true } end def equal_string(x) lambda { |s| x == s.to_s } end end describe "Bacon" do extend MetaTests it "should have should.satisfy" do lambda { should.satisfy { 1 == 1 } }.should succeed lambda { should.satisfy { 1 } }.should succeed lambda { should.satisfy { 1 != 1 } }.should fail lambda { should.satisfy { false } }.should fail lambda { should.satisfy { false } }.should fail lambda { 1.should.satisfy { |n| n % 2 == 0 } }.should fail lambda { 2.should.satisfy { |n| n % 2 == 0 } }.should succeed end it "should have should.==" do lambda { "string1".should == "string1" }.should succeed lambda { "string1".should == "string2" }.should fail lambda { [1,2,3].should == [1,2,3] }.should succeed lambda { [1,2,3].should == [1,2,4] }.should fail end it "should have should.equal" do lambda { "string1".should == "string1" }.should succeed lambda { "string1".should == "string2" }.should fail lambda { "1".should == 1 }.should fail lambda { "string1".should.equal "string1" }.should succeed lambda { "string1".should.equal "string2" }.should fail lambda { "1".should.equal 1 }.should fail end it "should have should.raise" do lambda { lambda { raise "Error" }.should.raise }.should succeed lambda { lambda { raise "Error" }.should.raise RuntimeError }.should succeed lambda { lambda { raise "Error" }.should.not.raise }.should fail lambda { lambda { raise "Error" }.should.not.raise(RuntimeError) }.should fail lambda { lambda { 1 + 1 }.should.raise }.should fail lambda { lambda { raise "Error" }.should.raise(Interrupt) }.should.raise end it "should have should.change" do lambda { lambda {}.should.change { sleep 0.001; Time.now } }.should succeed lambda { i = 1 lambda { i *= 2 }.should.change { i } }.should succeed lambda { i = 0 lambda { i *= 2 }.should.change { i } }.should fail lambda { should.change { sleep 0.001; Time.now } }.should succeed lambda { should.change { 42 } }.should fail end it "should have should.raise with a block" do lambda { should.raise { raise "Error" } }.should succeed lambda { should.raise(RuntimeError) { raise "Error" } }.should succeed lambda { should.not.raise { raise "Error" } }.should fail lambda { should.not.raise(RuntimeError) { raise "Error" } }.should fail lambda { should.raise { 1 + 1 } }.should fail lambda { should.raise(Interrupt) { raise "Error" } }.should.raise end it "should have a should.raise should return the exception" do ex = lambda { raise "foo!" }.should.raise ex.should.be.kind_of RuntimeError ex.message.should =~ /foo/ end it "should have should.be.an.instance_of" do lambda { "string".should.be.instance_of String }.should succeed lambda { "string".should.be.instance_of Hash }.should fail lambda { "string".should.be.an.instance_of String }.should succeed lambda { "string".should.be.an.instance_of Hash }.should fail end it "should have should.be.nil" do lambda { nil.should.be.nil }.should succeed lambda { nil.should.not.be.nil }.should fail lambda { "foo".should.be.nil }.should fail lambda { "foo".should.not.be.nil }.should succeed end it "should have should.include" do lambda { [1,2,3].should.include 2 }.should succeed lambda { [1,2,3].should.include 4 }.should fail lambda { {1=>2, 3=>4}.should.include 1 }.should succeed lambda { {1=>2, 3=>4}.should.include 2 }.should fail end it "should have should.be.a.kind_of" do lambda { Array.should.be.kind_of Module }.should succeed lambda { "string".should.be.kind_of Object }.should succeed lambda { 1.should.be.kind_of Comparable }.should succeed lambda { Array.should.be.a.kind_of Module }.should succeed lambda { "string".should.be.a.kind_of Class }.should fail end it "should have should.match" do lambda { "string".should.match(/strin./) }.should succeed lambda { "string".should =~ /strin./ }.should succeed lambda { "string".should.match(/slin./) }.should fail lambda { "string".should =~ /slin./ }.should fail end it "should have should.not.raise" do lambda { lambda { 1 + 1 }.should.not.raise }.should succeed lambda { lambda { 1 + 1 }.should.not.raise(Interrupt) }.should succeed lambda { lambda { lambda { Kernel.raise ZeroDivisionError.new("ArgumentError") }.should.not.raise(RuntimeError, Comparable) }.should.raise ZeroDivisionError }.should succeed lambda { lambda { raise "Error" }.should.not.raise }.should fail end it "should have should.throw" do lambda { lambda { throw :foo }.should.throw(:foo) }.should succeed lambda { lambda { :foo }.should.throw(:foo) }.should fail should.throw(:foo) { throw :foo } end it "should have should.not.satisfy" do lambda { should.not.satisfy { 1 == 2 } }.should succeed lambda { should.not.satisfy { 1 == 1 } }.should fail end it "should have should.not.equal" do lambda { "string1".should.not == "string2" }.should succeed lambda { "string1".should.not == "string1" }.should fail end it "should have should.not.match" do lambda { "string".should.not.match(/sling/) }.should succeed lambda { "string".should.not.match(/string/) }.should fail # lambda { "string".should.not.match("strin") }.should fail lambda { "string".should.not =~ /sling/ }.should succeed lambda { "string".should.not =~ /string/ }.should fail # lambda { "string".should.not =~ "strin" }.should fail end it "should have should.be.identical_to/same_as" do lambda { s = "string"; s.should.be.identical_to s }.should succeed lambda { "string".should.be.identical_to "string" }.should fail lambda { s = "string"; s.should.be.same_as s }.should succeed lambda { "string".should.be.same_as "string" }.should fail end it "should have should.respond_to" do lambda { "foo".should.respond_to :to_s }.should succeed lambda { 5.should.respond_to :to_str }.should fail lambda { :foo.should.respond_to :nx }.should fail end it "should have should.be.close" do lambda { 1.4.should.be.close 1.4, 0 }.should succeed lambda { 0.4.should.be.close 0.5, 0.1 }.should succeed lambda { 0.4.should.be.close 0.5, 0.05 }.should fail lambda { 0.4.should.be.close Object.new, 0.1 }.should fail lambda { 0.4.should.be.close 0.5, -0.1 }.should fail end it "should support multiple negation" do lambda { 1.should.equal 1 }.should succeed lambda { 1.should.not.equal 1 }.should fail lambda { 1.should.not.not.equal 1 }.should succeed lambda { 1.should.not.not.not.equal 1 }.should fail lambda { 1.should.equal 2 }.should fail lambda { 1.should.not.equal 2 }.should succeed lambda { 1.should.not.not.equal 2 }.should fail lambda { 1.should.not.not.not.equal 2 }.should succeed end it "should have should." do lambda { [].should.be.empty }.should succeed lambda { [1,2,3].should.not.be.empty }.should succeed lambda { [].should.not.be.empty }.should fail lambda { [1,2,3].should.be.empty }.should fail lambda { {1=>2, 3=>4}.should.has_key 1 }.should succeed lambda { {1=>2, 3=>4}.should.not.has_key 2 }.should succeed lambda { nil.should.bla }.should.raise(NoMethodError) lambda { nil.should.not.bla }.should.raise(NoMethodError) end it "should have should (>, >=, <, <=, ===)" do lambda { 2.should.be > 1 }.should succeed lambda { 1.should.be > 2 }.should fail lambda { 1.should.be < 2 }.should succeed lambda { 2.should.be < 1 }.should fail lambda { 2.should.be >= 1 }.should succeed lambda { 2.should.be >= 2 }.should succeed lambda { 2.should.be >= 2.1 }.should fail lambda { 2.should.be <= 1 }.should fail lambda { 2.should.be <= 2 }.should succeed lambda { 2.should.be <= 2.1 }.should succeed lambda { Array.should === [1,2,3] }.should succeed lambda { Integer.should === [1,2,3] }.should fail lambda { /foo/.should === "foobar" }.should succeed lambda { "foobar".should === /foo/ }.should fail end it "should allow for custom shoulds" do lambda { (1+1).should equal_string("2") }.should succeed lambda { (1+2).should equal_string("2") }.should fail lambda { (1+1).should.be equal_string("2") }.should succeed lambda { (1+2).should.be equal_string("2") }.should fail lambda { (1+1).should.not equal_string("2") }.should fail lambda { (1+2).should.not equal_string("2") }.should succeed lambda { (1+2).should.not.not equal_string("2") }.should fail lambda { (1+1).should.not.be equal_string("2") }.should fail lambda { (1+2).should.not.be equal_string("2") }.should succeed end it "should have should.flunk" do lambda { should.flunk }.should fail lambda { should.flunk "yikes" }.should fail end end describe "before/after" do before do @a = 1 @b = 2 end before do @a = 2 end after do @a.should.equal 2 @a = 3 end after do @a.should.equal 3 end it "should run in the right order" do @a.should.equal 2 @b.should.equal 2 end describe "when nested" do before do @c = 5 end it "should run from higher level" do @a.should.equal 2 @b.should.equal 2 end it "should run at the nested level" do @c.should.equal 5 end before do @a = 5 end it "should run in the right order" do @a.should.equal 5 @a = 2 end end it "should not run from lower level" do @c.should.be.nil end describe "when nested at a sibling level" do it "should not run from sibling level" do @c.should.be.nil end end end shared "a shared context" do it "gets called where it is included" do true.should.be.true end end shared "another shared context" do it "can access data" do @magic.should.be.equal 42 end end describe "shared/behaves_like" do behaves_like "a shared context" ctx = self it "raises NameError when the context is not found" do lambda { ctx.behaves_like "whoops" }.should.raise NameError end behaves_like "a shared context" before { @magic = 42 } behaves_like "another shared context" end describe "Methods" do def the_meaning_of_life 42 end it "should be accessible in a test" do the_meaning_of_life.should == 42 end describe "when in a sibling context" do it "should be accessible in a test" do the_meaning_of_life.should == 42 end end end describe 'describe arguments' do def check(ctx,name) ctx.should.be.an.instance_of Bacon::Context ctx.instance_variable_get('@name').should == name end it 'should work with string' do check(describe('string') {},'string') end it 'should work with symbols' do check(describe(:behaviour) {},'behaviour') end it 'should work with modules' do check(describe(Bacon) {},'Bacon') end it 'should work with namespaced modules' do check(describe(Bacon::Context) {},'Bacon::Context') end it 'should work with multiple arguments' do check(describe(Bacon::Context, :empty) {},'Bacon::Context empty') end end bacon-1.2.0/test/spec_nontrue.rb0000644000004100000410000000056012072543314016636 0ustar www-datawww-data$false_is_not_true = false.should.not.be.true $nil_is_not_true = nil.should.not.be.true describe 'A non-true value' do it 'should pass negated tests inside specs' do false.should.not.be.true nil.should.not.be.true end it 'should pass negated tests outside specs' do $false_is_not_true.should.be.true $nil_is_not_true.should.be.true end end bacon-1.2.0/README.rdoc0000644000004100000410000001766412072543314014451 0ustar www-datawww-data= Bacon -- small RSpec clone. "Truth will sooner come out from error than from confusion." ---Francis Bacon Bacon is a small RSpec clone weighing less than 350 LoC but nevertheless providing all essential features. == Whirl-wind tour require 'bacon' describe 'A new array' do before do @ary = Array.new end it 'should be empty' do @ary.should.be.empty @ary.should.not.include 1 end it 'should have zero size' do @ary.size.should.equal 0 @ary.size.should.be.close 0.1, 0.5 end it 'should raise on trying fetch any index' do lambda { @ary.fetch 0 }. should.raise(IndexError). message.should.match(/out of array/) # Alternatively: should.raise(IndexError) { @ary.fetch 0 } end it 'should have an object identity' do @ary.should.not.be.same_as Array.new end # Custom assertions are trivial to do, they are lambdas returning a # boolean vale: palindrome = lambda { |obj| obj == obj.reverse } it 'should be a palindrome' do @ary.should.be.a palindrome end it 'should have super powers' do should.flunk "no super powers found" end end Now run it: $ bacon whirlwind.rb A new array - should be empty - should have zero size - should raise on trying fetch any index - should have an object identity - should be a palindrome - should have super powers [FAILED] Bacon::Error: no super powers found ./whirlwind.rb:39: A new array - should have super powers ./whirlwind.rb:38 ./whirlwind.rb:3 6 specifications (9 requirements), 1 failures, 0 errors If you want shorter output, use the Test::Unit format: $ bacon -q whirlwind.rb .....F Bacon::Error: no super powers found ./whirlwind.rb:39: A new array - should have super powers ./whirlwind.rb:38 ./whirlwind.rb:3 6 tests, 9 assertions, 1 failures, 0 errors It also supports TAP: $ bacon -p whirlwind.rb ok 1 - should be empty ok 2 - should have zero size ok 3 - should raise on trying fetch any index ok 4 - should have an object identity ok 5 - should be a palindrome not ok 6 - should have super powers: FAILED # Bacon::Error: no super powers found # ./whirlwind.rb:39: A new array - should have super powers # ./whirlwind.rb:38 # ./whirlwind.rb:3 1..6 # 6 tests, 9 assertions, 1 failures, 0 errors $ bacon -p whirlwind.rb | taptap -q Tests took 0.00 seconds. FAILED tests 6 6) should have super powers: FAILED Failed 1/6 tests, 83.33% okay. (taptap is available from http://chneukirchen.org/repos/taptap/) As of Bacon 1.1, it also supports Knock: $ bacon -k whirlwind.rb ok - should be empty ok - should have zero size ok - should raise on trying fetch any index ok - should have an object identity ok - should be a palindrome not ok - should have super powers: FAILED # Bacon::Error: no super powers found # ./whirlwind.rb:39: A new array - should have super powers # ./whirlwind.rb:38 # ./whirlwind.rb:3 $ bacon -k whirlwind.rb | kn-sum 6 tests, 1 failed (83.3333% succeeded) (knock is available from http://github.com/chneukirchen/knock/) == Implemented assertions * should. and should.be. * should.equal * should.match * should.be.identical_to / should.be.same_as * should.raise(*exceptions) { } * should.change { } * should.throw(symbol) { } * should.satisfy { |object| } == Added core predicates * Object#true? * Object#false? * Proc#change? * Proc#raise? * Proc#throw? * Numeric#close? == before/after before and after need to be defined before the first specification in a context and are run before and after each specification. As of Bacon 1.1, before and after do nest in nested contexts. == Shared contexts You can define shared contexts in Bacon like this: shared "an empty container" do it "should have size zero" do end it "should be empty" do end end context "A new array" do behaves_like "an empty container" end These contexts are not executed on their own, but can be included with behaves_like in other contexts. You can use shared contexts to structure suites with many recurring specifications. == Matchers Custom matchers are simply lambdas returning a boolean value, for example: def shorter_than(max_size) lambda { |obj| obj.size < max_size } end [1,2,3].should.be shorter_than(5) You can use modules and extend to group matchers for use in multiple contexts. == bacon standalone runner -s, --specdox do AgileDox-like output (default) -q, --quiet do Test::Unit-like non-verbose output -p, --tap do TAP (Test Anything Protocol) output -k, --knock do Knock output -o, --output FORMAT do FORMAT (SpecDox/TestUnit/Tap) output -Q, --no-backtrace don't print backtraces -a, --automatic gather tests from ./test/, include ./lib/ -n, --name NAME runs tests matching regexp NAME -t, --testcase TESTCASE runs tests in TestCases matching regexp TESTCASE If you don't want to use the standalone runner, run Bacon.summary_on_exit to install an exit handler showing the summary. == Object#should You can use Object#should outside of contexts, where the result of assertion will be returned as a boolean. This is nice for demonstrations, quick checks and doctest tests. >> require 'bacon' >> (1 + 1).should.equal 2 => true >> (6*9).should.equal 42 => false == Bacon with autotest Since version 1.0, there is autotest support. You need to tag your test directories (test/ or spec/) by creating an .bacon file there. Autotest then will find it. bin/bacon needs to be in PATH or RUBYPATH. == Converting specs spec-converter is a simple tool to convert test-unit or dust style tests to test/spec specs. It can be found at http://opensource.thinkrelevance.com/wiki/spec_converter. == Thanks to * Michael Fellinger, for fixing Bacon for 1.9 and various improvements. * Gabriele Renzi, for implementing Context#should. * James Tucker, for the autotest support. * Yossef Mendelssohn, for nested contexts. * everyone contributing bug fixes. == History * January 7, 2008: First public release 0.9. * July 6th, 2008: Second public release 1.0. * Add Context#should as a shortcut for Context#it('should ' + _). * describe now supports multiple arguments for better organization. * Empty specifications are now erroneous. * after-blocks run in the case of exceptions too. * Autotest support. * Bug fixes. * November 30th, 2008: Third public release 1.1. * Nested before/after. * Add -Q/--no-backtraces to not show details about failed specifications. * Add Knock output. * Bug fixes. * December 21th, 2012: Fourth public release 1.2.0. * #satisfy will not pass arguments anymore to the block, use lexical scope. * Fixed Context#change?. * Add support for finding specs named like spec/**/*_spec.rb. * Contexts nest properly. * Timer in TestUnitOutput. * Nested output for SpecDoxOutput. * Small cleanups and more tests. == Contact Please mail bugs, suggestions and patches to . Git repository (patches rebased on HEAD are most welcome): http://github.com/chneukirchen/bacon git://github.com/chneukirchen/bacon.git == Copying Copyright (C) 2007, 2008, 2012 Christian Neukirchen Bacon is freely distributable under the terms of an MIT-style license. See COPYING or http://www.opensource.org/licenses/mit-license.php. == Links Behavior-Driven Development:: RSpec:: test/spec:: Christian Neukirchen:: bacon-1.2.0/Rakefile0000644000004100000410000000351112072543314014272 0ustar www-datawww-data# Rakefile for Bacon. -*-ruby-*- require 'rdoc/task' require 'rake/testtask' desc "Run all the tests" task :default => [:test] desc "Do predistribution stuff" task :predist => [:chmod, :changelog, :rdoc] desc "Make an archive as .tar.gz" task :dist => [:test, :predist] do sh "git archive --format=tar --prefix=#{release}/ HEAD^{tree} >#{release}.tar" sh "pax -waf #{release}.tar -s ':^:#{release}/:' RDOX ChangeLog doc" sh "gzip -f -9 #{release}.tar" end # Helper to retrieve the "revision number" of the git tree. def git_tree_version if File.directory?(".git") @tree_version ||= `git describe`.strip.sub('-', '.') @tree_version << ".0" unless @tree_version.count('.') == 2 else $: << "lib" require 'bacon' @tree_version = Bacon::VERSION end @tree_version end def gem_version git_tree_version.gsub(/-.*/, '') end def release "bacon-#{git_tree_version}" end def manifest `git ls-files`.split("\n") - [".gitignore"] end desc "Make binaries executable" task :chmod do Dir["bin/*"].each { |binary| File.chmod(0775, binary) } end desc "Generate a ChangeLog" task :changelog do sh "git log --format='%ad %an <%ae>%n%w(79,2,4)* %s%n%n%w(76,4,4)%b' |grep -v darcs-hash: |cat -s >ChangeLog" end desc "Generate RDox" task "RDOX" do sh "bin/bacon -Ilib --automatic --specdox >RDOX" end desc "Run all the tests" task :test do ruby "bin/bacon -Ilib --automatic --quiet" end desc "Generate RDoc documentation" Rake::RDocTask.new(:rdoc) do |rdoc| rdoc.options << '--line-numbers' << '--inline-source' << '--main' << 'README.rdoc' << '--title' << 'Bacon Documentation' << '--charset' << 'utf-8' rdoc.rdoc_dir = "doc" rdoc.rdoc_files.include 'README.rdoc' rdoc.rdoc_files.include 'COPYING' rdoc.rdoc_files.include 'RDOX' rdoc.rdoc_files.include('lib/bacon.rb') end task :rdoc => ["RDOX"] bacon-1.2.0/ChangeLog0000644000004100000410000003214412072543314014403 0ustar www-datawww-dataFri Dec 21 11:49:56 2012 +0100 Christian Neukirchen * Update README Fri Dec 21 11:45:44 2012 +0100 Christian Neukirchen * Replace ChangeLog generator Fri Dec 21 11:45:31 2012 +0100 Christian Neukirchen * Update copyright years Fri Dec 21 11:42:19 2012 +0100 Christian Neukirchen * Rename README README.rdoc Wed Mar 21 04:27:31 2012 -0700 Christian Neukirchen * Merge pull request #11 from cldwalker/fix_change_tests Fix change tests for jruby and sometimes 1.8.7 Tue Mar 20 18:19:29 2012 -0400 Gabriel Horner * all tests green - remove allowed_failures for travis Tue Mar 20 18:02:51 2012 -0400 Gabriel Horner * fix should.change tests failing intermittently on jruby + 1.8.7 see http://travis-ci.org/#!/cldwalker/bacon/builds/910141 tests were running so fast that Time.now remains the same Fri Mar 16 19:30:08 2012 +0100 Christian Neukirchen * Update README Fri Mar 16 11:42:46 2012 -0400 Gabriel Horner * Add travis to see tests pass on supported rubies Fri Mar 16 19:14:14 2012 +0100 Christian Neukirchen * Push version to 1.2 Fri Mar 16 19:11:20 2012 +0100 Christian Neukirchen * Add tests for should.== Proposed by Gabriel Horner . Fri Mar 16 19:05:34 2012 +0100 Christian Neukirchen * Remove passing arguments in #satisfy, simplify argument parsing This feature was never used and triggers a JRuby bug: http://jira.codehaus.org/browse/JRUBY-6550 Proposed by Gabriel Horner . Fri Mar 16 19:03:58 2012 +0100 Christian Neukirchen * Whitespace cleanup Sun Feb 26 17:50:46 2012 +0100 Christian Neukirchen * Add specs for change? Sun Feb 26 17:48:57 2012 +0100 Christian Neukirchen * Fix Context#change? Wed Dec 28 12:23:29 2011 +0100 Christian Neukirchen * Merge remote-tracking branch 'jeffkreeftmeijer/master' Wed Dec 28 03:17:12 2011 -0800 Christian Neukirchen * Merge pull request #6 from manveru/master Two minor fixes Wed Dec 28 03:54:58 2011 +0100 Michael Fellinger * Avoid warning about unused variable Wed Dec 28 03:54:19 2011 +0100 Michael Fellinger * Update deprecated calls in rakefile Sun Jan 16 14:38:05 2011 +0100 Jeff Kreeftmeijer * Move the Gem::Specification to bacon.gemspec So the gem can be built and released using gem build and gem push and to allow tools like Bundler to install Bacon from git or from the local filesystem. Wed Apr 14 05:40:31 2010 -0400 Gabriel Horner * Indent nested contexts for SpecDoxOutput Based on similar patch from http://github.com/wvl/bacon/commit/af940dbeb789f5eef2d998e227e5425d Mon Mar 29 14:06:47 2010 +0200 Christian Neukirchen * Merge remote branch 'cldwalker/timer' Sun Mar 28 23:16:49 2010 -0400 Gabriel Horner * give TestUnitOutput the same timer that Test::Unit has Sat Mar 20 04:19:18 2010 -0400 Gabriel Horner * methods in a context should serve as behavior that is inherited by sibling contexts Sun Jan 17 12:17:42 2010 -0800 Eoin Hennessy * Add support for finding specs with RSpec style naming. Tue Sep 22 21:17:55 2009 +0200 Christian Neukirchen * Add ChangeLog as gem dependency reported by lian Mon Aug 31 23:36:56 2009 +0200 Eloy Duran * Revert old change that was made because 1.9.0 couldn't rescue a splatted array of Exception classes. MacRuby currently can't use when with the same array and 1.9.2dev does. Also some other minor changes which didn't work currently on 1.9.2dev, but are nicer anyway imo. Thu Jan 22 06:07:53 2009 +0000 Anna Gabutero * Add libs to include path when invoking Test::Unit Sun Jan 11 14:41:01 2009 +0100 Christian Neukirchen * Update homepage Sat Jan 10 14:01:30 2009 -0800 Christian Neukirchen * Allow negated nontrue values outside specs Sat Jan 10 13:44:14 2009 -0800 Ian Dees * Added test for nontrue values outside specs Sun Nov 30 11:14:31 2008 +0100 Christian Neukirchen * Push VERSION to 1.1 Sun Nov 30 11:13:33 2008 +0100 Christian Neukirchen * Last fixes Sun Nov 30 11:06:09 2008 +0100 Christian Neukirchen * Update README Sun Nov 30 11:00:28 2008 +0100 Christian Neukirchen * Add Knock output Sat Oct 25 12:30:00 2008 +0200 Christian Neukirchen * De-metaprogram and document nested before/after Fri Oct 24 17:20:17 2008 -0500 Yossef Mendelssohn * Having higher-level after blocks also be run for nested contexts. Fri Oct 24 17:14:30 2008 -0500 Yossef Mendelssohn * Cleaning up setting of nested before blocks Fri Oct 24 17:09:42 2008 -0500 Yossef Mendelssohn * Ensuring that nested before blocks are run in the correct order Fri Oct 24 17:06:18 2008 -0500 Yossef Mendelssohn * Ensuring that before blocks don't bleed into sibling levels Fri Oct 24 17:01:51 2008 -0500 Yossef Mendelssohn * Letting before blocks be run from higher levels in nested context Split up Context#initialize to let running be a separate step. Added attr_reader for Context name and block to let the running step have access to them without resorting to instance variables. Sat Oct 4 13:38:23 2008 +0200 Christian Neukirchen * Move to git Sun Aug 17 13:32:40 2008 +0200 Christian Neukirchen * Add option to disable backtraces Sun Aug 17 12:48:29 2008 +0200 Christian Neukirchen * Don't %-expand twice in TAP output Fri Aug 1 12:01:28 2008 +0200 jftucker * pols-for-at-exit Added an alias for summary_on_exit to summary_at_exit to save on POLS for some people (me!). Sun Jul 6 18:47:42 2008 +0200 Christian Neukirchen * Add bacon_rspec.rb to avoid errors when .bacon doesn't exist Sun Jul 6 18:05:13 2008 +0200 Christian Neukirchen * Push VERSION to 1.0 Sun Jul 6 18:04:55 2008 +0200 Christian Neukirchen * Small reformatting Sun Jul 6 18:04:41 2008 +0200 Christian Neukirchen * Update README Sun Jul 6 18:03:51 2008 +0200 Christian Neukirchen * Allow 50 lines more code Sun Jul 6 17:46:07 2008 +0200 Christian Neukirchen * Suppress warnings when the suite loads Bacon again Wed Jun 25 13:56:34 2008 +0200 jftucker * support spec/test subdirs for -a Wed Jun 25 13:20:29 2008 +0200 jftucker * support mappings for subdirs in autotest Wed Jun 25 00:27:08 2008 +0200 jftucker * adding autotest support The autotest auto discovery uses bacons test/unit output. It does not currently call specific examples (TODO). It currently attempts to fix the rspec auto discovery by removing it if it finds a .bacon under test/ or spec/. In fact, these are the only conditions under which the bacon autotest will load. Thu Mar 13 04:00:42 2008 +0100 Michael Fellinger m.fellinger@gmail.com * Show exception instead of missing error if a spec is empty because of it. Sun Mar 2 11:52:38 2008 +0100 Christian Neukirchen * Call after-blocks even if before-blocks or spec raise exceptions Based on a patch by Keita Yamaguchi Sun Mar 2 11:52:09 2008 +0100 Christian Neukirchen * Count failed requirements too Sun Feb 10 18:45:24 2008 +0100 Christian Neukirchen * Reformats Sun Feb 10 18:42:32 2008 +0100 Christian Neukirchen * Empty specifications are now erroneous Sun Feb 10 14:49:58 2008 +0100 Michael Fellinger * Improve require for lib/bacon Wed Jan 23 23:59:40 2008 +0100 rff.rff * allows multiple arguments to #describe to allow specialized behaviours such as describe Queue,'empty' describe Queue,'full' Some tests for this and manveru's latest patch are included Sat Jan 19 23:07:25 2008 +0100 Michael Fellinger * #to_s the argument to describe Fri Jan 18 15:25:27 2008 +0100 Christian Neukirchen * Flunk if there are no arguments to #it Mon Jan 14 01:34:44 2008 +0100 rff.rff * add should('foo') shortcut for it('should foo') Mon Jan 7 20:24:04 2008 +0100 Christian Neukirchen * Last minute Mon Jan 7 20:21:43 2008 +0100 Christian Neukirchen * Update copyright Mon Jan 7 20:08:40 2008 +0100 Christian Neukirchen * Tighten code Mon Jan 7 19:33:39 2008 +0100 Christian Neukirchen * Update README Mon Jan 7 19:33:25 2008 +0100 Christian Neukirchen * Add bacon -o FORMAT Mon Jan 7 19:33:07 2008 +0100 Christian Neukirchen * Improve TAP output Mon Dec 31 19:01:49 2007 +0100 Michael Fellinger * behaves_like should take multiple names Sun Dec 30 19:38:18 2007 +0100 Michael Fellinger * Adding Proc#change? to check for changes on repeated calling of proc. Fri Dec 28 12:42:04 2007 +0100 Michael Fellinger * Patching for ruby 1.9.0 and removing useless spaces Wed Dec 5 14:56:51 2007 +0100 Christian Neukirchen * Make code nicer Wed Dec 5 14:48:06 2007 +0100 Christian Neukirchen * Fix Rakefile Wed Dec 5 14:46:32 2007 +0100 Christian Neukirchen * Integrate Rakefile Wed Dec 5 14:43:26 2007 +0100 Christian Neukirchen * Add Rakefile Wed Dec 5 14:41:53 2007 +0100 Christian Neukirchen * Add README Wed Dec 5 14:41:26 2007 +0100 Christian Neukirchen * Add copyright Wed Dec 5 14:18:54 2007 +0100 Christian Neukirchen * Move #close? to Numeric Wed Dec 5 14:11:34 2007 +0100 Christian Neukirchen * Add flunking Wed Dec 5 13:42:13 2007 +0100 Christian Neukirchen * Allow using Object#should outside of contexts providing boolean return Wed Dec 5 13:41:00 2007 +0100 Christian Neukirchen * Move summary outputter to lib/bacon.rb Wed Dec 5 13:26:27 2007 +0100 Christian Neukirchen * Fix output of summary Wed Dec 5 13:26:16 2007 +0100 Christian Neukirchen * Add identical_to/same_as Wed Dec 5 02:12:24 2007 +0100 Christian Neukirchen * Remove debugging statements Wed Dec 5 02:00:03 2007 +0100 Christian Neukirchen * Refactor tests Wed Dec 5 01:58:08 2007 +0100 Christian Neukirchen * Test Context#should.{throw,raise} Wed Dec 5 01:56:29 2007 +0100 Christian Neukirchen * Add should.throw Wed Dec 5 01:49:33 2007 +0100 Christian Neukirchen * Implement -n and -t for filtering on context/specification names Wed Dec 5 01:41:56 2007 +0100 Christian Neukirchen * Add shared contexts Wed Dec 5 01:41:39 2007 +0100 Christian Neukirchen * Make directives belong to Kernel and private Wed Dec 5 01:41:17 2007 +0100 Christian Neukirchen * Clear up error reporting Wed Dec 5 01:23:27 2007 +0100 Christian Neukirchen * Add TAP generator Thu May 31 14:32:48 2007 +0200 Christian Neukirchen * Set correct $? Thu May 31 14:28:35 2007 +0200 Christian Neukirchen * Add Test::Unit-like output (-q) Thu May 31 14:18:00 2007 +0200 Christian Neukirchen * Add standalone runner, bin/bacon Thu May 31 14:17:40 2007 +0200 Christian Neukirchen * Import test-suite Thu May 31 14:17:05 2007 +0200 Christian Neukirchen * Fix for testsuite Thu May 31 14:16:25 2007 +0200 Christian Neukirchen * Fix output Wed May 30 17:50:23 2007 +0200 Christian Neukirchen * Externalize spec/req handling Wed May 30 17:32:15 2007 +0200 Christian Neukirchen * Import Bacon, a small spec framework bacon-1.2.0/bacon.gemspec0000644000004100000410000000142112072543314015252 0ustar www-datawww-dataGem::Specification.new do |s| s.name = "bacon" s.version = '1.2.0' s.platform = Gem::Platform::RUBY s.summary = "a small RSpec clone" s.description = <<-EOF Bacon is a small RSpec clone weighing less than 350 LoC but nevertheless providing all essential features. http://github.com/chneukirchen/bacon EOF s.files = `git ls-files`.split("\n") - [".gitignore"] + %w(RDOX ChangeLog) s.bindir = 'bin' s.executables << 'bacon' s.require_path = 'lib' s.has_rdoc = true s.extra_rdoc_files = ['README.rdoc', 'RDOX'] s.test_files = [] s.author = 'Christian Neukirchen' s.email = 'chneukirchen@gmail.com' s.homepage = 'http://github.com/chneukirchen/bacon' end bacon-1.2.0/bin/0000755000004100000410000000000012072543314013375 5ustar www-datawww-databacon-1.2.0/bin/bacon0000755000004100000410000000540212072543314014406 0ustar www-datawww-data#!/usr/bin/env ruby # -*- ruby -*- require 'optparse' $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '../lib/') module Bacon; end automatic = false output = 'SpecDoxOutput' opts = OptionParser.new("", 24, ' ') { |opts| opts.banner = "Usage: bacon [options] [files | -a] [-- untouched arguments]" opts.separator "" opts.separator "Ruby options:" lineno = 1 opts.on("-e", "--eval LINE", "evaluate a LINE of code") { |line| eval line, TOPLEVEL_BINDING, "-e", lineno lineno += 1 } opts.on("-d", "--debug", "set debugging flags (set $DEBUG to true)") { $DEBUG = true } opts.on("-w", "--warn", "turn warnings on for your script") { $-w = true } opts.on("-I", "--include PATH", "specify $LOAD_PATH (may be used more than once)") { |path| $LOAD_PATH.unshift(*path.split(":")) } opts.on("-r", "--require LIBRARY", "require the library, before executing your script") { |library| require library } opts.separator "" opts.separator "bacon options:" opts.on("-s", "--specdox", "do AgileDox-like output (default)") { output = 'SpecDoxOutput' } opts.on("-q", "--quiet", "do Test::Unit-like non-verbose output") { output = 'TestUnitOutput' } opts.on("-p", "--tap", "do TAP (Test Anything Protocol) output") { output = 'TapOutput' } opts.on("-k", "--knock", "do Knock output") { output = 'KnockOutput' } opts.on("-o", "--output FORMAT", "do FORMAT (SpecDox/TestUnit/Tap) output") { |format| output = format + "Output" } opts.on("-Q", "--no-backtrace", "don't print backtraces") { Bacon.const_set :Backtraces, false } opts.on("-a", "--automatic", "gather tests from ./test/, include ./lib/") { $LOAD_PATH.unshift "lib" if File.directory? "lib" automatic = true } opts.on('-n', '--name NAME', String, "runs tests matching regexp NAME") { |n| Bacon.const_set :RestrictName, Regexp.new(n) } opts.on('-t', '--testcase TESTCASE', String, "runs tests in TestCases matching regexp TESTCASE") { |t| Bacon.const_set :RestrictContext, Regexp.new(t) } opts.separator "" opts.separator "Common options:" opts.on_tail("-h", "--help", "Show this message") do puts opts exit end opts.on_tail("--version", "Show version") do require 'bacon' puts "bacon #{Bacon::VERSION}" exit end opts.parse! ARGV } files = ARGV if automatic files.concat Dir["test/**/test_*.rb"] files.concat Dir["test/**/spec_*.rb"] files.concat Dir["spec/**/spec_*.rb"] files.concat Dir["spec/**/*_spec.rb"] end if files.empty? puts opts.banner exit 1 end require 'bacon' Bacon.extend Bacon.const_get(output) rescue abort "No such formatter: #{output}" Bacon.summary_on_exit files.each { |file| load file } bacon-1.2.0/metadata.yml0000644000004100000410000000254112072543314015132 0ustar www-datawww-data--- !ruby/object:Gem::Specification name: bacon version: !ruby/object:Gem::Version version: 1.2.0 prerelease: platform: ruby authors: - Christian Neukirchen autorequire: bindir: bin cert_chain: [] date: 2012-12-21 00:00:00.000000000 Z dependencies: [] description: ! 'Bacon is a small RSpec clone weighing less than 350 LoC but nevertheless providing all essential features. http://github.com/chneukirchen/bacon ' email: chneukirchen@gmail.com executables: - bacon extensions: [] extra_rdoc_files: - README.rdoc - RDOX files: - .travis.yml - COPYING - README.rdoc - Rakefile - bacon.gemspec - bin/bacon - lib/autotest/bacon.rb - lib/autotest/bacon_rspec.rb - lib/autotest/discover.rb - lib/bacon.rb - test/spec_bacon.rb - test/spec_nontrue.rb - test/spec_should.rb - RDOX - ChangeLog homepage: http://github.com/chneukirchen/bacon licenses: [] post_install_message: rdoc_options: [] 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: rubygems_version: 1.8.23 signing_key: specification_version: 3 summary: a small RSpec clone test_files: [] has_rdoc: true bacon-1.2.0/COPYING0000644000004100000410000000207412072543314013663 0ustar www-datawww-dataCopyright (c) 2007, 2008, 2012 Christian Neukirchen 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 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. bacon-1.2.0/RDOX0000644000004100000410000000405612072543314013331 0ustar www-datawww-data#should shortcut for #it('should') - should be called - should save some characters by typing should - should save characters even on failure - should work nested - should add new specifications - should have been called A non-true value - should pass negated tests inside specs - should pass negated tests outside specs Bacon - should have should.satisfy - should have should.== - should have should.equal - should have should.raise - should have should.change - should have should.raise with a block - should have a should.raise should return the exception - should have should.be.an.instance_of - should have should.be.nil - should have should.include - should have should.be.a.kind_of - should have should.match - should have should.not.raise - should have should.throw - should have should.not.satisfy - should have should.not.equal - should have should.not.match - should have should.be.identical_to/same_as - should have should.respond_to - should have should.be.close - should support multiple negation - should have should. - should have should (>, >=, <, <=, ===) - should allow for custom shoulds - should have should.flunk before/after - should run in the right order when nested - should run from higher level - should run at the nested level - should run in the right order - should not run from lower level when nested at a sibling level - should not run from sibling level shared/behaves_like - gets called where it is included - raises NameError when the context is not found - gets called where it is included - can access data Methods - should be accessible in a test when in a sibling context - should be accessible in a test describe arguments - should work with string string - should work with symbols behaviour - should work with modules Bacon - should work with namespaced modules Bacon::Context - should work with multiple arguments Bacon::Context empty 50 specifications (408 requirements), 0 failures, 0 errors bacon-1.2.0/lib/0000755000004100000410000000000012072543314013373 5ustar www-datawww-databacon-1.2.0/lib/autotest/0000755000004100000410000000000012072543314015243 5ustar www-datawww-databacon-1.2.0/lib/autotest/discover.rb0000644000004100000410000000035612072543314017412 0ustar www-datawww-dataAutotest.add_discovery do if File.exist?('spec/.bacon') || File.exist?('test/.bacon') class Autotest @@discoveries.delete_if { |d| d.inspect =~ /rspec/ } warn 'Removing rspec from autotest!' end 'bacon' end endbacon-1.2.0/lib/autotest/bacon_rspec.rb0000644000004100000410000000013612072543314020046 0ustar www-datawww-datarequire File.dirname(__FILE__) + '/bacon.rb' class Autotest::BaconRspec < Autotest::Bacon; endbacon-1.2.0/lib/autotest/bacon.rb0000644000004100000410000000160712072543314016656 0ustar www-datawww-dataAutotest.add_hook :initialize do |att| att.clear_mappings att.add_mapping(%r%^(test|spec)/.*\.rb$%) do |filename, _| filename end att.add_mapping(%r%^lib/(.*)\.rb$%) do |filename, m| lib_path = m[1] spec = File.basename(lib_path) path = File.dirname(lib_path) [ "test/#{path}/test_#{spec}.rb", "test/#{path}/spec_#{spec}.rb", "spec/#{path}/spec_#{spec}.rb", # TODO : decide if the follow 'rspec style' name should be allowed? # "spec/#{path}/#{spec}_spec.rb" ] end false end class Autotest::Bacon < Autotest def initialize super self.libs = %w[. lib test spec].join(File::PATH_SEPARATOR) end def make_test_cmd(files_to_test) args = files_to_test.keys.flatten.join(' ') args = '-a' if args.empty? # TODO : make regex to pass to -n using values "#{ruby} -S bacon -I#{libs} -o TestUnit #{args}" end end bacon-1.2.0/lib/bacon.rb0000644000004100000410000002055612072543314015012 0ustar www-datawww-data# Bacon -- small RSpec clone. # # "Truth will sooner come out from error than from confusion." ---Francis Bacon # Copyright (C) 2007, 2008, 2012 Christian Neukirchen # # Bacon is freely distributable under the terms of an MIT-style license. # See COPYING or http://www.opensource.org/licenses/mit-license.php. module Bacon VERSION = "1.2" Counter = Hash.new(0) ErrorLog = "" Shared = Hash.new { |_, name| raise NameError, "no such context: #{name.inspect}" } RestrictName = // unless defined? RestrictName RestrictContext = // unless defined? RestrictContext Backtraces = true unless defined? Backtraces def self.summary_on_exit return if Counter[:installed_summary] > 0 @timer = Time.now at_exit { handle_summary if $! raise $! elsif Counter[:errors] + Counter[:failed] > 0 exit 1 end } Counter[:installed_summary] += 1 end class < e rescued = true raise e ensure if Counter[:requirements] == prev_req and not rescued raise Error.new(:missing, "empty specification: #{@name} #{description}") end begin @after.each { |block| instance_eval(&block) } rescue Object => e raise e unless rescued end end rescue Object => e ErrorLog << "#{e.class}: #{e.message}\n" e.backtrace.find_all { |line| line !~ /bin\/bacon|\/bacon\.rb:\d+/ }. each_with_index { |line, i| ErrorLog << "\t#{line}#{i==0 ? ": #@name - #{description}" : ""}\n" } ErrorLog << "\n" if e.kind_of? Error Counter[e.count_as] += 1 e.count_as.to_s.upcase else Counter[:errors] += 1 "ERROR: #{e.class}" end else "" ensure Counter[:depth] -= 1 end end end def describe(*args, &block) context = Bacon::Context.new(args.join(' '), &block) (parent_context = self).methods(false).each {|e| class< e e else false end def throw?(sym) catch(sym) { call return false } return true end def change? pre_result = yield call post_result = yield pre_result != post_result end end class Numeric def close?(to, delta) (to.to_f - self).abs <= delta.to_f rescue false end end class Object def should(*args, &block) Should.new(self).be(*args, &block) end end module Kernel private def describe(*args, &block) Bacon::Context.new(args.join(' '), &block).run end def shared(name, &block) Bacon::Shared[name] = block end end class Should # Kills ==, ===, =~, eql?, equal?, frozen?, instance_of?, is_a?, # kind_of?, nil?, respond_to?, tainted? instance_methods.each { |name| undef_method name if name =~ /\?|^\W+$/ } def initialize(object) @object = object @negated = false end def not(*args, &block) @negated = !@negated if args.empty? self else be(*args, &block) end end def be(*args, &block) if args.empty? self else block = args.shift unless block_given? satisfy(*args, &block) end end alias a be alias an be def satisfy(description="", &block) r = yield(@object) if Bacon::Counter[:depth] > 0 Bacon::Counter[:requirements] += 1 raise Bacon::Error.new(:failed, description) unless @negated ^ r r else @negated ? !r : !!r end end def method_missing(name, *args, &block) name = "#{name}?" if name.to_s =~ /\w[^?]\z/ desc = @negated ? "not " : "" desc << @object.inspect << "." << name.to_s desc << "(" << args.map{|x|x.inspect}.join(", ") << ") failed" satisfy(desc) { |x| x.__send__(name, *args, &block) } end def equal(value) self == value end def match(value) self =~ value end def identical_to(value) self.equal? value end alias same_as identical_to def flunk(reason="Flunked") raise Bacon::Error.new(:failed, reason) end end