tryouts 0.8.7 → 0.8.8

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/CHANGES.txt CHANGED
@@ -11,6 +11,12 @@ TRYOUTS, CHANGES
11
11
  * TODO: Clear stash between drills
12
12
 
13
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
+
14
20
  #### 0.8.7 (2010-02-15) ###############################
15
21
 
16
22
  * CHANGE: Removed hanna dependency
@@ -1,2 +1,37 @@
1
1
 
2
- require "tryouts/mixins/hash"
2
+ class Hash
3
+
4
+ # A depth-first look to find the deepest point in the Hash.
5
+ # The top level Hash is counted in the total so the final
6
+ # number is the depth of its children + 1. An example:
7
+ #
8
+ # ahash = { :level1 => { :level2 => {} } }
9
+ # ahash.deepest_point # => 3
10
+ #
11
+ def deepest_point(h=self, steps=0)
12
+ if h.is_a?(Hash)
13
+ steps += 1
14
+ h.each_pair do |n,possible_h|
15
+ ret = deepest_point(possible_h, steps)
16
+ steps = ret if steps < ret
17
+ end
18
+ else
19
+ return 0
20
+ end
21
+ steps
22
+ end
23
+
24
+ unless method_defined?(:last)
25
+ # Ruby 1.9 doesn't have a Hash#last (but Tryouts::OrderedHash does).
26
+ # It's used in Tryouts to return the most recently added instance of
27
+ # Tryouts to @@instances.
28
+ #
29
+ # NOTE: This method is defined only when Hash.method_defined?(:last)
30
+ # returns false.
31
+ def last
32
+ self[ self.keys.last ]
33
+ end
34
+ end
35
+
36
+ end
37
+
data/lib/tryouts.rb CHANGED
@@ -2,9 +2,9 @@
2
2
  require 'time'
3
3
  require 'digest/sha1'
4
4
 
5
- autoload :SysInfo, 'sysinfo'
6
- autoload :OpenStruct, 'ostruct'
7
- autoload :YAML, 'yaml'
5
+ require 'attic'
6
+ require 'sysinfo'
7
+ require 'yaml'
8
8
 
9
9
  ## NOTE: Don't require rye here so
10
10
  ## we can still run tryouts on the
@@ -46,7 +46,7 @@ class Tryouts
46
46
  end
47
47
  end
48
48
 
49
- VERSION = "0.8.7"
49
+ VERSION = "0.8.8"
50
50
 
51
51
  require 'tryouts/mixins'
52
52
  require 'tryouts/tryout'
@@ -0,0 +1,78 @@
1
+ ## Tryouts 0.8
2
+
3
+ library :rudy, 'path/2/rudy/lib'
4
+ tryouts "Code", :api do
5
+
6
+ setup do
7
+ end
8
+
9
+
10
+ dream :class, Rudy::Disk
11
+ dream :size, 1
12
+ dream :device, '/dev/sdh'
13
+ dream :path, '/'
14
+ drill "has a default size and device" do
15
+ Rudy::Disk.new('/')
16
+ end
17
+
18
+ drill "save disk metadata", true do
19
+ Rudy::Disk.new('/any/path').save
20
+ end
21
+
22
+ dream :exception, Rudy::Metadata::DuplicateRecord
23
+ drill "won't save over a disk with the same name" do
24
+ Rudy::Disk.new('/any/path').save
25
+ end
26
+
27
+ set :group_name, "grp-9000"
28
+ dream :class, Rudy::AWS::EC2::Group
29
+ dream :proc, lambda { |group|
30
+ accountnum = Rudy::Huxtable.config.accounts.aws.accountnum
31
+ should_have = "#{accountnum}:#{group_name}"
32
+ return false unless group.groups.is_a?(Hash)
33
+ group.groups.has_key?(should_have) == true
34
+ }
35
+ drill "group (#{group_name}) contains new rules" do
36
+ stash :group, Rudy::AWS::EC2::Groups.get(group_name)
37
+ end
38
+ end
39
+
40
+
41
+
42
+
43
+
44
+
45
+
46
+
47
+ # "has a default size and device"
48
+ Rudy::Disk.new '/' # <Rudy::Disk>
49
+ #=> # obj.size == 1
50
+ # obj.device == '/dev/sdh'
51
+ # obj.path == '/'
52
+
53
+ # "save disk metadata"
54
+ Rudy::Disk.new('/any/path').save # true
55
+
56
+ # "won't save over a disk with the same name"
57
+ Rudy::Disk.new('/any/path').save # ! <Rudy::Metadata::DuplicateRecord>
58
+
59
+ # "group contains new rules"
60
+ group_name = "grp-9000"
61
+ accountnum = Rudy::Huxtable.config.accounts.aws.accountnum
62
+ obj = Rudy::AWS::EC2::Groups.get(group_name)
63
+ obj.class #=> Rudy::AWS::EC2::Group
64
+ obj.groups.has_key?("#{accountnum}:#{group_name}") #=> true
65
+ obj.device #=> '/dev/sdh'
66
+
67
+ ### Context b ###
68
+
69
+ obj.path #=> '/'
70
+
71
+
72
+ Foo::bar() #=> "asdf"
73
+
74
+ result = Foo::bar()
75
+ result #=> "asdf"
76
+
77
+ # work with:
78
+ # $ ruby -rubygems -Ilib ...
@@ -0,0 +1,36 @@
1
+ ## Tryouts 0.8
2
+
3
+ command :script, '/path/2/script'
4
+
5
+ tryouts "CLI", :cli do
6
+ dream :grep, /UTC/
7
+ drill "can display date", :date
8
+
9
+ dream []
10
+ drill "can be quiet", :q, :test
11
+
12
+ dream :match, /\d+\.\d+\.\d+\.\d+/
13
+ drill "can execute a block of commands" do
14
+ ret = rudy :q, :myaddress, :e
15
+ ret.first
16
+ end
17
+ end
18
+
19
+ ## Comment-style
20
+
21
+ command :script, '/path/2/script'
22
+ tryouts "CLI", :cli do
23
+
24
+ # "can display date"
25
+ script :date # stdout.grep /UTC/
26
+ # stderr.empty? == true
27
+
28
+ # "can be quiet"
29
+ script :q, :test # stdout.empty? == true
30
+
31
+ # "can execute a block of commands"
32
+ ls :a, '/tmp'
33
+ script :q, :myaddress, :e # stdout.first.match /\d+\.\d+\.\d+\.\d+/
34
+
35
+ end
36
+
data/tryouts.gemspec CHANGED
@@ -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.7"
4
+ s.version = "0.8.8"
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"
@@ -57,7 +57,6 @@
57
57
  lib/tryouts/drill/sergeant/cli.rb
58
58
  lib/tryouts/drill/sergeant/rbenchmark.rb
59
59
  lib/tryouts/mixins.rb
60
- lib/tryouts/mixins/hash.rb
61
60
  lib/tryouts/orderedhash.rb
62
61
  lib/tryouts/stats.rb
63
62
  lib/tryouts/tryout.rb
@@ -69,6 +68,8 @@
69
68
  tryouts/20_cli_tryouts.rb
70
69
  tryouts/30_benchmark_tryouts.rb
71
70
  tryouts/50_class_context_tryouts.rb
71
+ tryouts/X1_new_api_syntax.rb
72
+ tryouts/X2_new_cli_syntax.rb
72
73
  tryouts/standalone_test.rb
73
74
  )
74
75
 
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.7
4
+ version: 0.8.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Delano Mandelbaum
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-02-15 00:00:00 -05:00
12
+ date: 2010-02-20 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -72,7 +72,6 @@ files:
72
72
  - lib/tryouts/drill/sergeant/cli.rb
73
73
  - lib/tryouts/drill/sergeant/rbenchmark.rb
74
74
  - lib/tryouts/mixins.rb
75
- - lib/tryouts/mixins/hash.rb
76
75
  - lib/tryouts/orderedhash.rb
77
76
  - lib/tryouts/stats.rb
78
77
  - lib/tryouts/tryout.rb
@@ -84,6 +83,8 @@ files:
84
83
  - tryouts/20_cli_tryouts.rb
85
84
  - tryouts/30_benchmark_tryouts.rb
86
85
  - tryouts/50_class_context_tryouts.rb
86
+ - tryouts/X1_new_api_syntax.rb
87
+ - tryouts/X2_new_cli_syntax.rb
87
88
  - tryouts/standalone_test.rb
88
89
  has_rdoc: true
89
90
  homepage: http://github.com/delano/tryouts
@@ -1,37 +0,0 @@
1
-
2
- class Hash
3
-
4
- # A depth-first look to find the deepest point in the Hash.
5
- # The top level Hash is counted in the total so the final
6
- # number is the depth of its children + 1. An example:
7
- #
8
- # ahash = { :level1 => { :level2 => {} } }
9
- # ahash.deepest_point # => 3
10
- #
11
- def deepest_point(h=self, steps=0)
12
- if h.is_a?(Hash)
13
- steps += 1
14
- h.each_pair do |n,possible_h|
15
- ret = deepest_point(possible_h, steps)
16
- steps = ret if steps < ret
17
- end
18
- else
19
- return 0
20
- end
21
- steps
22
- end
23
-
24
- unless method_defined?(:last)
25
- # Ruby 1.9 doesn't have a Hash#last (but Tryouts::OrderedHash does).
26
- # It's used in Tryouts to return the most recently added instance of
27
- # Tryouts to @@instances.
28
- #
29
- # NOTE: This method is defined only when Hash.method_defined?(:last)
30
- # returns false.
31
- def last
32
- self[ self.keys.last ]
33
- end
34
- end
35
-
36
- end
37
-