mirror of
https://github.com/michaeldv/pit.git
synced 2025-12-09 16:05:35 +00:00
First incarnation of Ruby-based pit test suite
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
class Hand < RuntimeError
|
||||
def oops(msg)
|
||||
puts "\n#{msg} in #{self.backtrace[-1].sub(':', ' line ')}"
|
||||
puts "\n#{msg} in #{self.backtrace[1].sub(':', ' line ')}"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -42,17 +42,18 @@ class String
|
||||
end
|
||||
end
|
||||
|
||||
"123".should.equal "123"
|
||||
"123".should.equal "321"
|
||||
if $0 == __FILE__
|
||||
"123".should.equal "123"
|
||||
"123".should.equal "321"
|
||||
|
||||
"123".should_not.equal "321"
|
||||
"123".should_not.equal "123"
|
||||
"123".should_not.equal "321"
|
||||
"123".should_not.equal "123"
|
||||
|
||||
"abc".should.match /B/i
|
||||
"abc".should.match /xyz/
|
||||
|
||||
"abc".should_not.match /xyz/
|
||||
"abc".should_not.match /abc/
|
||||
"abc".should.match /B/i
|
||||
"abc".should.match /xyz/
|
||||
|
||||
"abc".should_not.match /xyz/
|
||||
"abc".should_not.match /abc/
|
||||
end
|
||||
|
||||
|
||||
80
test/pit_test.rb
Executable file
80
test/pit_test.rb
Executable file
@@ -0,0 +1,80 @@
|
||||
#!/usr/bin/env ruby
|
||||
#
|
||||
BASE = File.dirname(File.expand_path(__FILE__))
|
||||
require "#{BASE}/pit_should"
|
||||
|
||||
class PitTestRunner
|
||||
def self.run
|
||||
runner = self.new
|
||||
runner.public_methods.grep(/^should_/).each do |method|
|
||||
runner.send(:before) if runner.respond_to?(:before)
|
||||
runner.send(method)
|
||||
runner.send(:after) if runner.respond_to?(:after)
|
||||
end
|
||||
puts
|
||||
end
|
||||
|
||||
def initialize
|
||||
@pit = "#{BASE.sub(/test$/, 'bin')}/pit"
|
||||
if File.executable?(@pit)
|
||||
ENV['PITFILE'] = "#{BASE}/test.pitfile"
|
||||
puts "Testing #{@pit} with #{ENV['PITFILE']}"
|
||||
else
|
||||
raise("\nCould not run #{@pit}")
|
||||
end
|
||||
end
|
||||
|
||||
def before
|
||||
`#{@pit} init -f`
|
||||
`#{@pit} project -c test`
|
||||
end
|
||||
|
||||
def should_parse_alpha_dates
|
||||
`#{@pit} task -c test -d "dec 1, 2011 19:30"`
|
||||
`#{@pit} task`.should.match /Dec 01, 2011 19:30/m
|
||||
`#{@pit} task -c test -d "dec 1, 2012 1:15pm"`
|
||||
`#{@pit} task`.should.match /Dec 01, 2012 13:15/m
|
||||
`#{@pit} task -c test -d "dec 1, 2013 11"`
|
||||
`#{@pit} task`.should.match /Dec 01, 2013 11:00/m
|
||||
`#{@pit} task -c test -d "dec 1, 2013 7pm"`
|
||||
`#{@pit} task`.should.match /Dec 01, 2013 19:00/m
|
||||
`#{@pit} task -c test -d "dec 1, 2013"`
|
||||
`#{@pit} task`.should.match /Dec 01, 2013 /m
|
||||
`#{@pit} task -c test -d "dec 1 5:55"`
|
||||
`#{@pit} task`.should.match /Dec 01, #{Time.now.year} 05:55/m
|
||||
`#{@pit} task -c test -d "dec 1 2:40pm"`
|
||||
`#{@pit} task`.should.match /Dec 01, #{Time.now.year} 14:40/m
|
||||
# `#{@pit} task -c test -d "dec 1 5"`
|
||||
# `#{@pit} task`.should.match /Dec 01, #{Time.now.year} 05:00/m
|
||||
# `#{@pit} task -c test -d "dec 1 3pm"`
|
||||
# `#{@pit} task`.should.match /Dec 01, #{Time.now.year} 15:00/m
|
||||
`#{@pit} task -c test -d "dec 1"`
|
||||
`#{@pit} task`.should.match /Dec 01, #{Time.now.year} /m
|
||||
end
|
||||
|
||||
def should_parse_slash_dates
|
||||
`#{@pit} task -c test -d "12/1/2011 19:30"`
|
||||
`#{@pit} task`.should.match /Dec 01, 2011 19:30/m
|
||||
`#{@pit} task -c test -d "12/1/2012 1:15pm"`
|
||||
`#{@pit} task`.should.match /Dec 01, 2012 13:15/m
|
||||
`#{@pit} task -c test -d "12/1/2013 11"`
|
||||
`#{@pit} task`.should.match /Dec 01, 2013 11:00/m
|
||||
`#{@pit} task -c test -d "12/1/2013 7pm"`
|
||||
`#{@pit} task`.should.match /Dec 01, 2013 19:00/m
|
||||
`#{@pit} task -c test -d "12/1/2013"`
|
||||
`#{@pit} task`.should.match /Dec 01, 2013 /m
|
||||
`#{@pit} task -c test -d "12/1 5:55"`
|
||||
`#{@pit} task`.should.match /Dec 01, #{Time.now.year} 05:55/m
|
||||
`#{@pit} task -c test -d "12/1 2:40pm"`
|
||||
`#{@pit} task`.should.match /Dec 01, #{Time.now.year} 14:40/m
|
||||
# `#{@pit} task -c test -d "12/1 5"`
|
||||
# `#{@pit} task`.should.match /Dec 01, #{Time.now.year} 05:00/m
|
||||
# `#{@pit} task -c test -d "12/1 3pm"`
|
||||
# `#{@pit} task`.should.match /Dec 01, #{Time.now.year} 15:00/m
|
||||
`#{@pit} task -c test -d "12/1"`
|
||||
`#{@pit} task`.should.match /Dec 01, #{Time.now.year} /m
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
PitTestRunner.run
|
||||
BIN
test/test.pitfile
Normal file
BIN
test/test.pitfile
Normal file
Binary file not shown.
Reference in New Issue
Block a user