delano-tryouts 0.7.4 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES.txt CHANGED
@@ -1,6 +1,25 @@
1
1
  TRYOUTS, CHANGES
2
2
 
3
-
3
+ #### 0.8.0 (2009-07-01) ###############################
4
+
5
+ NOTE: :cli drills are available again
6
+
7
+ * CHANGE: Dream definition block no longer support the rcode,
8
+ output, format, and emsg methods. Now: the return value of
9
+ the block is used at the dream.output
10
+
11
+ dream do
12
+ "output value"
13
+ end
14
+
15
+ dream :format do
16
+ "output value"
17
+ end
18
+
19
+ * CHANGE: Improved clarity of [nodream] error message
20
+ * ADDED: Re-introduced :cli drill support.
21
+
22
+
4
23
  #### 0.7.4 (2009-06-29) ###############################
5
24
 
6
25
  * FIXED: The stash method is now available to :benchmark drills
data/README.rdoc CHANGED
@@ -1,6 +1,6 @@
1
- = Tryouts - v0.7 BETA
1
+ = Tryouts - v0.8 BETA
2
2
 
3
- Tryouts is a high-level testing library (DSL) for your Ruby codes.
3
+ Tryouts is a high-level testing library (DSL) for your Ruby codes and command-line applications.
4
4
 
5
5
  A tryout is made up of one of more drills. The return value of the drill block is compared to the expectations defined by one or more dreams. The goal is to achieve your dreams.
6
6
 
@@ -16,17 +16,6 @@ A tryout is made up of one of more drills. The return value of the drill block i
16
16
  $ gem install tryouts
17
17
 
18
18
 
19
- == NOTICE (2009-06-26): DSL Syntax Change
20
-
21
- The order of dream arguments has reversed between 0.7.1 and 0.7.2. It is now:
22
-
23
- * <tt>dream :method, 'Expected value'</tt>
24
-
25
- This is a return to the original syntax and I think it's the right way to go because it reads more naturally:
26
-
27
- * <tt>drill 'test name', 'return value', :class, String</tt>
28
-
29
-
30
19
  == Writing Tests
31
20
 
32
21
  The examples below are a complete overview of Tryouts syntax.
@@ -67,7 +56,38 @@ The examples below are a complete overview of Tryouts syntax.
67
56
 
68
57
  end
69
58
 
70
- === Benchmarks (:benchmark)
59
+ === Testing Command-Line Applications (:cli)
60
+
61
+ You can execute drills on command-line applications.
62
+
63
+ command :rudy, "path/2/rudy"
64
+
65
+ tryouts "Rudy CLI", :cli do
66
+
67
+ # We have specified the name of the command above so
68
+ # we only need to specify the arguments in the drill.
69
+ # $ rudy myaddress -e
70
+ drill "can display my IP addresses", :myaddress, :e
71
+
72
+ # The drill returns an Array of lines from STDOUT so
73
+ # we can use Array#grep to check the command output.
74
+ # If any lines match, this test will pass.
75
+ dream :grep, /No machines running/
76
+ drill "can call with no arguments"
77
+
78
+ # Drills can also be defined with a block which gets
79
+ # executed via Rye::Box#batch. Methods in the block
80
+ # are executed as commands. The return value of the
81
+ # block is considered the test output.
82
+ dream :match, /\d+\.\d+\.\d+\.\d+/
83
+ drill "can execute a block of commands" do
84
+ ret = rudy :q, :myaddress, :e
85
+ ret.first
86
+ end
87
+
88
+ end
89
+
90
+ === Running Performance Benchmarks (:benchmark)
71
91
 
72
92
  You can also use Tryouts to run benchmarks. The tryouts method takes a second parameter which specifies which drill sergeant to use. Below we specify <tt>:benchmark</tt> so each drill is timed and executed multiple times.
73
93
 
@@ -138,15 +158,41 @@ In quiet mode, the sergeant returns only a PASS or FAIL message (in the case of
138
158
 
139
159
  == Screenshots
140
160
 
141
- Here is an example of Tryouts output from a gibbler[http://github.com/delano/gibbler/blob/gibbler-0.2.1/tryouts/gibbler_tryouts.rb] tryout:
161
+ === :api Tryouts
142
162
 
143
- http://github.com/delano/tryouts/raw/gh-pages/screens/tryouts-1-failure.png
163
+ http://delano.github.com/tryouts/screens/tryouts-0.8-api.png
144
164
 
145
- The drill that failed looks like this:
165
+ <i>from gibbler[http://github.com/delano/gibbler/blob/master/tryouts/10_basic_tryouts.rb]</i>
146
166
 
147
- dream :respond_to?, :to_gibble
148
- dream :to_gibble, 'ab33b9dec202d136d0e695a3a7b06ee678134882'
149
- drill Array, "Array"
167
+
168
+ === :cli Tryouts (verbose)
169
+
170
+ http://delano.github.com/tryouts/screens/tryouts-0.8-cli.png
171
+
172
+ <i>from tryouts[http://github.com/delano/tryouts/blob/master/tryouts/20_cli_tryouts.rb]</i>
173
+
174
+
175
+ === :benchmark Tryouts (verbose)
176
+
177
+ http://delano.github.com/tryouts/screens/tryouts-0.8-benchmark.png
178
+
179
+ <i>from gibbler[http://github.com/delano/gibbler/blob/master/tryouts/80_performance_tryouts.rb]</i>
180
+
181
+ == News
182
+
183
+ === 2009-07-01: Drills for command-line applications
184
+
185
+ Support for testing command-line applications has been re-introduced in 0.8. See example code further down in this README.
186
+
187
+ === 2009-06-26: DSL Syntax Change
188
+
189
+ The order of dream arguments has reversed between 0.7.1 and 0.7.2. It is now:
190
+
191
+ * <tt>dream :method, 'Expected value'</tt>
192
+
193
+ This is a return to the original syntax and I think it's the right way to go because it reads more naturally in the one-liner format:
194
+
195
+ * <tt>drill 'test name', 'return value', :class, String</tt>
150
196
 
151
197
 
152
198
  == BETA Notice
@@ -175,6 +221,7 @@ Tryouts does some funky stuff to make it simple to write tests. This "funky stuf
175
221
 
176
222
  * Everyone at Utrecht.rb and Amsterdam.rb for putting up with my Ruby questions :]
177
223
  * Sam Aaron (http://sam.aaron.name) for the early feedback.
224
+ * Kalin Harvey for the encouragement.
178
225
 
179
226
 
180
227
  == Credits
data/bin/mockout CHANGED
@@ -15,35 +15,40 @@ begin; require 'json'; rescue LoadError; end # json may not be installed
15
15
  module DrillCLI
16
16
  extend Drydock
17
17
 
18
- global :f, :format, String, "One of: json, yaml, string (default)"
18
+ global :q, :quiet, "Don't print anything to STDOUT or STDERR"
19
19
 
20
-
21
- default :info
20
+ default :echo
22
21
  debug :on
22
+
23
+ about "Echo all arguments"
24
+ command :echo do |obj|
25
+ puts obj.argv unless obj.global.quiet
26
+ end
23
27
 
24
- data = {
25
- "Date" => "2009-02-16",
26
- "Owners" => ["greg", "rupaul", "telly", "prince kinko"],
27
- "Players" => ["d-bam", "alberta", "birds", "condor man"]
28
- }
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
29
34
 
30
- option :e, :echo, "Echo the arguments"
31
- command :info do |obj|
32
- format = obj.global.format.nil? ? nil : "to_#{obj.global.format}"
33
- format = nil if obj.global.format == 'string'
34
- if obj.option.echo
35
- puts obj.argv
36
- else
37
- if format.nil?
38
- data.keys.sort.each do |n|
39
- val = data[n]
40
- val = val.join(', ') if val.is_a?(Array)
41
- puts "%9s %44s" % ["#{n}:", val]
42
- end
43
- else
44
- puts data.send(format)
45
- end
46
- end
35
+ about "Prints current date in UTC"
36
+ command :date do |obj|
37
+ puts Time.now.utc unless obj.global.quiet
47
38
  end
48
39
 
49
- end
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/lib/tryouts.rb CHANGED
@@ -4,6 +4,7 @@ require 'sysinfo'
4
4
  require 'digest/sha1'
5
5
  require 'ostruct'
6
6
  require 'yaml'
7
+ require 'rye'
7
8
 
8
9
  begin; require 'json'; rescue LoadError; end # json may not be installed
9
10
 
@@ -41,7 +42,7 @@ class Tryouts
41
42
  end
42
43
  end
43
44
 
44
- VERSION = "0.7.4"
45
+ VERSION = "0.8.0"
45
46
 
46
47
  require 'tryouts/mixins'
47
48
  require 'tryouts/tryout'
@@ -119,7 +120,7 @@ class Tryouts
119
120
  # Add a shell command to Rye::Cmd and save the command name
120
121
  # in @@commands so it can be used as the default for drills
121
122
  def command(name=nil, path=nil)
122
- raise "command testing is temporarily disabled"
123
+ #raise "command testing is temporarily disabled"
123
124
  return @command if name.nil?
124
125
  @command = name.to_sym
125
126
  @dtype = :cli
data/lib/tryouts/drill.rb CHANGED
@@ -32,7 +32,7 @@ class Tryouts
32
32
  # A Reality object (the actual output of the test)
33
33
  attr_reader :reality
34
34
 
35
- @@valid_dtypes = [:api, :benchmark]
35
+ @@valid_dtypes = [:api, :cli, :benchmark]
36
36
 
37
37
  # * +name+ The display name of this drill
38
38
  # * +dtype+ A Symbol representing the drill type. One of: :api, :benchmark
@@ -48,8 +48,16 @@ class Tryouts
48
48
  def initialize(name, dtype, *args, &drill)
49
49
  @name, @dtype, @drill, @skip = name, dtype, drill, false
50
50
  @dreams = []
51
+
52
+ # We create a default empty reality but if the drill runs correctly
53
+ # this reality gets replaced with the return value from the drill.
54
+ @reality = Tryouts::Drill::Reality.new
55
+
51
56
  case @dtype
52
57
  when :cli
58
+ # For CLI drills, a block takes precedence over inline args.
59
+ # A block will contain multiple shell commands (see Rye::Box#batch)
60
+ args = [] if dtype == :cli && drill.is_a?(Proc)
53
61
  @sergeant = Tryouts::Drill::Sergeant::CLI.new *args
54
62
  when :api
55
63
  default_output = drill.nil? ? args.shift : nil
@@ -79,10 +87,8 @@ class Tryouts
79
87
  raise NoSergeant, "Weird drill sergeant: #{@dtype}"
80
88
  end
81
89
  @clr = :red
82
- # For CLI drills, a block takes precedence over inline args.
83
- # A block will contain multiple shell commands (see Rye::Box#batch)
84
- drill_args = [] if dtype == :cli && drill.is_a?(Proc)
85
- @reality = Tryouts::Drill::Reality.new
90
+
91
+
86
92
  end
87
93
 
88
94
  def self.valid_dtypes; @@valid_dtypes; end
@@ -126,6 +132,11 @@ class Tryouts
126
132
  mean, sdev, sum = @reality.output.mean, @reality.output.sdev, @reality.output.sum
127
133
  out.puts '%6s%.4f (sdev:%.4f sum:%.4f)'.color(@clr) % ['', mean, sdev, sum]
128
134
  end
135
+ elsif @dtype == :cli
136
+ out.puts '%6s%s'.color(@clr) % ['', @reality.command]
137
+ output = @reality.output
138
+ output = output.join($/ + ' '*6) if output.kind_of?(Array)
139
+ out.puts '%6s%s'.color(@clr) % ['', output]
129
140
  else
130
141
  out.puts '%6s%s'.color(@clr) % ['', @reality.output.inspect]
131
142
  end
@@ -155,6 +166,8 @@ class Tryouts
155
166
  return if skip?
156
167
  out = StringIO.new
157
168
 
169
+ out.puts '%12s'.color(:red) % '[nodream]' if @dreams.empty?
170
+
158
171
  @dreams.each do |dream|
159
172
  next if dream == reality #? :normal : :red
160
173
  out.puts '%12s: %s'.color(@clr) % ["failed", dream.test_to_string(@reality)]
@@ -44,6 +44,8 @@ class Tryouts::Drill
44
44
  reality.output != dream.output
45
45
  when :respond_to?, :kind_of?, :is_a?
46
46
  reality.output.send(dream.format, dream.output)
47
+ when :grep
48
+ !reality.output.grep(dream.output).empty?
47
49
  else
48
50
 
49
51
  if dream.format.nil?
@@ -83,12 +85,10 @@ class Tryouts::Drill
83
85
  when :gt, :gte, :lt, :lte, :ne
84
86
  op = {:gt=>'>',:gte=>'>=', :lt=>'<', :lte => '<=', :ne => '!='}.find { |i| i[0] == dream.format }
85
87
  "#{reality.output.inspect} #{op[1]} #{dream.output.inspect}"
86
- when :respond_to?
87
- "#{reality.output.class}.respond_to? #{dream.output.inspect}"
88
- when :kind_of?
89
- "#{reality.output.class}.kind_of? #{dream.output.inspect}"
90
- when :is_a?
91
- "#{reality.output.class}.is_a? #{dream.output.inspect}"
88
+ when :respond_to?, :kind_of?, :is_a?
89
+ "#{reality.output.class}.#{dream.format} #{dream.output.inspect}"
90
+ when :grep
91
+ "!#{reality.output}.grep(#{dream.output.inspect}).empty?"
92
92
  else
93
93
 
94
94
  if dream.format.nil?
@@ -124,7 +124,7 @@ class Tryouts::Drill
124
124
  end
125
125
 
126
126
  def from_block(definition)
127
- instance_eval &definition
127
+ self.output = instance_eval &definition
128
128
  self
129
129
  end
130
130
 
@@ -156,6 +156,8 @@ class Tryouts::Drill
156
156
  true
157
157
  when :respond_to?, :is_a?, :kind_of?
158
158
  true
159
+ when :grep
160
+ @output
159
161
  else
160
162
  @output
161
163
  end
@@ -173,6 +175,8 @@ class Tryouts::Drill
173
175
  attr_accessor :trace
174
176
  attr_accessor :ecode
175
177
  attr_accessor :etype
178
+ # For :cli drills only. Contains the shell command string.
179
+ attr_accessor :command
176
180
  def initialize
177
181
  @stash = Tryouts::HASH_TYPE.new
178
182
  end
@@ -188,7 +192,7 @@ class Tryouts::Drill
188
192
  (test.arity > 0 ? test.call(@output) : test.call)
189
193
  when :exception
190
194
  @etype
191
- when :respond_to?, :is_a?, :kind_of?
195
+ when :respond_to?, :is_a?, :kind_of?, :grep
192
196
  @output.send(dream.format, dream.output)
193
197
  when nil
194
198
  @output
@@ -7,36 +7,43 @@ class Tryouts; class Drill; module Sergeant
7
7
  # The sergeant responsible for running command-line interface drills.
8
8
  #
9
9
  class CLI
10
-
11
- attr_reader :rbox
12
10
 
13
- # An Array of arguments to be sent to +rbox.send(*rbox_args)+
11
+ attr_accessor :rbox
12
+
13
+ # An Array of arguments to be sent to <tt>rbox.send(@command, *rbox_args)</tt>
14
14
  attr_accessor :rbox_args
15
15
 
16
+ # The command name to execute <tt>rbox.send(@command, *rbox_args)</tt>
17
+ attr_accessor :command
18
+
16
19
  def initialize(*args)
17
- require 'rye'
20
+ @command = args.shift
18
21
  @rbox_args = args
19
22
  @rbox = Rye::Box.new
20
23
  end
21
-
24
+
22
25
  # NOTE: Context is ignored for the CLI Sergeant.
23
26
  def run(block, context=nil, &inline)
24
27
  # A Proc object takes precedence over an inline block.
25
28
  runtime = (block.nil? ? inline : block)
26
29
  response = Tryouts::Drill::Reality.new
30
+
31
+ if @command.nil?
32
+ response.command = '[block]'
33
+ else
34
+ response.command = '$ ' << @rbox.preview_command(@command, *@rbox_args)
35
+ end
36
+
27
37
  begin
28
38
  if runtime.nil?
29
- ret = @rbox.send *@rbox_args
30
- else
31
- ret = @rbox.instance_eval &runtime
32
- end
33
- response.ecode = ret.exit_code
34
- if ret.stdout.size == 1
35
- response.output = ret.stdout.first
39
+ ret = @rbox.send @command, *@rbox_args
40
+ response.output = ret.stdout
41
+ response.ecode = ret.exit_code
42
+ response.error = ret.stderr unless ret.stderr.empty?
36
43
  else
37
- response.output = Array.new(ret.stdout) # Cast the Rye::Rap object
44
+ response.output = @rbox.instance_eval &runtime
38
45
  end
39
- response.error = ret.stderr unless ret.stderr.empty?
46
+
40
47
  rescue Rye::CommandNotFound => ex
41
48
  puts ex.message, ex.backtrace if Tryouts.verbose > 2
42
49
  response.etype = ex.class
@@ -128,6 +128,8 @@ class Tryouts
128
128
  # +args+ is sent directly to the Drill class. The values are specific on the Sergeant.
129
129
  def drill(dname, *args, &definition)
130
130
  raise "Empty drill name (#{@name})" if dname.nil? || dname.empty?
131
+ # The command name to run should be the first argument
132
+ args.unshift @command if @dtype == :cli
131
133
  drill = Tryouts::Drill.new(dname, @dtype, *args, &definition)
132
134
  self.add_drill drill
133
135
  end
@@ -141,11 +143,15 @@ class Tryouts
141
143
  #
142
144
  # NOTE: This method is DSL-only. It's not intended to be used in OO syntax.
143
145
  def dream(*args, &definition)
144
- if args.empty?
145
- dobj = Tryouts::Drill::Dream.from_block definition
146
- else
146
+ if definition.nil?
147
147
  args = args.size == 1 ? [args.first] : args.reverse
148
148
  dobj = Tryouts::Drill::Dream.new(*args)
149
+ else
150
+ if args.size > 1
151
+ raise "Dreams with a block can take only one argument (#{@name})"
152
+ end
153
+ dobj = Tryouts::Drill::Dream.from_block definition
154
+ dobj.format = args.first if args.size == 1
149
155
  end
150
156
  @dream_catcher.push dobj
151
157
  dobj
data/tryouts.gemspec CHANGED
@@ -1,8 +1,8 @@
1
1
  @spec = Gem::Specification.new do |s|
2
2
  s.name = "tryouts"
3
3
  s.rubyforge_project = "tryouts"
4
- s.version = "0.7.4"
5
- s.summary = "Tryouts are high-level tests for your Ruby code. May all your dreams come true!"
4
+ s.version = "0.8.0"
5
+ s.summary = "Basketball tryouts for your Ruby codes and command line apps. Go for it!"
6
6
  s.description = s.summary
7
7
  s.author = "Delano Mandelbaum"
8
8
  s.email = "tryouts@solutious.com"
@@ -17,11 +17,14 @@
17
17
  s.require_paths = %w[lib]
18
18
 
19
19
  # Specific files to include rdocs from
20
- s.extra_rdoc_files = %w[README.rdoc LICENSE.txt]
20
+ s.extra_rdoc_files = %w[README.rdoc LICENSE.txt CHANGES.txt]
21
21
 
22
22
  # Update --main to reflect the default page to display
23
23
  s.rdoc_options = ["--line-numbers", "--title", "Tryouts: #{s.summary}", "--main", "README.rdoc"]
24
24
 
25
+ ## NOTE: this is for Rudy conversion (incomplete)
26
+ ##rdoc '--line-numbers', '--title', "Tryouts: Basketball tryouts for your Ruby codes and command line apps. Go for it!", '--main', 'README.rdoc',
27
+
25
28
  # = DEPENDENCIES =
26
29
  # Add all gem dependencies
27
30
  s.add_dependency 'rye'
@@ -59,7 +62,9 @@
59
62
  tryouts.gemspec
60
63
  tryouts/01_mixins_tryouts.rb
61
64
  tryouts/10_syntax_tryouts.rb
65
+ tryouts/15_dreams_tryouts.rb
62
66
  tryouts/20_cli_tryouts.rb
67
+ tryouts/30_benchmark_tryouts.rb
63
68
  tryouts/50_class_context_tryouts.rb
64
69
  tryouts/standalone_test.rb
65
70
  )
@@ -0,0 +1,40 @@
1
+ library :tryouts, 'lib'
2
+ group "Syntax"
3
+
4
+ tryouts "Dreams" do
5
+
6
+ drill "dream inline", :muggsy do
7
+ :muggsy
8
+ end
9
+
10
+ dream :muggsy
11
+ drill "dream on top" do
12
+ :muggsy
13
+ end
14
+
15
+ dream do
16
+ :muggsy
17
+ end
18
+ drill "dream output in a block" do
19
+ :muggsy
20
+ end
21
+
22
+ dream :class do
23
+ Symbol
24
+ end
25
+ drill "dream with a format argument and a block" do
26
+ :muggsy
27
+ end
28
+
29
+ ## NOTE: The following should raise a Runtime error b/c dreams takes 1 arg
30
+ #
31
+ ##dream :class, 2 do
32
+ ## Symbol
33
+ ##end
34
+ ##drill "dream with a format argument and a block" do
35
+ ## :muggsy
36
+ ##end
37
+
38
+ xdrill "this drill will fail b/c it has no dream", :muggsy
39
+
40
+ end
@@ -2,45 +2,39 @@
2
2
  TRYOUTS_HOME = File.expand_path(File.join(File.dirname(__FILE__), ".."))
3
3
  MOCKOUT_PATH = File.join(TRYOUTS_HOME, "bin", "mockout")
4
4
 
5
- ##group "mockout cli"
6
- ##command :mockout, MOCKOUT_PATH
7
- ##dreams File.join(GYMNASIUM_HOME, 'mockoutcli_dreams.rb')
8
- ##
9
- ##tryout "Common Usage" do
10
- ## drill "No args", :info
11
- ## drill "YAML Output", :f, :yaml, :info
12
- ## drill "JSON Output", :f, :json, :info
13
- ##end
14
- ##
15
- ##tryout "inline dream that passes", :cli, :mockout do
16
- ## output = ["we expect mockout to", "echo these lines back"]
17
- ##
18
- ## # $ bin/mockout sergeant -e "we expect mockout to" "echo these lines back"
19
- ## drill "echo arguments", :info, :e, output[0], output[1]
20
- ## dream "echo arguments", output
21
- ##end
22
- ##
23
- ##tryout "inline dream that fails", :cli, :mockout do
24
- ## dream "echo arguments", "The dream does"
25
- ## drill "echo arguments", :info, :e, "not match reality"
26
- ##end
27
- ##
28
- ##
29
- ##dreams "Common Usage" do
30
- ## dream "No Comman" do
31
- ## output inline(%Q{
32
- ## Date: 2009-02-16
33
- ## Owners: greg, rupaul, telly, prince kinko
34
- ## Players: d-bam, alberta, birds, condor man
35
- ## })
36
- ## end
37
- ## dream "YAML Output" do
38
- ## format :to_yaml
39
- ## output ({
40
- ## "Date" => "2009-02-16",
41
- ## "Players" => ["d-bam", "alberta", "birds", "condor man"],
42
- ## "Owners" => ["greg", "rupaul", "telly", "prince kinko"]
43
- ## })
44
- ## end
45
- ##end
5
+ group "CLI"
6
+ command :mockout, MOCKOUT_PATH
7
+
8
+ tryout "Mockouts", :cli do
9
+
10
+ # This fails. Rye problem?
11
+ dream :class, Array
12
+ dream []
13
+ drill "No args"
14
+
15
+ dream ["One line of content"]
16
+ drill "can echo single argument", :echo, "One line of content"
17
+
18
+ dream ["Two lines", "of content"]
19
+ drill "can echo single argument with line break", :echo, "Two lines#{$/}of content"
20
+
21
+ dream :grep, /UTC/
22
+ drill "can display date", :date
23
+
24
+ dream []
25
+ drill "can be quiet", :q, :test
26
+
27
+ dream ["PASS"]
28
+ drill "can execute via a block" do
29
+ mockout :test, :p
30
+ end
31
+
32
+ dream :match, /\d+\.\d+\.\d+\.\d+/
33
+ drill "can execute a block of commands" do
34
+ ret = rudy :q, :myaddress, :e
35
+ ret.first
36
+ end
37
+
38
+ end
39
+
46
40
 
@@ -0,0 +1,28 @@
1
+
2
+
3
+ group "Benchmarks"
4
+
5
+ tryouts "Benchmark Syntax", :benchmark do
6
+
7
+ drill "can check the mean is <=", :mean, 4 do
8
+ sleep 0.1
9
+ end
10
+
11
+ drill "can check the standard deviation", :sdev, 0.1 do
12
+ sleep 0.1
13
+ end
14
+
15
+ drill "Tryouts::Stat objects have a default name", :name, :unknown do
16
+ sleep 0.1
17
+ end
18
+
19
+ dream :samples, 5
20
+ drill "default repetitions is 5" do
21
+ sleep 0.1
22
+ end
23
+
24
+ dream :proc, lambda { |x| x.sum >= 0.5 }
25
+ drill "can specify dream proc" do
26
+ sleep 0.1
27
+ end
28
+ end
@@ -8,12 +8,16 @@ tryout "Setting class variables", :api do
8
8
  @from_setup = true
9
9
  end
10
10
 
11
- drill "can't access class var created in setup (1.9 only)", :exception, NameError do
12
- @@from_setup
11
+ if Tryouts.sysinfo.ruby[1] == 9
12
+ drill "can't access class var created in setup (1.9 only)", :exception, NameError do
13
+ @@from_setup
14
+ end
13
15
  end
14
16
 
15
- drill "can access class var created in setup (1.8 only)", 'Olivia' do
16
- @@from_setup.class.to_s
17
+ if Tryouts.sysinfo.ruby[1] == 8
18
+ drill "can access class var created in setup (1.8 only)", 'Olivia' do
19
+ @@from_setup.class.to_s
20
+ end
17
21
  end
18
22
 
19
23
  drill "create class var", 'Olivia' do
@@ -7,6 +7,8 @@
7
7
  #
8
8
  # Usage: ruby tryouts/standalone_test.rb
9
9
  #
10
+
11
+ ## NOTE: BROKEN SINCE 0.6
10
12
 
11
13
  TRYOUTS_HOME = File.expand_path(File.join(File.dirname(__FILE__), '..'))
12
14
  TRYOUTS_LIB = File.join(TRYOUTS_HOME, 'lib')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: delano-tryouts
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.4
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Delano Mandelbaum
@@ -42,7 +42,7 @@ dependencies:
42
42
  - !ruby/object:Gem::Version
43
43
  version: "0"
44
44
  version:
45
- description: Tryouts are high-level tests for your Ruby code. May all your dreams come true!
45
+ description: Basketball tryouts for your Ruby codes and command line apps. Go for it!
46
46
  email: tryouts@solutious.com
47
47
  executables:
48
48
  - sergeant
@@ -51,6 +51,7 @@ extensions: []
51
51
  extra_rdoc_files:
52
52
  - README.rdoc
53
53
  - LICENSE.txt
54
+ - CHANGES.txt
54
55
  files:
55
56
  - CHANGES.txt
56
57
  - LICENSE.txt
@@ -76,7 +77,9 @@ files:
76
77
  - tryouts.gemspec
77
78
  - tryouts/01_mixins_tryouts.rb
78
79
  - tryouts/10_syntax_tryouts.rb
80
+ - tryouts/15_dreams_tryouts.rb
79
81
  - tryouts/20_cli_tryouts.rb
82
+ - tryouts/30_benchmark_tryouts.rb
80
83
  - tryouts/50_class_context_tryouts.rb
81
84
  - tryouts/standalone_test.rb
82
85
  has_rdoc: true
@@ -85,7 +88,7 @@ post_install_message:
85
88
  rdoc_options:
86
89
  - --line-numbers
87
90
  - --title
88
- - "Tryouts: Tryouts are high-level tests for your Ruby code. May all your dreams come true!"
91
+ - "Tryouts: Basketball tryouts for your Ruby codes and command line apps. Go for it!"
89
92
  - --main
90
93
  - README.rdoc
91
94
  require_paths:
@@ -108,6 +111,6 @@ rubyforge_project: tryouts
108
111
  rubygems_version: 1.2.0
109
112
  signing_key:
110
113
  specification_version: 2
111
- summary: Tryouts are high-level tests for your Ruby code. May all your dreams come true!
114
+ summary: Basketball tryouts for your Ruby codes and command line apps. Go for it!
112
115
  test_files: []
113
116