delano-tryouts 0.8.3 → 0.8.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,11 +1,19 @@
1
1
  TRYOUTS, CHANGES
2
2
 
3
3
 
4
+ #### 0.8.4 (2009-07-20) ###############################
5
+
6
+ * CHANGE: "setup" and "clean" blocks now run in the same DrillContext
7
+ instance as drills (so instance variables are now shared)
8
+ * CHANGE: Non-fatal errors are now displayed only in verbose mode.
9
+ * ADDED: "set" keyword inside tryout definitions.
10
+ * ADDED: New dependency: attic
11
+
12
+
4
13
  #### 0.8.3 (2009-07-19) ###############################
5
14
 
6
15
  * FIXED: Updated gemspec
7
16
 
8
-
9
17
  #### 0.8.2 (2009-07-19) ###############################
10
18
 
11
19
  * CHANGE: Moved Drill and Reality to separate files.
@@ -32,37 +32,51 @@ The examples below are a complete overview of Tryouts syntax.
32
32
  library :gibbler, "../path/to/gibbler/lib"
33
33
 
34
34
  tryouts "Common Usage", :api do
35
-
35
+
36
+ # Define variables available only within
37
+ # in the current tryout definition.
38
+ set :local_variable, 3
39
+
40
+ setup do
41
+ # do stuff before all drills
42
+ end
43
+
44
+ clean do
45
+ # do stuff after all drills
46
+ end
47
+
36
48
  # This drill block should return 3.
37
- drill "Maths R Us", 3 do
49
+ drill "Maths R Us", local_variable do
38
50
  12 / 4
39
51
  end
40
-
52
+
41
53
  # You can specify a method to execute
42
- # on the return value of the drill block.
54
+ # on the return value of the drill block.
43
55
  drill "We want a symbol", :class, Symbol do
44
- orange.methods.first
56
+ Class.methods.first
45
57
  end
46
-
58
+
47
59
  # Dreams can also be specified explicitly which is
48
60
  # important b/c it's possible to specify multiple.
49
61
  dream :class, Array
50
- dream [:a, :b, :c]
62
+ dream ['b', 'c', 'd']
51
63
  drill "Should return a list of 3" do
52
- Letters.list(3)
64
+ letters = 'a'..'z'
65
+ letters.to_a[1..local_variable]
53
66
  end
54
-
67
+
55
68
  # Drills can pass based on an exception too.
56
69
  dream :exception, NameError
57
70
  drill "Something failed" do
58
71
  raise NameError
59
72
  end
60
-
61
- # We can even put simple drills on a single line.
73
+
74
+ # We can even put simple drills on a single line.
62
75
  drill 'Small, fast, and furious', 'Muggsy Bogues', :match, /Mug+sy Bogu?es/
63
-
76
+
64
77
  end
65
78
 
79
+
66
80
  === Testing Command-Line Applications (:cli)
67
81
 
68
82
  You can execute drills on command-line applications.
@@ -187,19 +201,14 @@ http://delano.github.com/tryouts/screens/tryouts-0.8-benchmark.png
187
201
 
188
202
  == News
189
203
 
190
- === 2009-07-01: Drills for command-line applications
191
-
192
- Support for testing command-line applications has been re-introduced in 0.8. See example code further down in this README.
204
+ === 2009-07-20: New DSL keyword "set"
193
205
 
194
- === 2009-06-26: DSL Syntax Change
206
+ The "set" keyword has been introduced in 0.8.4 for defining variables available only to the Tryout definition they were declared in. See Example 1.
195
207
 
196
- The order of dream arguments has reversed between 0.7.1 and 0.7.2. It is now:
197
-
198
- * <tt>dream :method, 'Expected value'</tt>
208
+ === 2009-07-01: Drills for command-line applications
199
209
 
200
- 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:
210
+ Support for testing command-line applications has been re-introduced in 0.8. See example code further down in this README.
201
211
 
202
- * <tt>drill 'test name', 'return value', :class, String</tt>
203
212
 
204
213
 
205
214
  == BETA Notice
@@ -3,8 +3,7 @@
3
3
  TRYOUTS_HOME = File.expand_path(File.join(File.dirname(__FILE__), '..'))
4
4
 
5
5
  $:.unshift File.join(TRYOUTS_HOME, 'lib')
6
-
7
- local_libs = %w{tryouts net-scp amazon-ec2 aws-s3 caesars drydock rye storable sysinfo annoy}
6
+ local_libs = %w{tryouts drydock rye storable sysinfo attic}
8
7
  local_libs.each { |dir| $:.unshift File.join(TRYOUTS_HOME, '..', dir, 'lib') }
9
8
 
10
9
  require 'drydock'
@@ -1,5 +1,6 @@
1
1
 
2
2
  require 'time'
3
+ require 'attic'
3
4
  require 'sysinfo'
4
5
  require 'digest/sha1'
5
6
  require 'ostruct'
@@ -45,7 +46,7 @@ class Tryouts
45
46
  end
46
47
  end
47
48
 
48
- VERSION = "0.8.3"
49
+ VERSION = "0.8.4"
49
50
 
50
51
  require 'tryouts/mixins'
51
52
  require 'tryouts/tryout'
@@ -30,13 +30,16 @@ class Tryouts
30
30
  # A Hash of Dream objects for this Tryout. The keys are drill names.
31
31
  attr_reader :dream_catcher
32
32
 
33
+ # The instance of Drill::Context in which the drills will run in.
34
+ attr_reader :drill_context
33
35
 
34
36
  def initialize(name, dtype, command=nil, *args)
35
37
  raise "Must supply command for dtype :cli" if dtype == :cli && command.nil?
36
38
  raise "#{dtype} is not a valid drill type" if !Drill.valid_dtype?(dtype)
37
39
  @name, @dtype, @command = name, dtype, command
38
- @drills, @dream_catcher = [], []
40
+ @drills, @dream_catcher, @locals = [], [], {}
39
41
  @passed, @failed, @skipped = 0, 0, 0
42
+ @drill_context = DrillContext.new
40
43
  end
41
44
 
42
45
  ## --------------------------------------- EXTERNAL API -----
@@ -54,11 +57,11 @@ class Tryouts
54
57
 
55
58
  # Execute all Drill objects
56
59
  def run
57
- DrillContext.module_eval &setup if setup.is_a?(Proc)
60
+ @drill_context.instance_eval &setup if setup.is_a?(Proc)
58
61
  puts "\n %s ".bright % @name unless Tryouts.verbose < 0
59
62
  @drills.each do |drill|
60
63
  print ' %-69s ' % "\"#{drill.name}\"" unless Tryouts.verbose < 0
61
- drill.run DrillContext.new
64
+ drill.run @drill_context
62
65
  if drill.skip?
63
66
  @skipped += 1
64
67
  elsif drill.success?
@@ -69,7 +72,7 @@ class Tryouts
69
72
  puts drill.flag # PASS, FAIL, SKIP
70
73
  puts drill.info if Tryouts.verbose > 0 && !drill.skip?
71
74
  end
72
- DrillContext.module_eval &clean if clean.is_a?(Proc)
75
+ @drill_context.instance_eval &clean if clean.is_a?(Proc)
73
76
  end
74
77
 
75
78
  # Prints error output. If there are no errors, it prints nothing.
@@ -81,13 +84,15 @@ class Tryouts
81
84
  puts $/, ' ' << title.color(:red).att(:reverse)
82
85
  puts drill.report
83
86
  end
84
- # Print errors for successful runs too
85
- success = @drills.select { |d| !d.skip? && d.success? }
86
- success.each do |drill,index|
87
- next unless drill.has_error?
88
- title = ' Non-fatal error in: %-69s ' % ["\"#{drill.name}\""]
89
- puts $/, ' ' << title.color(:red)
90
- puts drill.report
87
+ if Tryouts.verbose > 0
88
+ # Print errors for successful runs too
89
+ success = @drills.select { |d| !d.skip? && d.success? }
90
+ success.each do |drill,index|
91
+ next unless drill.has_error?
92
+ title = ' Non-fatal error in: %-69s ' % ["\"#{drill.name}\""]
93
+ puts $/, ' ' << title.color(:red)
94
+ puts drill.report
95
+ end
91
96
  end
92
97
  end
93
98
 
@@ -109,7 +114,16 @@ class Tryouts
109
114
  d
110
115
  end
111
116
 
112
- ## --------------------------------------- EXTERNAL DSL -----
117
+ ## ------------------------------------------------ DSL -----
118
+
119
+ # Define a method named +key+ for only the current instances of
120
+ # Tryout and DrillContext so it's not available anywhere else.
121
+ # The methods return +value+.
122
+ def set(key, value)
123
+ self.meta_def( key ) { value }
124
+ @drill_context.meta_def( key ) { value }
125
+ value
126
+ end
113
127
 
114
128
  # A block to executed one time _before_ starting the drills
115
129
  def setup(&block)
@@ -1,7 +1,7 @@
1
1
  @spec = Gem::Specification.new do |s|
2
2
  s.name = "tryouts"
3
3
  s.rubyforge_project = "tryouts"
4
- s.version = "0.8.3"
4
+ s.version = "0.8.4"
5
5
  s.summary = "Tryouts is a high-level testing library (DSL) for your Ruby codes and command-line applications."
6
6
  s.description = s.summary
7
7
  s.author = "Delano Mandelbaum"
@@ -28,6 +28,7 @@
28
28
  # = DEPENDENCIES =
29
29
  # Add all gem dependencies
30
30
  s.add_dependency 'rye'
31
+ s.add_dependency 'attic'
31
32
  s.add_dependency 'drydock'
32
33
  s.add_dependency 'sysinfo'
33
34
 
@@ -64,6 +65,7 @@
64
65
  tryouts.gemspec
65
66
  tryouts/01_mixins_tryouts.rb
66
67
  tryouts/10_syntax_tryouts.rb
68
+ tryouts/14_set_tryouts.rb
67
69
  tryouts/15_dreams_tryouts.rb
68
70
  tryouts/20_cli_tryouts.rb
69
71
  tryouts/30_benchmark_tryouts.rb
@@ -0,0 +1,26 @@
1
+ library :tryouts, 'lib'
2
+ group "Syntax"
3
+
4
+ tryouts "Set (initial)" do
5
+ set :key1, 9000
6
+ drill "set values are available outside drill/dream blocks", key1 do
7
+ 9000
8
+ end
9
+ drill "set values are available inside drill/dream blocks", 9000 do
10
+ key1
11
+ end
12
+ end
13
+
14
+ tryouts "Set (double check)" do
15
+
16
+ dream :exception, NameError
17
+ drill "set values are not available from other tryouts inside blocks" do
18
+ key1
19
+ end
20
+
21
+ ## NOTE: This drill will create a runtime error b/c key1 isn't defined here.
22
+ ## dream key1
23
+ ## drill "set values are not available from other tryouts outside blocks" do
24
+ ## end
25
+
26
+ end
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.8.3
4
+ version: 0.8.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Delano Mandelbaum
@@ -22,6 +22,16 @@ dependencies:
22
22
  - !ruby/object:Gem::Version
23
23
  version: "0"
24
24
  version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: attic
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:
25
35
  - !ruby/object:Gem::Dependency
26
36
  name: drydock
27
37
  type: :runtime
@@ -79,6 +89,7 @@ files:
79
89
  - tryouts.gemspec
80
90
  - tryouts/01_mixins_tryouts.rb
81
91
  - tryouts/10_syntax_tryouts.rb
92
+ - tryouts/14_set_tryouts.rb
82
93
  - tryouts/15_dreams_tryouts.rb
83
94
  - tryouts/20_cli_tryouts.rb
84
95
  - tryouts/30_benchmark_tryouts.rb