tryouts 2.0.4 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,2 +1 @@
1
- *.gemspec
2
1
  pkg
data/CHANGES.txt CHANGED
@@ -1,5 +1,13 @@
1
1
  TRYOUTS, CHANGES
2
2
 
3
+ #### 2.1.0 (2011-02-12) ###############################
4
+
5
+ * CHANGE: Default output is less verbose (eg. PASS/FAIL/SKIP)
6
+ * CHANGE: -q now prints nothing to STDOUT. Check $?. If 0, all tests pass
7
+ otherwise it contains the number of tests that failed.
8
+ * ADDED: -v option for increased output.
9
+
10
+
3
11
  #### 2.0.4 (2011-01-06) ###############################
4
12
 
5
13
  * ADDED: -q option for reduced output.
data/README.rdoc CHANGED
@@ -61,15 +61,41 @@ All code before the first test definition is assumed to be setup code. All code
61
61
 
62
62
  Try ships with a command-line tool called <tt>try</tt>. When called with no arguments, it will look for files ending with _try.rb in the current directory, or in the subfolder try.
63
63
 
64
- http://delano.github.com/tryouts/screens/tryouts-2.0-success.png
65
-
66
64
  You can also supply a specific file to test.
67
65
 
68
66
  $ try path/2/test.rb
67
+ Ruby 1.9.1 @ 2011-01-06 12:38:29 -0500
68
+
69
+ # TEST 1: test matches result with expectation
70
+ 7 a = 1 + 1
71
+ 8 #=> 2
72
+ == 2
73
+ ...
74
+
75
+ ## TEST 12: comments, tests, and expectations can
76
+ ## contain multiple lines
77
+ 13 a = 1
78
+ 14 b = 2
79
+ 15 a + b
80
+ 16 # => 3
81
+ 17 # => 2 + 1
82
+ == 3
83
+ == 3
84
+
85
+ 12 of 12 tests passed (and 5 skipped)
86
+
69
87
 
70
88
  If all tests pass, try exits with a 0. Otherwise it exits with the number of tests that failed.
71
89
 
72
- http://delano.github.com/tryouts/screens/tryouts-2.0-failure.png
90
+
91
+ For reduced output, use the `-q` option:
92
+
93
+ $ try -q
94
+ Ruby 1.9.1 @ 2011-01-06 12:38:29 -0500
95
+
96
+ 42 of 42 tests passed (and 5 skipped)
97
+ 4 of 4 batches passed
98
+
73
99
 
74
100
  == Installation
75
101
 
@@ -92,5 +118,6 @@ With help from:
92
118
 
