protest 0.4.2 → 0.5.0

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.
@@ -10,21 +10,11 @@ module Protest
10
10
  # This report is based on the output displayed by TURN[http://github.com/TwP/turn],
11
11
  # Test::Unit Reporter (New) by Tim Pease.
12
12
  class Reports::Turn < Report
13
- include Utils::Summaries
14
- include Utils::ColorfulOutput
15
-
16
- attr_reader :stream #:nodoc:
17
-
18
13
  PASS = "PASS"
19
14
  FAIL = "FAIL"
20
15
  ERROR = "ERROR"
21
16
  PENDING = "PENDING"
22
17
 
23
- # Set the stream where the report will be written to. STDOUT by default.
24
- def initialize(stream=STDOUT)
25
- @stream = stream
26
- end
27
-
28
18
  on :enter do |report, context|
29
19
  report.puts context.description unless context.tests.empty?
30
20
  end
@@ -22,16 +22,15 @@ module Protest
22
22
  # Run a test and report if it passes, fails, or is pending. Takes the name
23
23
  # of the test as an argument.
24
24
  def report(test)
25
- fire_event(:test, Test.new(test)) if test.real?
25
+ fire_event(:test, Test.new(test))
26
26
  test.run(@report)
27
- fire_event(:pass, PassedTest.new(test)) if test.real?
27
+ fire_event(:pass, PassedTest.new(test))
28
28
  rescue Pending => e
29
29
  fire_event :pending, PendingTest.new(test, e)
30
30
  rescue AssertionFailed => e
31
31
  fire_event :failure, FailedTest.new(test, e)
32
32
  rescue Exception => e
33
33
  fire_event :error, ErroredTest.new(test, e)
34
- raise if test.raise_exceptions?
35
34
  end
36
35
 
37
36
  protected
@@ -17,8 +17,12 @@ module Protest
17
17
  end
18
18
 
19
19
  class << self
20
- alias_method :describe, :context
21
- alias_method :story, :context
20
+ alias_method :describe, :context
21
+
22
+ def story(description, &block)
23
+ warn "[DEPRECATED] `story` alias is deprecated. Use `describe` or `context` instead."
24
+ context(description, &block)
25
+ end
22
26
  end
23
27
 
24
28
  # A TestCase defines a suite of related tests. You can further categorize
@@ -28,14 +32,7 @@ module Protest
28
32
  # Run all tests in this context. Takes a Runner instance in order to
29
33
  # provide output.
30
34
  def self.run(runner)
31
- runner.report(TestWrapper.new(:setup, self))
32
35
  tests.each {|test| runner.report(test) }
33
- runner.report(TestWrapper.new(:teardown, self))
34
- rescue Exception => e
35
- # If any exception bubbles up here, then it means it was during the
36
- # global setup/teardown blocks, so let's just skip the rest of this
37
- # context.
38
- return
39
36
  end
40
37
 
41
38
  # Tests added to this context.
@@ -43,14 +40,13 @@ module Protest
43
40
  @tests ||= []
44
41
  end
45
42
 
46
- # Add a test to be run in this context. This method is aliased as +it+,
47
- # +should+ and +scenario+ for your comfort.
43
+ # Add a test to be run in this context. This method is aliased as +it+
44
+ # and +should+ for your comfort.
48
45
  def self.test(name, &block)
49
46
  tests << new(name, caller.at(0), &block)
50
47
  end
51
48
 
52
- # Add a setup block to be run before each test in this context. This method
53
- # is aliased as +before+ for your comfort.
49
+ # Add a setup block to be run before each test in this context.
54
50
  def self.setup(&block)
55
51
  define_method :setup do
56
52
  super()
@@ -58,33 +54,7 @@ module Protest
58
54
  end
59
55
  end
60
56
 
61
- # Add a +setup+ block that will be run *once* for the entire test case,
62
- # before the first test is run.
63
- #
64
- # Keep in mind that while +setup+ blocks are evaluated on the context of the
65
- # test, and thus you can share state between them, your tests will not be
66
- # able to access instance variables set in a +global_setup+ block.
67
- #
68
- # This is usually not needed (and generally using it is a code smell, since
69
- # you could make a test dependent on the state of other tests, which is a
70
- # huge problem), but it comes in handy when you need to do expensive
71
- # operations in your test setup/teardown and the tests won't modify the
72
- # state set on this operations. For example, creating large amount of
73
- # records in a database or filesystem, when your tests will only read these
74
- # records.
75
- #
76
- # This method is aliased as +before_all+ for your comfort.
77
- def self.global_setup(&block)
78
- (class << self; self; end).class_eval do
79
- define_method :do_global_setup do
80
- super()
81
- instance_eval(&block)
82
- end
83
- end
84
- end
85
-
86
- # Add a teardown block to be run after each test in this context. This
87
- # method is aliased as +after+ for your comfort.
57
+ # Add a teardown block to be run after each test in this context.
88
58
  def self.teardown(&block)
89
59
  define_method :teardown do
90
60
  instance_eval(&block)
@@ -92,31 +62,9 @@ module Protest
92
62
  end
93
63
  end
94
64
 
95
- # Add a +teardown+ block that will be run *once* for the entire test case,
96
- # after the last test is run.
97
- #
98
- # Keep in mind that while +teardown+ blocks are evaluated on the context of
99
- # the test, and thus you can share state between the tests and the
100
- # teardown blocks, you will not be able to access instance variables set in
101
- # a test from your +global_teardown+ block.
102
- #
103
- # See TestCase.global_setup for a discussion on why these methods are best
104
- # avoided unless you really need them and use them carefully.
105
- #
106
- # This method is aliased as +after_all+ for your comfort.
107
- def self.global_teardown(&block)
108
- (class << self; self; end).class_eval do
109
- define_method :do_global_teardown do
110
- instance_eval(&block)
111
- super()
112
- end
113
- end
114
- end
115
-
116
65
  # Define a new test context nested under the current one. All +setup+ and
117
66
  # +teardown+ blocks defined on the current context will be inherited by the
118
- # new context. This method is aliased as +describe+ and +story+ for your
119
- # comfort.
67
+ # new context. This method is aliased as +describe+ for your comfort.
120
68
  def self.context(description, &block)
121
69
  subclass = Class.new(self)
122
70
  subclass.class_eval(&block) if block
@@ -129,18 +77,29 @@ module Protest
129
77
  # descriptive output when running your tests.
130
78
  attr_accessor :description
131
79
 
132
- alias_method :describe, :context
133
- alias_method :story, :context
80
+ alias_method :describe, :context
81
+ alias_method :it, :test
82
+ alias_method :should, :test
134
83
 
135
- alias_method :before, :setup
136
- alias_method :after, :teardown
84
+ def story(description, &block)
85
+ warn "[DEPRECATED] `story` alias is deprecated. Use `describe` or `context` instead."
86
+ context(description, &block)
87
+ end
137
88
 
138
- alias_method :before_all, :global_setup
139
- alias_method :after_all, :global_teardown
89
+ def scenario(name, &block)
90
+ warn "[DEPRECATED] `scenario` alias is deprecated. Use `test`, `it` or `should` instead."
91
+ test(name, &block)
92
+ end
93
+
94
+ def before(&block)
95
+ warn "[DEPRECATED] `before` alias is deprecated. Use `setup` instead."
96
+ setup(&block)
97
+ end
140
98
 
141
- alias_method :it, :test
142
- alias_method :should, :test
143
- alias_method :scenario, :test
99
+ def after(&block)
100
+ warn "[DEPRECATED] `after` alias is deprecated. Use `teardown` instead."
101
+ teardown(&block)
102
+ end
144
103
  end
145
104
 
146
105
  # Initialize a new instance of a single test. This test can be run in
@@ -209,16 +168,6 @@ module Protest
209
168
  @name
210
169
  end
211
170
 
212
- # Tests must not re-raise exceptions
213
- def raise_exceptions?
214
- false
215
- end
216
-
217
- # This is a real test
218
- def real?
219
- true
220
- end
221
-
222
171
  private
223
172
 
224
173
  def setup #:nodoc:
@@ -236,47 +185,13 @@ module Protest
236
185
  end
237
186
  private_class_method :sanitize_description
238
187
 
239
- def self.do_global_setup
240
- end
241
- private_class_method :do_global_setup
242
-
243
- def self.do_global_teardown
244
- end
245
- private_class_method :do_global_teardown
246
-
247
188
  def self.description #:nodoc:
248
189
  parent = ancestors[1..-1].detect {|a| a < Protest::TestCase }
249
190
  "#{parent.description rescue nil} #{@description}".strip
250
191
  end
251
192
 
252
193
  def self.inherited(child)
253
- Protest.add_test_case(child)
254
- end
255
-
256
- # Provides the TestCase API for global setup/teardown blocks, so they can be
257
- # "faked" as tests into the reporter (they aren't counted towards the total
258
- # number of tests but they could count towards the number of failures/errors.)
259
- class TestWrapper #:nodoc:
260
- attr_reader :name
261
-
262
- def initialize(type, test_case)
263
- @type = type
264
- @test = test_case
265
- @name = "Global #{@type} for #{test_case.description}"
266
- end
267
-
268
- def run(report)
269
- @test.send("do_global_#{@type}")
270
- end
271
-
272
- def raise_exceptions?
273
- true
274
- end
275
-
276
- # This is not a real test but a fake one
277
- def real?
278
- false
279
- end
194
+ Protest.test_cases << child
280
195
  end
281
196
  end
282
197
  end
@@ -49,7 +49,7 @@ module Protest
49
49
 
50
50
  # Call on +:end+ to print a list of failures (failed assertions) and errors
51
51
  # (unrescued exceptions), including file and line number where the test
52
- # failed, and a short backtrace.
52
+ # failed, and a backtrace.
53
53
  #
54
54
  # It will not output anything if there weren't any failures or errors.
55
55
  #
@@ -73,7 +73,7 @@ module Protest
73
73
  colorize_as = ErroredTest === error ? :errored : :failed
74
74
  puts " #{pad(index+1, pad_indexes)}) #{test_type(error)}: `#{error.test_name}' (on line #{error.line} of `#{error.file}')", colorize_as
75
75
  puts indent("With `#{error.error_message}'", 6 + pad_indexes), colorize_as
76
- indent(error.backtrace[0..2], 6 + pad_indexes).each {|backtrace| puts backtrace, colorize_as }
76
+ indent(error.backtrace, 6 + pad_indexes).each {|backtrace| puts backtrace, colorize_as }
77
77
  puts
78
78
  end
79
79
  end
@@ -0,0 +1,3 @@
1
+ module Protest
2
+ VERSION = "0.5.0"
3
+ end
@@ -1,43 +1,17 @@
1
1
  # -*- coding: utf-8 -*-
2
- Gem::Specification.new do |s|
3
- s.name = "protest"
4
- s.version = "0.4.2"
5
- s.date = "2010-10-22"
6
-
7
- s.description = "Protest is a tiny, simple, and easy-to-extend test framework"
8
- s.summary = s.description
9
- s.homepage = "http://protestrb.com"
10
2
 
11
- s.authors = ["Nicolás Sanguinetti", "Matías Flores"]
12
- s.email = "mflores@atlanware.com"
3
+ require "./lib/protest/version"
13
4
 
14
- s.require_paths = ["lib"]
15
- s.rubyforge_project = "protest"
16
- s.has_rdoc = true
17
- s.rubygems_version = "1.3.1"
18
-
19
- s.files = %w[
20
- .gitignore
21
- LICENSE
22
- README.rdoc
23
- Rakefile
24
- protest.gemspec
25
- lib/protest.rb
26
- lib/protest/utils.rb
27
- lib/protest/utils/backtrace_filter.rb
28
- lib/protest/utils/summaries.rb
29
- lib/protest/utils/colorful_output.rb
30
- lib/protest/test_case.rb
31
- lib/protest/tests.rb
32
- lib/protest/runner.rb
33
- lib/protest/stories.rb
34
- lib/protest/report.rb
35
- lib/protest/reports.rb
36
- lib/protest/reports/progress.rb
37
- lib/protest/reports/documentation.rb
38
- lib/protest/reports/summary.rb
39
- lib/protest/reports/turn.rb
40
- lib/protest/reports/stories.rb
41
- lib/protest/reports/stories/pdf.rb
42
- ]
5
+ Gem::Specification.new do |s|
6
+ s.name = "protest"
7
+ s.version = Protest::VERSION
8
+ s.summary = "Protest is a tiny, simple, and easy-to-extend test framework"
9
+ s.description = "Protest is a tiny, simple, and easy-to-extend test framework for ruby."
10
+ s.homepage = "http://protestrb.com"
11
+ s.authors = ["Nicolás Sanguinetti", "Matías Flores"]
12
+ s.email = "flores.matias@gmail.com"
13
+ s.license = "MIT"
14
+ s.require_paths = ["lib"]
15
+ s.files = %w{ .gitignore CHANGELOG.md LICENSE README.md Rakefile protest.gemspec }
16
+ s.files += Dir["lib/**/*.rb"]
43
17
  end
metadata CHANGED
@@ -1,89 +1,68 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: protest
3
- version: !ruby/object:Gem::Version
4
- hash: 11
5
- prerelease: false
6
- segments:
7
- - 0
8
- - 4
9
- - 2
10
- version: 0.4.2
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.0
5
+ prerelease:
11
6
  platform: ruby
12
- authors:
13
- - "Nicol\xC3\xA1s Sanguinetti"
14
- - "Mat\xC3\xADas Flores"
7
+ authors:
8
+ - Nicolás Sanguinetti
9
+ - Matías Flores
15
10
  autorequire:
16
11
  bindir: bin
17
12
  cert_chain: []
18
-
19
- date: 2010-10-22 00:00:00 -03:00
20
- default_executable:
13
+ date: 2013-06-07 00:00:00.000000000 Z
21
14
  dependencies: []
22
-
23
- description: Protest is a tiny, simple, and easy-to-extend test framework
24
- email: mflores@atlanware.com
15
+ description: Protest is a tiny, simple, and easy-to-extend test framework for ruby.
16
+ email: flores.matias@gmail.com
25
17
  executables: []
26
-
27
18
  extensions: []
28
-
29
19
  extra_rdoc_files: []
30
-
31
- files:
20
+ files:
32
21
  - .gitignore
22
+ - CHANGELOG.md
33
23
  - LICENSE
34
- - README.rdoc
24
+ - README.md
35
25
  - Rakefile
36
26
  - protest.gemspec
37
- - lib/protest.rb
38
- - lib/protest/utils.rb
39
- - lib/protest/utils/backtrace_filter.rb
40
- - lib/protest/utils/summaries.rb
41
- - lib/protest/utils/colorful_output.rb
42
- - lib/protest/test_case.rb
43
- - lib/protest/tests.rb
44
- - lib/protest/runner.rb
45
- - lib/protest/stories.rb
46
27
  - lib/protest/report.rb
47
- - lib/protest/reports.rb
48
- - lib/protest/reports/progress.rb
49
28
  - lib/protest/reports/documentation.rb
29
+ - lib/protest/reports/progress.rb
50
30
  - lib/protest/reports/summary.rb
51
31
  - lib/protest/reports/turn.rb
52
- - lib/protest/reports/stories.rb
53
- - lib/protest/reports/stories/pdf.rb
54
- has_rdoc: true
32
+ - lib/protest/reports.rb
33
+ - lib/protest/runner.rb
34
+ - lib/protest/test_case.rb
35
+ - lib/protest/tests.rb
36
+ - lib/protest/utils/backtrace_filter.rb
37
+ - lib/protest/utils/colorful_output.rb
38
+ - lib/protest/utils/summaries.rb
39
+ - lib/protest/utils.rb
40
+ - lib/protest/version.rb
41
+ - lib/protest.rb
55
42
  homepage: http://protestrb.com
56
- licenses: []
57
-
43
+ licenses:
44
+ - MIT
58
45
  post_install_message:
59
46
  rdoc_options: []
60
-
61
- require_paths:
47
+ require_paths:
62
48
  - lib
63
- required_ruby_version: !ruby/object:Gem::Requirement
49
+ required_ruby_version: !ruby/object:Gem::Requirement
64
50
  none: false
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- hash: 3
69
- segments:
70
- - 0
71
- version: "0"
72
- required_rubygems_version: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
56
  none: false
74
- requirements:
75
- - - ">="
76
- - !ruby/object:Gem::Version
77
- hash: 3
78
- segments:
79
- - 0
80
- version: "0"
57
+ requirements:
58
+ - - ! '>='
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
81
61
  requirements: []
82
-
83
- rubyforge_project: protest
84
- rubygems_version: 1.3.7
62
+ rubyforge_project:
63
+ rubygems_version: 1.8.23
85
64
  signing_key:
86
65
  specification_version: 3
87
66
  summary: Protest is a tiny, simple, and easy-to-extend test framework
88
67
  test_files: []
89
-
68
+ has_rdoc: