quarry 0.5.0 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -17,3 +17,7 @@ BEGIN {
17
17
  end
18
18
  }
19
19
 
20
+
21
+ def p(*args)
22
+ super *(args << caller[0])
23
+ end
@@ -24,43 +24,65 @@ module Quarry
24
24
  @error = []
25
25
  end
26
26
 
27
+ # Before running any specifications.
27
28
  def report_intro
28
29
  end
29
30
 
31
+ # Beginning of a specification.
30
32
  def report_start(spec)
31
33
  @specs += 1
32
34
  end
33
35
 
36
+ # Report a header.
34
37
  def report_header(step)
35
38
  end
36
39
 
40
+ # Report a comment.
37
41
  def report_comment(step)
38
42
  end
39
43
 
40
- def report_mode(step)
41
- report_literal(step)
42
- end
44
+ # Er... what was this for?
45
+ #def report_mode(step)
46
+ # report_literal(step)
47
+ #end
43
48
 
49
+ # Before running a step.
44
50
  def report_step(step)
45
51
  @steps += 1
46
52
  end
47
53
 
54
+ # Report step passed.
48
55
  def report_pass(step)
49
56
  @pass << step
50
57
  end
51
58
 
59
+ # Report step failed.
52
60
  def report_fail(step, assertion)
53
61
  @fail << [step, assertion]
54
62
  end
55
63
 
64
+ # Report step raised an error.
56
65
  def report_error(step, exception)
57
66
  raise exception if $DEBUG
58
67
  @error << [step, exception]
59
68
  end
60
69
 
70
+ # Since regular macro step does not pass or fail,
71
+ # this method is used instead.
72
+ #
73
+ # TODO: Rename to #report_nominal (?)
74
+ def report_macro(step)
75
+ end
76
+
77
+ # After running a step.
78
+ def report_step_end(step)
79
+ end
80
+
81
+ # End of a specification.
61
82
  def report_end(spec)
62
83
  end
63
84
 
85
+ # After running all specifications.
64
86
  def report_summary
65
87
  end
66
88
 
@@ -7,21 +7,23 @@ module Quarry
7
7
  #
8
8
  class DotProgress < Reporter
9
9
 
10
+ #
10
11
  def report_intro
11
12
  @start_time = Time.now
12
13
  puts "Started"
13
14
  end
14
15
 
16
+ #
15
17
  def report_step(step)
16
18
  super
17
- if step.code
19
+ #if step.code
18
20
  print "."
19
21
  #str = "(%s) %s" % [count.join('.'), str.tab(6).strip]
20
22
  #puts "* #{step.text.tab(2).strip}"
21
23
  #puts "\n#{step.code}\n" if $VERBOSE
22
- else
24
+ #else
23
25
  #puts "\n#{step.text}"
24
- end
26
+ #end
25
27
  end
26
28
 
27
29
  #def report(str)
@@ -12,25 +12,25 @@ module Quarry
12
12
  class Summary < Reporter
13
13
 
14
14
  def report_header(step)
15
- puts ANSICode.bold(step.text)
15
+ puts ANSICode.bold("#{step}")
16
16
  end
17
17
 
18
18
  def report_comment(step)
19
- txt = step.text.tabto(2)
19
+ txt = step.to_s.tabto(2)
20
20
  txt[0,1] = "*"
21
21
  puts txt
22
22
  end
23
23
 
24
24
  def report_macro(step)
25
- txt = step.text.tabto(2)
25
+ txt = step.to_s.tabto(2)
26
26
  txt[0,1] = "*"
27
27
  puts txt
28
28
  #puts
29
- #puts ANSICode.magenta("#{step.code}")
29
+ #puts ANSICode.magenta("#{step}")
30
30
  end
31
31
 
32
32
  def report_pass(step)
33
- #puts ANSICode.green("#{step.code}")
33
+ #puts ANSICode.green("#{step}")
34
34
  end
35
35
 
36
36
  def report_fail(step, assertion)
@@ -40,7 +40,7 @@ module Quarry
40
40
  msg = ANSICode.magenta(msg)
41
41
  puts msg
42
42
  #puts
43
- puts ANSICode.red("#{step.code}")
43
+ puts ANSICode.red("#{step}")
44
44
  end
45
45
 
46
46
  def report_error(step, exception)
@@ -52,7 +52,7 @@ module Quarry
52
52
  msg = ANSICode.magenta(msg)
53
53
  puts msg
54
54
  #puts
55
- puts ANSICode.red("#{step.code}")
55
+ puts ANSICode.red("#{step}")
56
56
  end
57
57
 
58
58
  #def report(str)
@@ -12,58 +12,64 @@ module Quarry
12
12
  # super
13
13
  # if step.code
14
14
  # #str = "(%s) %s" % [count.join('.'), str.tab(6).strip]
15
- # #puts "* #{step.text.tab(2).strip}"
15
+ # #puts "* #{step.to_s.tab(2).strip}"
16
16
  # #puts
17
- # #puts step.text
17
+ # #puts step.to_s
18
18
  # #puts
19
19
  # else
20
- # #puts "#{step.text}\n" # TODO: This never happens.
20
+ # #puts "#{step}\n" # TODO: This never happens.
21
21
  # end
22
22
  #end
23
23
 
24
24
  def report_header(step)
25
- puts ANSICode.bold(step.text)
26
- puts
25
+ puts ANSICode.bold("#{step}")
26
+ #puts
27
27
  end
28
28
 
29
29
  def report_comment(step)
30
- puts step.text
31
- puts
30
+ puts step
31
+ #puts
32
32
  end
33
33
 
34
+ #
34
35
  def report_macro(step)
35
36
  #puts
36
37
  #puts step.text
37
- puts ANSICode.magenta("#{step.code}")
38
- puts
38
+ puts ANSICode.magenta("#{step}")
39
+ #puts
39
40
  end
40
41
 
42
+ #
41
43
  def report_pass(step)
42
- puts ANSICode.green("#{step.code}")
43
- puts
44
+ puts ANSICode.green("#{step}")
45
+ #puts
44
46
  end
45
47
 
46
48
  def report_fail(step, error)
47
- tab = step.code.index(/\S/)
48
- puts ANSICode.red("#{step.code}")
49
+ tab = step.tab #step.to_s.index(/\S/)
50
+ puts ANSICode.red("#{step}")
49
51
  puts
50
52
  msg = []
51
53
  msg << ANSICode.bold(ANSICode.red("FAIL: ")) + error.to_str
52
- msg << ANSICode.bold(error.backtrace[0].chomp(":in \`run_step'"))
54
+ msg << ANSICode.bold(error.backtrace[0].chomp(":in \`run'"))
53
55
  puts msg.join("\n").tabto(tab||2)
54
- puts
56
+ #puts
55
57
  end
56
58
 
57
59
  def report_error(step, error)
58
60
  raise error if $DEBUG
59
- tab = step.code.index(/\S/)
60
- puts ANSICode.red("#{step.code}")
61
+ tab = step.tab #step.to_s.index(/\S/)
62
+ puts ANSICode.red("#{step}")
61
63
  puts
62
64
  msg = []
63
65
  msg << ANSICode.bold(ANSICode.red("ERROR: ")) + error.to_str.sub(/for Quarry::Context.*?$/,'')
64
- msg << ANSICode.bold(error.backtrace[0].chomp(":in \`run_step'"))
66
+ msg << ANSICode.bold(error.backtrace[0].chomp(":in \`run'"))
65
67
  #msg = ANSICode.red(msg)
66
68
  puts msg.join("\n").tabto(tab||2)
69
+ #puts
70
+ end
71
+
72
+ def report_step_end(step)
67
73
  puts
68
74
  end
69
75
 
@@ -39,6 +39,10 @@ module Quarry
39
39
  attr :context
40
40
  #attr :count
41
41
 
42
+ #attr_accessor :before
43
+
44
+ #attr_accessor :after
45
+
42
46
  # New Specification
43
47
  def initialize(specs, output=nil)
44
48
  @specs = [specs].flatten
@@ -72,24 +76,9 @@ module Quarry
72
76
  #context.instance_eval(&spec.given) if spec.given
73
77
 
74
78
  spec.steps.each do |step|
75
- case step
76
- when Markup::Header
77
- output.report_header(step)
78
- when Markup::Macro
79
- case step.type
80
- when :before
81
- @before = step.code
82
- when :after
83
- @after = step.code
84
- else
85
- context.instance_eval(step.code, spec.file, step.lineno)
86
- end
87
- output.report_macro(step)
88
- when Markup::Comment
89
- output.report_comment(step)
90
- else
91
- run_step(spec, step) if step.code
92
- end
79
+ output.report_step(self)
80
+ step.run(self, spec, context, output)
81
+ output.report_step_end(self)
93
82
  end
94
83
 
95
84
  # TODO <-- plugin in here end
@@ -99,6 +88,7 @@ module Quarry
99
88
  end
100
89
  end
101
90
 
91
+ =begin
102
92
  # Run a specification step.
103
93
  #
104
94
  def run_step(spec, step)
@@ -117,6 +107,35 @@ module Quarry
117
107
  end
118
108
  end
119
109
 
110
+ # Run a specification tabular step.
111
+ #
112
+ # TODO: Table reporting needs to be improved. Big time!
113
+ def run_table(spec, step)
114
+ table = YAML.load(File.new(step.file)) # yaml or csv ?
115
+
116
+ vars = *table[0]
117
+ rows = table[1..-1]
118
+
119
+ output.report_step(step)
120
+ context.instance_eval(@before, spec.file) if @before
121
+ rows.each do |row|
122
+ set = vars.zip(row).map{ |a| "#{a[0]}=#{a[1].inspect}" }.join(';')
123
+ code = set + "\n" + step.code
124
+ begin
125
+ context.instance_eval(code, spec.file, step.lineno)
126
+ #output.report_literal(set)
127
+ output.report_pass(step)
128
+ rescue Assertion => error
129
+ output.report_fail(step, error)
130
+ rescue Exception => error
131
+ output.report_error(step, error)
132
+ ensure
133
+ context.instance_eval(@after, spec.file) if @after
134
+ end
135
+ end
136
+ end
137
+ =end
138
+
120
139
  end#class Runner
121
140
 
122
141
  end#module Quarry
@@ -13,7 +13,7 @@ module Quarry
13
13
  end
14
14
 
15
15
  def inspect
16
- @spec.file
16
+ "##{@spec.file}"
17
17
  end
18
18
 
19
19
  end #class Context
File without changes
File without changes
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quarry
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Sawyer <transfire@gmail.com>
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-11-19 00:00:00 -05:00
12
+ date: 2008-11-28 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -25,9 +25,9 @@ dependencies:
25
25
  description: Quarry is a small collection of libraries to facilitate Ruby project development, testing and debugging. In particular it includes a flexible but light-weight Behavior-Driven Development (BDD) library.
26
26
  email: transfire@gmail.com
27
27
  executables:
28
- - ruby-xacto
29
28
  - quarry
30
29
  - quarry-doc
30
+ - quarry-extract
31
31
  extensions: []
32
32
 
33
33
  extra_rdoc_files:
@@ -35,6 +35,7 @@ extra_rdoc_files:
35
35
  - MANIFEST
36
36
  - CHANGES
37
37
  - RELEASE
38
+ - TODO
38
39
  - VERSION
39
40
  - COPYING
40
41
  files:
@@ -45,12 +46,13 @@ files:
45
46
  - MANIFEST
46
47
  - CHANGES
47
48
  - RELEASE
49
+ - TODO
48
50
  - README
49
51
  - VERSION
50
52
  - COPYING
51
- - bin/ruby-xacto
52
53
  - bin/quarry
53
54
  - bin/quarry-doc
55
+ - bin/quarry-extract
54
56
  - lib/quarry
55
57
  - lib/quarry.rb
56
58
  - lib/quarry/probe.rb
@@ -81,17 +83,21 @@ files:
81
83
  - lib/quarry/grammar/legacy
82
84
  - lib/quarry/grammar/should.rb
83
85
  - lib/quarry/grammar/legacy/assert.rb
86
+ - lib/quarry/markup/macro.rb
84
87
  - lib/quarry/markup/step.rb
88
+ - lib/quarry/markup/before.rb
89
+ - lib/quarry/markup/header.rb
90
+ - lib/quarry/markup/after.rb
91
+ - lib/quarry/markup/table.rb
92
+ - lib/quarry/markup/comment.rb
85
93
  - meta/created
86
94
  - meta/homepage
87
95
  - meta/summary
88
96
  - meta/abstract
89
97
  - meta/authors
90
98
  - meta/requires
91
- - spec/complex.rd
92
- - spec/mock.rd
93
- - spec/basic.rd
94
- - spec/stub.rd
99
+ - spec/04_mock.rd
100
+ - spec/03_stub.rd
95
101
  has_rdoc: true
96
102
  homepage: http://quarry.rubyforge.org
97
103
  post_install_message:
@@ -1,18 +0,0 @@
1
- = Example of Ruby Quarry Specification
2
-
3
- Notice this file is just a RDoc formatted text file.
4
- It could just as well be a Markdown file, or nearly any
5
- other markup format.
6
-
7
- Okay. Lets try out some code.
8
-
9
- (2 + 2).assert == 4
10
-
11
- Now something that will fail:
12
-
13
- (2 + 2).assert == 5
14
-
15
- And some that will raise an error:
16
-
17
- nobody_knows_method
18
-
@@ -1,48 +0,0 @@
1
- = Before and After in a Quarry Specification
2
-
3
- Quarry supports before and after clauses in specifications through
4
- the use of *BEFORE:* and *AFTER:* indicators. Before and after
5
- clauses are executed at the beginning and at the end of each test
6
- step.
7
-
8
- BEFORE: We use a before clause if we want to setup some code at the
9
- start of each step.
10
-
11
- #puts "Starting step..."
12
-
13
- AFTER: And an after clause to teardown objects after a step.
14
-
15
- #puts "Finished!"
16
-
17
- There can only be one before or after clause at a time. So if
18
- we define a new BEFORE: or AFTER: section later in the specification,
19
- it will replace the current clause in use.
20
-
21
- Only use before and after claues when necessary --specifications
22
- are typically more readible without them. In fact, some developers
23
- make a policy of avoiding them altogether. YMMV.
24
-
25
- Macros, and any other non-testable code, can be designated using the
26
- *MACRO:* indicator. Because the context in which a specification
27
- is run is a self-extended module, macros are just method definitions.
28
-
29
- MACRO: Macro's contain code to execute but not tested.
30
-
31
- def assert_integer(x)
32
- x.assert.is_a? Integer
33
- end
34
-
35
- Okay. Now lets try out some code.
36
-
37
- (2 + 2).assert == 4
38
-
39
- assert_integer(4)
40
-
41
- Now something that will fail:
42
-
43
- (2 + 2).assert == 5
44
-
45
- And some that will raise an error:
46
-
47
- nobody_knows_method
48
-