93
119
  * Syntenic[http://syntenic.com/] for the hackfest venue.
94
120
  * AlexPeuchert[http://www.rubypulse.com/] for the screencast.
121
+ * Christian Michon for suggesting a better default output format.
95
122
 
96
123
  <i>This collision was brought to you by Montreal.rb.</i>
data/Rakefile CHANGED
@@ -33,7 +33,7 @@ end
33
33
 
34
34
 
35
35
  Rake::RDocTask.new do |rdoc|
36
- version = "#{config[:MAJOR]}.#{config[:MINOR]}.#{config[:PATCH]}.#{config[:BUILD]}"
36
+ version = "#{config[:MAJOR]}.#{config[:MINOR]}.#{config[:PATCH]}}"
37
37
  rdoc.rdoc_dir = "doc"
38
38
  rdoc.title = "stella #{version}"
39
39
  rdoc.rdoc_files.include("README*")
data/VERSION.yml CHANGED
@@ -1,5 +1,4 @@
1
1
  ---
2
2
  :MAJOR: 2
3
- :MINOR: 0
4
- :PATCH: 4
5
- :BUILD: '001'
3
+ :MINOR: 1
4
+ :PATCH: 0
data/bin/try CHANGED
@@ -7,6 +7,7 @@
7
7
  #
8
8
  # $ try
9
9
  # $ try -q
10
+ # $ try -v
10
11
  # $ try path/2/file.rb
11
12
  # $ try -q path/2/file.rb path/2/another.rb
12
13
  #
@@ -23,7 +24,13 @@ require 'tryouts'
23
24
  $:.unshift dir
24
25
  end
25
26
 
27
+ unless ARGV.delete('-V').nil?
28
+ puts "Tryouts: #{Tryouts::VERSION}"
29
+ exit
30
+ end
31
+
26
32
  Tryouts.quiet = !ARGV.delete('-q').nil? # eg try -q [PATH]
33
+ Tryouts.noisy = !ARGV.delete('-v').nil? # eg try -v [PATH]
27
34
 
28
35
  if ARGV.empty?
29
36
  paths = Dir.glob(File.join(Dir.pwd, '{try,tryouts}', '*_{try,tryouts}.rb'))
data/lib/tryouts.rb CHANGED
@@ -12,10 +12,7 @@ class Tryouts
12
12
  load_config
13
13
  [@version[:MAJOR], @version[:MINOR], @version[:PATCH]].join('.')
14
14
  end
15
- def self.inspect
16
- load_config
17
- [@version[:MAJOR], @version[:MINOR], @version[:PATCH], @version[:BUILD]].join('.')
18
- end
15
+ alias_method :inspect, :to_s
19
16
  def self.load_config
20
17
  require 'yaml'
21
18
  @version ||= YAML.load_file(File.join(TRYOUTS_LIB_HOME, '..', 'VERSION.yml'))
@@ -27,11 +24,12 @@ end
27
24
  class Tryouts
28
25
  @debug = false
29
26
  @quiet = false
27
+ @noisy = false
30
28
  @container = Class.new
31
29
  @cases = []
32
30
  @sysinfo = nil
33
31
  class << self
34
- attr_accessor :debug, :container, :quiet
32
+ attr_accessor :debug, :container, :quiet, :noisy
35
33
  attr_reader :cases
36
34
 
37
35
  def sysinfo
@@ -56,30 +54,42 @@ class Tryouts
56
54
 
57
55
  path = batch.path.gsub(/#{Dir.pwd}\/?/, '')
58
56
 
59
- msg '%-60s %s' % [path, ''] unless Tryouts.quiet # status
57
+ vmsg '%-60s %s' % [path, '']
60
58
 
61
59
  before_handler = Proc.new do |t|
62
- msg Console.reverse(' %-58s ' % [t.desc.to_s]) unless Tryouts.quiet
63
- msg t.test.inspect, t.exps.inspect unless Tryouts.quiet
60
+ if Tryouts.noisy
61
+ vmsg Console.reverse(' %-58s ' % [t.desc.to_s])
62
+ vmsg t.test.inspect, t.exps.inspect
63
+ end
64
64
  end
65
65
 
66
66
  batch.run(before_handler) do |t|
67
67
  if t.failed?
68
68
  failed_tests += 1
69
- msg Console.color(:red, t.failed.join($/)), $/ unless Tryouts.quiet
69
+ if Tryouts.noisy
70
+ vmsg Console.color(:red, t.failed.join($/)), $/
71
+ else
72
+ msg ' %s (%s:%s)' % [Console.color(:red, "FAIL"), path, t.exps.first]
73
+ end
70
74
  elsif t.skipped? || !t.run?
71
75
  skipped_tests += 1
72
- msg Console.bright(t.skipped.join($/)), $/ unless Tryouts.quiet
76
+ if Tryouts.noisy
77
+ vmsg Console.bright(t.skipped.join($/)), $/
78
+ else
79
+ msg ' SKIP (%s:%s)' % [path, t.exps.first]
80
+ end
73
81
  else
74
- msg Console.color(:green, t.passed.join($/)), $/ unless Tryouts.quiet
82
+ if Tryouts.noisy
83
+ vmsg Console.color(:green, t.passed.join($/)), $/
84
+ else
85
+ msg ' %s' % [Console.color(:green, 'PASS')]
86
+ end
75
87
  end
76
-
77
88
  all += 1
78
-
79
89
  end
80
90
  end
81
91
 
82
- msg unless Tryouts.quiet
92
+ msg
83
93
  if all > 0
84
94
  suffix = 'tests passed'
85
95
  suffix << " (and #{skipped_tests} skipped)" if skipped_tests > 0
@@ -97,7 +107,7 @@ class Tryouts
97
107
  end
98
108
 
99
109
  def cformat(*args)
100
- Console.bright '%3d of %d %s' % args
110
+ Console.bright '%d of %d %s' % args
101
111
  end
102
112
 
103
113
  def run path
@@ -175,12 +185,17 @@ class Tryouts
175
185
  end
176
186
 
177
187
  def print str
188
+ return if Tryouts.quiet
178
189
  STDOUT.print str
179
190
  STDOUT.flush
180
191
  end
181
192
 
193
+ def vmsg *msg
194
+ STDOUT.puts *msg if !Tryouts.quiet && Tryouts.noisy
195
+ end
196
+
182
197
  def msg *msg
183
- STDOUT.puts *msg
198
+ STDOUT.puts *msg unless Tryouts.quiet
184
199
  end
185
200
 
186
201
  def err *msg
data/tryouts.gemspec ADDED
@@ -0,0 +1,53 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{tryouts}
8
+ s.version = "2.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Delano Mandelbaum"]
12
+ s.date = %q{2011-02-12}
13
+ s.default_executable = %q{try}
14
+ s.description = %q{Don't waste your time writing tests}
15
+ s.email = %q{delano@solutious.com}
16
+ s.executables = ["try"]
17
+ s.extra_rdoc_files = [
18
+ "LICENSE.txt",
19
+ "README.rdoc"
20
+ ]
21
+ s.files = [
22
+ ".gitignore",
23
+ "CHANGES.txt",
24
+ "LICENSE.txt",
25
+ "README.rdoc",
26
+ "Rakefile",
27
+ "VERSION.yml",
28
+ "bin/try",
29
+ "lib/sysinfo.rb",
30
+ "lib/tryouts.rb",
31
+ "try/step1_try.rb",
32
+ "try/step2_try.rb",
33
+ "try/step3_try.rb",
34
+ "try/step4_try.rb",
35
+ "tryouts.gemspec"
36
+ ]
37
+ s.homepage = %q{http://github.com/delano/tryouts}
38
+ s.rdoc_options = ["--charset=UTF-8"]
39
+ s.require_paths = ["lib"]
40
+ s.rubyforge_project = %q{tryouts}
41
+ s.rubygems_version = %q{1.5.2}
42
+ s.summary = %q{Don't waste your time writing tests}
43
+
44
+ if s.respond_to? :specification_version then
45
+ s.specification_version = 3
46
+
47
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
48
+ else
49
+ end
50
+ else
51
+ end
52
+ end
53
+
metadata CHANGED
@@ -1,13 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tryouts
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
5
- prerelease: false
6
- segments:
7
- - 2
8
- - 0
9
- - 4
10
- version: 2.0.4
4
+ prerelease:
5
+ version: 2.1.0
11
6
  platform: ruby
12
7
  authors:
13
8
  - Delano Mandelbaum
@@ -15,7 +10,7 @@ autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
12
 
18
- date: 2011-01-06 00:00:00 -05:00
13
+ date: 2011-02-12 00:00:00 -05:00
19
14
  default_executable: try
20
15
  dependencies: []
21
16
 
@@ -42,6 +37,7 @@ files:
42
37
  - try/step2_try.rb
43
38
  - try/step3_try.rb
44
39
  - try/step4_try.rb
40
+ - tryouts.gemspec
45
41
  has_rdoc: true
46
42
  homepage: http://github.com/delano/tryouts
47
43
  licenses: []
@@ -56,23 +52,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
56
52
  requirements:
57
53
  - - ">="
58
54
  - !ruby/object:Gem::Version
59
- hash: 3
60
- segments:
61
- - 0
62
55
  version: "0"
63
56
  required_rubygems_version: !ruby/object:Gem::Requirement
64
57
  none: false
65
58
  requirements:
66
59
  - - ">="
67
60
  - !ruby/object:Gem::Version
68
- hash: 3
69
- segments:
70
- - 0
71
61
  version: "0"
72
62
  requirements: []
73
63
 
74
64
  rubyforge_project: tryouts
75
- rubygems_version: 1.3.7
65
+ rubygems_version: 1.5.2
76
66
  signing_key:
77
67
  specification_version: 3
78
68
  summary: Don't waste your time writing tests