tryouts 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES.txt CHANGED
@@ -1,5 +1,10 @@
1
1
  TRYOUTS, CHANGES
2
2
 
3
+ #### 0.5.1 (2009-06-13) ###############################
4
+
5
+ * ADDED: dream method is now available inside drill block
6
+ * ADDED: Drills that return true are assumed to pass
7
+
3
8
 
4
9
  #### 0.5.0 (2009-06-07) ###############################
5
10
 
@@ -13,7 +18,7 @@ TRYOUTS, CHANGES
13
18
 
14
19
  #### 0.4.1 (2009-06-07) ###############################
15
20
 
16
- * CHANGE: The CLI output is no longer terrifyingly ugly.
21
+ * CHANGE: The CLI output is no longer terrifyingly ugly
17
22
 
18
23
 
19
24
  #### 0.4.0 (2009-06-05) ###############################
data/README.rdoc CHANGED
@@ -1,4 +1,4 @@
1
- = Tryouts - v0.4 BETA
1
+ = Tryouts - v0.5 BETA
2
2
 
3
3
  Tryouts is a high-level testing library for your command-line applications and Ruby codes.
4
4
 
data/Rakefile CHANGED
@@ -74,7 +74,7 @@ Rake::RDocTask.new do |t|
74
74
  t.rdoc_files.include(LICENSE)
75
75
  t.rdoc_files.include(README)
76
76
  t.rdoc_files.include(CHANGES)
77
- t.rdoc_files.include('bin/tryouts')
77
+ t.rdoc_files.include('bin/sergeant')
78
78
  t.rdoc_files.include('lib/**/*.rb')
79
79
  end
80
80
 
data/bin/sergeant CHANGED
@@ -19,6 +19,10 @@ module TryoutsCLI
19
19
  default :run, :with_args
20
20
 
21
21
  global :q, :quiet, "Decrease output"
22
+ global :V, :version, "Display version number" do
23
+ puts "Tryouts version: #{Tryouts::VERSION}"
24
+ exit 0
25
+ end
22
26
  global :v, :verbose, "Increase output" do
23
27
  @verbose ||= 0
24
28
  @verbose += 1
@@ -146,26 +146,26 @@ class Tryouts::CLI::Run
146
146
  `-=;_-' `-----' `-_;=-' -bodom-
147
147
  }
148
148
  PUG = %q{
149
- __,-----._ ,-.
150
- ,' ,-. \`---. ,-----<._/
151
- (,.-. o:.` )),"\\\-._ ,' `.
152
- ('"-` .\ \`:_ )\ `-;'-._ \
153
- ,,-. \` ; : \( `-' ) -._ : `:
154
- ( \ `._\\\ ` ; ; ` : )
155
- \`. `-. __ , / \ ;, (
156
- `.`-.___--' `- / ; | : |
157
- `-' `-.`--._ ' ; |
158
- (`--._`. ; /\ |
159
- \ ' \ , ) :
160
- | `--::---- \' ; ;|
161
- \ .__,- ( ) : :|
162
- \ : `------; \ | | ;
163
- \ : / , ) | | (
164
- \ \ `-^-| | / , ,\
165
- ) ) | -^- ; `-^-^'
166
- _,' _ ; | |
167
- / , , ,' /---. :
168
- `-^-^' ( : :,'
169
- `-^--' -hrr-
149
+ __,-----._ ,-.
150
+ ,' ,-. \`---. ,-----<._/
151
+ (,.-. o:.` )),"\\\-._ ,' `.
152
+ ('"-` .\ \`:_ )\ `-;'-._ \
153
+ ,,-. \` ; : \( `-' ) -._ : `:
154
+ ( \ `._\\\ ` ; ; ` : )
155
+ \`. `-. __ , / \ ;, (
156
+ `.`-.___--' `- / ; | : |
157
+ `-' `-.`--._ ' ; |
158
+ (`--._`. ; /\ |
159
+ \ ' \ , ) :
160
+ | `--::---- \' ; ;|
161
+ \ .__,- ( ) : :|
162
+ \ : `------; \ | | ;
163
+ \ : / , ) | | (
164
+ \ \ `-^-| | / , ,\
165
+ ) ) | -^- ; `-^-^'
166
+ _,' _ ; | |
167
+ / , , ,' /---. :
168
+ `-^-^' ( : :,'
169
+ `-^--' -hrr-
170
170
  }
171
171
  end
data/lib/tryouts/drill.rb CHANGED
@@ -48,11 +48,25 @@ class Tryouts
48
48
  end
49
49
 
50
50
  def run(context=nil)
51
- return false if @dream.nil?
52
51
  begin
53
52
  print Tryouts::DRILL_MSG % @name
54
53
  @reality = @sergeant.run @drill, context
54
+ # Store the stash from the drill block
55
55
  @reality.stash = context.stash if context.respond_to? :stash
56
+ # Create or overwrite an existing dream if onw was defined in the block
57
+ if context.respond_to?(:dream) && context.has_dream?
58
+ @dream = Tryouts::Drill::Dream.new
59
+ @dream.output = context.dream
60
+ @dream.format = context.format unless context.format.nil?
61
+ @dream.rcode = context.rcode unless context.rcode.nil?
62
+ @dream.emsg = context.emsg unless context.emsg.nil?
63
+ end
64
+
65
+ # If the drill block returned true we assume success if there's no dream
66
+ if @dream.nil? && @reality.output == true
67
+ @dream = Tryouts::Drill::Dream.new
68
+ @dream.output = true
69
+ end
56
70
  process_reality
57
71
  rescue => ex
58
72
  @reality.rcode = -2
@@ -36,8 +36,19 @@ class Tryouts
36
36
  # The before and after blocks are also run in this context.
37
37
  class DrillContext
38
38
  # An ordered Hash of stashed objects.
39
- attr_reader :stash
40
- def initialize; @stash = Tryouts::HASH_TYPE.new; end
39
+ attr_writer :stash
40
+ # A value used as the dream output that will overwrite a predefined dream
41
+ attr_writer :dream
42
+ attr_writer :format
43
+ attr_writer :rcode
44
+ attr_writer :emsg
45
+ attr_writer :output
46
+
47
+ def initialize; @stash = Tryouts::HASH_TYPE.new; @has_dream = false; end
48
+
49
+ # Set to to true by DrillContext#dream
50
+ def has_dream?; @has_dream; end
51
+
41
52
  # If called with no arguments, returns +@stash+.
42
53
  # If called with arguments, it will add a new value to the +@stash+
43
54
  # and return the new value. e.g.
@@ -45,13 +56,37 @@ class Tryouts
45
56
  # stash :name, 'some value' # => 'some value'
46
57
  #
47
58
  def stash(*args)
48
- if args.empty?
49
- @stash
50
- else
51
- @stash[args[0]] = args[1]
52
- args[1]
53
- end
59
+ return @stash if args.empty?
60
+ @stash[args[0]] = args[1]
61
+ args[1]
62
+ end
63
+
64
+ # If called with no arguments, returns +@dream+.
65
+ # If called with one argument, it will overwrite +@dream+ with the
66
+ # first element. If called with two arguments, it will check if
67
+ # the second argument is a Symbol or Fixnum. If it's a Symbol it
68
+ # will assume it's +@format+. If it's a Fixnum, it will assume
69
+ # it's +@rcode+. If there's a there's a third argument and it's a
70
+ # Fixnum, it's assumed to be +@rcode+. In all cases, this method
71
+ # returns the value of +@dream+. e.g.
72
+ #
73
+ # dream 'some value' # => 'some value'
74
+ # dream :val1, :class, 1 # => :val1
75
+ #
76
+ def dream(*args)
77
+ return @dream if args.empty?
78
+ @has_dream = true
79
+ @dream = args.shift
80
+ @format = args.shift if args.first.is_a? Symbol
81
+ @rcode = args.shift if args.first.is_a? Fixnum
82
+ @emsg = args.shift if args.first.is_a? String
54
83
  end
84
+
85
+ def output(*args); return @output if args.empty?; @output = args.first; end
86
+ def format(*args); return @format if args.empty?; @format = args.first; end
87
+ def rcode(*args); return @rcode if args.empty?; @rcode = args.first; end
88
+ def emsg(*args); return @emsg if args.empty?; @emsg = args.first; end
89
+
55
90
  end
56
91
 
57
92
  def initialize(name, dtype, command=nil, *args)
@@ -108,7 +143,8 @@ class Tryouts
108
143
  puts drill.reality.backtrace, $/
109
144
  end
110
145
  else
111
- puts '%24s' % ["[nodream]"]
146
+ puts '%24s: %s' % ["expected output", "[nodream]"]
147
+ puts '%24s: %s' % ["actual output", drill.reality.output.inspect]
112
148
  end
113
149
 
114
150
  end
data/lib/tryouts.rb CHANGED
@@ -1,5 +1,4 @@
1
1
 
2
- require 'rubygems'
3
2
  require 'ostruct'
4
3
  require 'rye'
5
4
  require 'yaml'
@@ -30,7 +29,7 @@ class Tryouts
30
29
  # Raised when there is a problem loading or parsing a Tryouts::Drill::Dream object
31
30
  class BadDreams < Exception; end
32
31
 
33
- VERSION = "0.5.0"
32
+ VERSION = "0.5.1"
34
33
 
35
34
  require 'tryouts/mixins'
36
35
  require 'tryouts/tryout'
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.5.0
4
+ version: 0.5.1
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: 2009-06-08 00:00:00 -04:00
12
+ date: 2009-06-13 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency