tryouts 0.8.8 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/try/step1_try.rb ADDED
@@ -0,0 +1,51 @@
1
+ require 'rubygems'
2
+ require 'hexoid'
3
+
4
+ POOP = 1
5
+
6
+ # TEST 1: test matches result with expectation
7
+ a = 1 + 1
8
+ #=> 2
9
+
10
+
11
+ ## TEST 2: comments, tests, and expectations can
12
+ ## contain multiple lines
13
+ a = 1
14
+ b = 2
15
+ a + b
16
+ # => 3
17
+ # => 2 + 1
18
+
19
+ # TEST 3: test expectation type matters
20
+ 'foo'.class
21
+ #=> String
22
+
23
+
24
+ # TEST 4: instance variables can be used in expectations
25
+ @a = 1
26
+ @a
27
+ #=> @a
28
+
29
+
30
+ # TEST 5: test ignores blank lines before expectations
31
+ @a += 1
32
+ 'foo'
33
+
34
+
35
+ #=> 'foo'
36
+
37
+
38
+ # TEST 6: test allows whiny expectation markers for textmate users *sigh*
39
+ 'foo'
40
+ # => 'foo'
41
+
42
+
43
+ # TEST 7: test expectations can be commented out
44
+ 'foo'
45
+ ##=> 'this would fail'
46
+
47
+ x = raise rescue 'foo'
48
+ #=> 'foo'
49
+
50
+
51
+
data/try/step2_try.rb ADDED
@@ -0,0 +1,59 @@
1
+ # run me with
2
+ # ruby -rubygems -Ilib step1_tryouts.rb
3
+
4
+
5
+ ## some addition
6
+ a = 1
7
+ b = 2
8
+ a + b + 1
9
+ # => 4
10
+
11
+
12
+ # multiple expectations
13
+ 'foo' + 'bar'
14
+ #=> 'foobar'
15
+ #=> :foobar.to_s
16
+
17
+
18
+ # test ignores comments before expectations
19
+ 'foo'
20
+ # ignored comment
21
+ # ignored comment
22
+ #=> 'foo'
23
+
24
+
25
+ ## test uses helper methods
26
+ ## ( #foo is defined on top of file )
27
+ #foo()
28
+ ##=> foo
29
+
30
+
31
+ #begin
32
+ # raise
33
+ #rescue
34
+ # 'foo'
35
+ #end
36
+ ##=> 'foo'
37
+
38
+ ## test handles multiple code lines
39
+ ## only only tests last line against expectation
40
+ #str = ""
41
+ #str << 'foo'
42
+ #str << 'bar'
43
+ #str
44
+ ##=> 'foobar'
45
+ ##
46
+ ### test failure
47
+ ##'this fails'
48
+ ###=> 'expectation not met'
49
+ #
50
+
51
+
52
+ #
53
+ # require 'pathname'
54
+ # require Pathname(__FILE__).dirname.parent + 'lib/nofw'
55
+ #
56
+ # # test failure
57
+ # 'this fails'
58
+ # #=> 'expectation not met'
59
+ #
data/try/step3_try.rb ADDED
@@ -0,0 +1,19 @@
1
+
2
+
3
+ begin
4
+ raise
5
+ rescue
6
+ 'foo'
7
+ end
8
+ #=> 'foo'
9
+
10
+ # test handles multiple code lines
11
+ # only only tests last line against expectation
12
+ str = ""
13
+ str << 'foo'
14
+ str << 'bar'
15
+ str
16
+ #=> 'foobar'
17
+
18
+
19
+
data/try/step4_try.rb ADDED
@@ -0,0 +1,6 @@
1
+ require 'pathname'
2
+ require Pathname(__FILE__).dirname.parent + 'lib/nofw'
3
+
4
+
5
+ # The syntax could be a derivative from step 3 (helpers?)
6
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tryouts
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.8
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Delano Mandelbaum
@@ -9,94 +9,39 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-02-20 00:00:00 -05:00
13
- default_executable:
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: rye
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: "0"
24
- version:
25
- - !ruby/object:Gem::Dependency
26
- name: drydock
27
- type: :runtime
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: "0"
34
- version:
35
- - !ruby/object:Gem::Dependency
36
- name: sysinfo
37
- type: :runtime
38
- version_requirement:
39
- version_requirements: !ruby/object:Gem::Requirement
40
- requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- version: "0"
44
- version:
45
- description: Tryouts is a high-level testing library (DSL) for your Ruby codes and command-line applications.
46
- email: tryouts@solutious.com
12
+ date: 2010-07-18 00:00:00 -04:00
13
+ default_executable: try
14
+ dependencies: []
15
+
16
+ description: Put your Ruby tests in comments.
17
+ email: delano@solutious.com
47
18
  executables:
48
- - sergeant
19
+ - try
49
20
  extensions: []
50
21
 
51
22
  extra_rdoc_files:
52
- - README.rdoc
53
23
  - LICENSE.txt
54
- - CHANGES.txt
24
+ - README.rdoc
55
25
  files:
56
- - CHANGES.txt
26
+ - .gitignore
57
27
  - LICENSE.txt
58
28
  - README.rdoc
59
29
  - Rakefile
60
- - bin/mockout
61
- - bin/sergeant
30
+ - VERSION.yml
31
+ - bin/try
32
+ - lib/sysinfo.rb
62
33
  - lib/tryouts.rb
63
- - lib/tryouts/cli.rb
64
- - lib/tryouts/cli/run.rb
65
- - lib/tryouts/drill.rb
66
- - lib/tryouts/drill/context.rb
67
- - lib/tryouts/drill/dream.rb
68
- - lib/tryouts/drill/reality.rb
69
- - lib/tryouts/drill/response.rb
70
- - lib/tryouts/drill/sergeant/api.rb
71
- - lib/tryouts/drill/sergeant/benchmark.rb
72
- - lib/tryouts/drill/sergeant/cli.rb
73
- - lib/tryouts/drill/sergeant/rbenchmark.rb
74
- - lib/tryouts/mixins.rb
75
- - lib/tryouts/orderedhash.rb
76
- - lib/tryouts/stats.rb
77
- - lib/tryouts/tryout.rb
78
- - tryouts.gemspec
79
- - tryouts/01_mixins_tryouts.rb
80
- - tryouts/10_syntax_tryouts.rb
81
- - tryouts/14_set_tryouts.rb
82
- - tryouts/15_dreams_tryouts.rb
83
- - tryouts/20_cli_tryouts.rb
84
- - tryouts/30_benchmark_tryouts.rb
85
- - tryouts/50_class_context_tryouts.rb
86
- - tryouts/X1_new_api_syntax.rb
87
- - tryouts/X2_new_cli_syntax.rb
88
- - tryouts/standalone_test.rb
34
+ - try/step1_try.rb
35
+ - try/step2_try.rb
36
+ - try/step3_try.rb
37
+ - try/step4_try.rb
89
38
  has_rdoc: true
90
39
  homepage: http://github.com/delano/tryouts
91
40
  licenses: []
92
41
 
93
42
  post_install_message:
94
43
  rdoc_options:
95
- - --line-numbers
96
- - --title
97
- - "Tryouts: Tryouts is a high-level testing library (DSL) for your Ruby codes and command-line applications."
98
- - --main
99
- - README.rdoc
44
+ - --charset=UTF-8
100
45
  require_paths:
101
46
  - lib
102
47
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -116,7 +61,7 @@ requirements: []
116
61
  rubyforge_project: tryouts
117
62
  rubygems_version: 1.3.5
118
63
  signing_key:
119
- specification_version: 2
120
- summary: Tryouts is a high-level testing library (DSL) for your Ruby codes and command-line applications.
64
+ specification_version: 3
65
+ summary: Put your Ruby tests in comments.
121
66
  test_files: []
122
67
 
data/CHANGES.txt DELETED
@@ -1,202 +0,0 @@
1
- TRYOUTS, CHANGES
2
-
3
- * TODO: consider having set create var= methods too.
4
- * TODO: Support: "sergeant 30:52"
5
- * TODO: FIXED: output for quiet mode
6
- * TODO: Run clean after reports have been generated. See Gibbler 256 tryouts.
7
- * TODO: Load tryouts/setup.rb and tryouts/clean.rb
8
- * TODO: Support Hash syntax in set,
9
- set :name => value
10
- * TODO: Support tryouts/*_drills.rb and tryouts/*_tryout.rb
11
- * TODO: Clear stash between drills
12
-
13
-
14
- #### 0.8.8 (2010-02-20) ###############################
15
-
16
- * FIXED: Missing meta_def method (require attic)
17
- * CHANGE: Try not to use autoload for the required dependencies. [Diego Elio 'Flameeyes' Pettenò]
18
-
19
-
20
- #### 0.8.7 (2010-02-15) ###############################
21
-
22
- * CHANGE: Removed hanna dependency
23
-
24
- #### 0.8.6 (2009-11-29) ###############################
25
-
26
- * CHANGE: Removed Attic dependency
27
-
28
- #### 0.8.5 (2009-10-07) ###############################
29
-
30
- NOTE: Benchmark tryouts must now use proc style dreams
31
-
32
- * CHANGE: Benchmark tryouts now display complex benchmark info
33
- (utime, stime, cutime, cstime, total, real)
34
- * CHANGE: Benchmark tryouts now run a brief warmup
35
- * CHANGE: Improved startup time (via autoload)
36
-
37
-
38
- #### 0.8.4 (2009-07-20) ###############################
39
-
40
- * CHANGE: "setup" and "clean" blocks now run in the same DrillContext
41
- instance as drills (so instance variables are now shared)
42
- * CHANGE: Non-fatal errors are now displayed only in verbose mode.
43
- * ADDED: "set" keyword inside tryout definitions.
44
- * ADDED: New dependency: attic
45
-
46
-
47
- #### 0.8.3 (2009-07-19) ###############################
48
-
49
- * FIXED: Updated gemspec
50
-
51
- #### 0.8.2 (2009-07-19) ###############################
52
-
53
- * CHANGE: Moved Drill and Reality to separate files.
54
- * CHANGE: dream blocks are now lazy executed just before the
55
- drill is executed.
56
-
57
-
58
- #### 0.8.1 (2009-07-14) ###############################
59
-
60
- * CHANGE: Fixed parentheses warning in tryouts.rb for Ruby 1.8
61
- * CHANGE: rye is now loaded when running CLI tryouts.
62
-
63
-
64
- #### 0.8.0 (2009-07-01) ###############################
65
-
66
- NOTE: :cli drills are available again
67
-
68
- * CHANGE: Dream definition block no longer support the rcode,
69
- output, format, and emsg methods. Now: the return value of
70
- the block is used at the dream.output
71
-
72
- dream do
73
- "output value"
74
- end
75
-
76
- dream :format do
77
- "output value"
78
- end
79
-
80
- * CHANGE: Improved clarity of [nodream] error message
81
- * ADDED: Re-introduced :cli drill support.
82
-
83
-
84
- #### 0.7.4 (2009-06-29) ###############################
85
-
86
- * FIXED: The stash method is now available to :benchmark drills
87
- * FIXED: Specifying a single argument to drill with a block now
88
- correctly parses the arg as the expected dream output.
89
- * CHANGE: Differentiated non-fatal error messages for successful drills
90
- * CHANGE: Context sensitive message for LoadErrors in Tryouts#library
91
-
92
-
93
- #### 0.7.3 (2009-06-27) ###############################
94
-
95
- * ADDED: Display Tryouts group name for runtime errors.
96
- * ADDED: Improved LoadError error message
97
- * ADDED: Print error messages for drills that PASS.
98
- * ADDED: Better error handling when supplied tryouts file is not found
99
-
100
-
101
- #### 0.7.2 (2009-06-26) ###############################
102
-
103
- NOTE: You will need to make a syntax change to your tryouts.
104
- OLD: dream OUTPUT, :format
105
- NEW: dream :format, OUTPUT
106
-
107
- * CHANGE: Order of dream arguments is reversed!
108
- * CHANGE: Reduced CLI width to 79
109
-
110
-
111
- #### 0.7.1 (2009-06-26) ###############################
112
-
113
- * FIXED: Updated manifest in gemspec
114
- * CHANGE: :cli testing is disabled indefinitely
115
- * ADDED: Found Muggsy Bogues
116
-
117
-
118
- #### 0.7.0 (2009-06-25) ###############################
119
-
120
- * FIXED: Stash wasn't being displayed in the drill report
121
- * CHANGE: CLI is now formatted to be 80 characters wide.
122
- * ADDED: Tryouts::Drill::Sergeant::Benchmark
123
- * ADDED: Tryouts::Stats
124
- * ADDED: new dream formats: :mean and :sdev which compare with <=.
125
- dream 10, :mean
126
- drill "do something" do; ...; end # stats.mean <= 10
127
- * ADDED: new dream format: :proc
128
- dream lambda { |x| x.real < 0.1 }, :proc
129
- drill("array sort!") { @@array.dup.sort! }
130
-
131
-
132
- #### 0.6.3 (2009-06-25) ###############################
133
-
134
- NOTE: command testing (:cli) is still disabled.
135
-
136
- * FIXED: Now correctly append to existing Tryouts object
137
- * CHANGE: Renamed :regex format to :match
138
- * ADDED: Hella better runtime error handling
139
- * ADDED: Better support for quiet (-q)
140
- * ADDED: Verbose output now displays each dream vs reality
141
- * ADDED: Skipped drills now appear in the report
142
- * ADDED: new dream format: :ne (!=)
143
-
144
-
145
- #### 0.6.2 (2009-06-24) ###############################
146
-
147
- NOTE: command testing (:cli) is still disabled.
148
-
149
- * CHANGE: dream arguments are now ordered: format, output
150
- * ADDED: One-liner drill syntax
151
- * ADDED: new dream formats: :regex, :gt, :gte, :lt, :lte, :size
152
- * ADDED: Calls to xdrill now also clear the dream catcher
153
- * ADDED: Support for multiple dreams per drill
154
-
155
-
156
- #### 0.6.1 (2009-06-24) ###############################
157
-
158
- NOTE: command testing (:cli) is still disabled.
159
-
160
- * FIXED: JRuby is now supported
161
- * FIXED: Now correctly requiring sysinfo library
162
- * CHANGE: Don't require rye until a CLI sergeant is created.
163
-
164
-
165
- #### 0.6.0 (2009-06-24) ###############################
166
-
167
- NOTE: External dreams files are no longer supported.
168
- NOTE: command testing (:cli) is disabled.
169
-
170
- * CHANGE: Removed all mention of external dreams files.
171
- * CHANGE: dream method is not available inside drill block.
172
- * CHANGE: rcode, emsg, backtrace renamed to ecode, error, trace
173
- * ADDED: dream is now available above drill blocks.
174
- * ADDED: Better verbose and debugging output
175
- * ADDED: Cleaner test output
176
- * ADDED: drill success is now solely based on output.
177
-
178
-
179
- #### 0.5.1 (2009-06-13) ###############################
180
-
181
- * ADDED: dream method is now available inside drill block
182
- * ADDED: Drills that return true are assumed to pass
183
-
184
-
185
- #### 0.5.0 (2009-06-07) ###############################
186
-
187
- * FIXED: Fix for running drills without dreams and for specifying verbose without a command name
188
- * CHANGE: The executable has been renamed to 'sergeant'
189
- * CHANGE: Gave reality a default rcode (0)
190
- * CHANGE: Now using module_eval (was: class_eval) for setup and clean
191
- * ADDED: Displays percentage of failed dreams
192
- * ADDED: Drill stash!
193
- * ADDED: xdream and better handling for drills and dreams with no name
194
-
195
-
196
- #### 0.4.1 (2009-06-07) ###############################
197
-
198
- * CHANGE: The CLI output is no longer terrifyingly ugly
199
-
200
- #### 0.4.0 (2009-06-05) ###############################
201
-
202
- NOTE: Initial public release
data/bin/mockout DELETED
@@ -1,54 +0,0 @@
1
- #!/usr/bin/ruby
2
-
3
- # = Mockout
4
- #
5
- # This mock is used to generate test output for Tryouts itself.
6
- # It is otherwise uninteresting!
7
- #
8
-
9
- require 'rubygems'
10
- require 'drydock'
11
- require 'yaml'
12
-
13
- begin; require 'json'; rescue LoadError; end # json may not be installed
14
-
15
- module DrillCLI
16
- extend Drydock
17
-
18
- global :q, :quiet, "Don't print anything to STDOUT or STDERR"
19
-
20
- default :echo
21
- debug :on
22
-
23
- about "Echo all arguments"
24
- command :echo do |obj|
25
- puts obj.argv unless obj.global.quiet
26
- end
27
-
28
- about "Returns PASS or FAIL"
29
- option :p, :pass, "Always pass"
30
- command :test do |obj|
31
- rate = obj.option.pass ? 0 : 0.4
32
- puts rand >= rate ? "PASS" : "FAIL" unless obj.global.quiet
33
- end
34
-
35
- about "Prints current date in UTC"
36
- command :date do |obj|
37
- puts Time.now.utc unless obj.global.quiet
38
- end
39
-
40
- about "Exits with a non-zero exit code"
41
- option :e, :ecode, Integer, "The exit code to fail with (default: 1)"
42
- command :error do |obj|
43
- ecode = obj.option.ecode.nil? ? 1 : obj.option.ecode
44
- unless obj.global.quiet
45
- STDERR.puts "STDERR output (#{ecode})"
46
- STDOUT.puts "STDOUT output (#{ecode})"
47
- end
48
- exit ecode
49
- end
50
-
51
- end
52
-
53
- Drydock.run!(ARGV, STDIN) if Drydock.run?
54
-
data/bin/sergeant DELETED
@@ -1,66 +0,0 @@
1
- #!/usr/bin/ruby
2
-
3
- TRYOUTS_HOME = File.expand_path(File.join(File.dirname(__FILE__), '..'))
4
-
5
- $:.unshift File.join(TRYOUTS_HOME, 'lib')
6
- local_libs = %w{tryouts drydock rye storable sysinfo attic}
7
- local_libs.each { |dir| $:.unshift File.join(TRYOUTS_HOME, '..', dir, 'lib') }
8
-
9
- require 'drydock'
10
- require 'tryouts'
11
- require 'tryouts/cli'
12
-
13
- # = TryoutsCLI
14
- #
15
- # This is the Drydock definition for the bin/tryouts executable
16
- module TryoutsCLI
17
- extend Drydock
18
-
19
- debug :off
20
- default :run, :with_args
21
-
22
- global :q, :quiet, "Decrease output"
23
- global :V, :version, "Display version number" do
24
- puts "Tryouts version: #{Tryouts::VERSION}"
25
- exit 0
26
- end
27
- global :v, :verbose, "Increase output" do
28
- @verbose ||= 0
29
- @verbose += 1
30
- end
31
-
32
- about "Run tryouts from current working directory"
33
- argv :files
34
- option :q, :quiet, "Decrease output (same as global)"
35
- option :v, :verbose, "Increase output (same as global)" do
36
- @verbose ||= 0
37
- @verbose += 1
38
- end
39
- command :run => Tryouts::CLI::Run
40
-
41
- about "Show dreams available from the current working directory"
42
- argv :files
43
- option :q, :quiet, "Decrease output (same as global)"
44
- option :v, :verbose, "Increase output (same as global)" do
45
- @verbose ||= 0
46
- @verbose += 1
47
- end
48
- command :dreams => Tryouts::CLI::Run
49
-
50
- about "Show tryouts available from the current working directory"
51
- argv :files
52
- option :q, :quiet, "Decrease output (same as global)"
53
- option :v, :verbose, "Increase output (same as global)" do
54
- @verbose ||= 0
55
- @verbose += 1
56
- end
57
- command :list => Tryouts::CLI::Run
58
-
59
- end
60
-
61
- begin
62
- Drydock.run!(ARGV, STDIN) if Drydock.run?
63
- rescue Tryouts::Exception => ex
64
- puts ex.message
65
- puts ex.backtrace if Tryouts.debug?
66
- end