baretest 0.4.0.pre2 → 0.4.0.pre3

Sign up to get free protection for your applications and to get access to all the features.
data/MANIFEST.txt CHANGED
@@ -46,6 +46,7 @@ lib/baretest/uid.rb
46
46
  lib/baretest/use/mocha.rb
47
47
  lib/baretest/use/rack_test.rb
48
48
  lib/baretest/use/rr.rb
49
+ lib/baretest/use/support.rb
49
50
  lib/baretest/version.rb
50
51
  lib/command.rb
51
52
  lib/command/argument.rb
data/README.rdoc CHANGED
@@ -104,10 +104,7 @@ Usage:
104
104
 
105
105
  == Planned Features
106
106
 
107
- * Passing on flags/options for formatters
108
- * Tagging tests to allow focusing (only run tests with/without specific tags)
109
107
  * Word-wrapping for CLI runner
110
- * Flags for color and verbose (\[no-]color and \[no-]verbose) for the executable
111
108
  * baretest --init \[LAYOUT], to create the necessary directory structure
112
109
  * Detect whether baretest is run from an interactive terminal or not and adjust
113
110
  defaults (no-color e.g.)
@@ -124,8 +121,6 @@ Usage:
124
121
  touched file
125
122
  end
126
123
 
127
- * Inline tests via Module#describe (basically the same as Test::Suite#suite)
128
- * YARD code to extract the specifications without running the code
129
124
  * A redmine plugin
130
125
  * --fail-all flag, to test/review diagnostics of tests (no idea how to do that yet)
131
126
 
@@ -138,7 +133,7 @@ Usage:
138
133
 
139
134
  == A Bit of Background
140
135
 
141
- Originally, bare-test started out as a project for shits & giggles on the flight
136
+ Originally, baretest started out as a project for shits & giggles on the flight
142
137
  back from vegas (railsconf09), to prove that it is possible to have a fully
143
138
  fledged test-framework in under 100 lines of source-code.
144
139
  Later I realized that this project could become more. For one it was (still is)
@@ -111,7 +111,7 @@ module BareTest
111
111
  # containing suite.
112
112
  def execute(with_setup=nil, and_teardown=nil)
113
113
  if @skipped then
114
- status = Status.new(self, :manually_skipped)
114
+ status = Status.new(self, :manually_skipped, nil, @skipped)
115
115
  elsif !@block
116
116
  status = Status.new(self, :pending)
117
117
  else
@@ -100,13 +100,17 @@ module BareTest
100
100
 
101
101
  def run_suite(suite)
102
102
  return super unless suite.description
103
+
104
+ indent = " #{' '*@depth}"
105
+ skip_reason = suite.reason(:indent => indent+' ', :first_indent => indent+' Reason: ')
106
+
103
107
  case size = suite.assertions.size
104
108
  when 0
105
- defer "\n \e[1m#{' '*@depth+suite.description}\e[0m"
109
+ defer "\n#{indent}\e[1m#{suite.description}\e[0m", skip_reason
106
110
  when 1
107
- defer "\n \e[1m#{' '*@depth+suite.description}\e[0m (1 test)"
111
+ defer "\n#{indent}\e[1m#{suite.description}\e[0m (1 test)", skip_reason
108
112
  else
109
- defer "\n \e[1m#{' '*@depth+suite.description}\e[0m (#{size} tests)"
113
+ defer "\n#{indent}\e[1m#{suite.description}\e[0m (#{size} tests)", skip_reason
110
114
  end
111
115
  @depth += 1
112
116
  rv = super(suite) # run the suite
@@ -121,7 +125,7 @@ module BareTest
121
125
  rv = super # run the assertion
122
126
  indent = ' '+' '*@depth
123
127
  backtrace = []
124
- reason = rv.reason(:indent => indent)
128
+ reason = rv.reason(:indent => indent, :first_indent => indent+'Reason: ')
125
129
 
126
130
  printf(Formats[rv.status], StatusLabel[rv.status], ' '*@depth, interpolated_description(assertion, setup))
127
131
  if rv.status == :error then
@@ -139,8 +143,12 @@ module BareTest
139
143
  str.scan(/[^ ]+ /)
140
144
  end
141
145
 
142
- def defer(output)
143
- @deferred << output
146
+ # Add data to output, but mark it as deferred
147
+ # We defer in order to be able to ignore suites. Ignored suites that
148
+ # contain unignored suites/assertions must be displayed, ignored suites
149
+ # that don't, will be popped from the deferred-stack
150
+ def defer(*output)
151
+ @deferred.concat(output.compact)
144
152
  end
145
153
 
146
154
  def pop_deferred
data/lib/baretest/run.rb CHANGED
@@ -68,18 +68,21 @@ module BareTest
68
68
  @exclude_tags = @options[:exclude_tags] # nil is ok here
69
69
  include_states = @options[:include_states] # nil is ok here
70
70
  exclude_states = @options[:exclude_states] # nil is ok here
71
- @states = [nil, :success, :failure, :skipped, :pending, :error]
71
+ @states = [nil, *BareTest::StatusOrder]
72
72
  @skipped = {}
73
73
  @last_run_states = {}
74
-
75
- @persistence = @options[:persistence]
74
+ @persistence = @options[:persistence]
76
75
 
77
76
  if (include_states || exclude_states) && !((include_states && include_states.empty?) && (exclude_states && exclude_states.empty?)) then
78
77
  [include_states, exclude_states].compact.each do |states|
79
78
  states << nil if states.include?(:new)
80
- states << :pending if states.include?(:skipped)
81
- states.concat([:error, :skipped, :pending]) if states.include?(:failure)
79
+ states.push(:error, :skipped, :pending) if states.include?(:failure)
82
80
  states.delete(:new)
81
+ if states.include?(:skipped) then
82
+ states.delete(:skipped)
83
+ states.push(:pending, :manually_skipped, :dependency_missing, :library_missing, :component_missing)
84
+ end
85
+ states.uniq!
83
86
  end
84
87
  @states = (include_states || @states) - (exclude_states || [])
85
88
  end
@@ -144,9 +147,9 @@ module BareTest
144
147
  skipped = @skipped[suite] || recursively_skipped
145
148
 
146
149
  if recursively_skipped then
147
- skip_recursively(suite, "Skipped")
150
+ skip_recursively(suite, "Ancestor was skipped")
148
151
  elsif skipped then
149
- skip_suite(suite, "Skipped")
152
+ skip_suite(suite, "Container was skipped")
150
153
  end
151
154
  end
152
155
 
@@ -0,0 +1,9 @@
1
+ BareTest.new_component :support do
2
+ require 'baretest/assertion/support'
3
+
4
+ BareTest::Assertion::Context.send :include, BareTest::Assertion::Support
5
+
6
+ teardown do
7
+ ::BareTest.clean_touches(self) # instance evaled, self is the assertion
8
+ end
9
+ end
@@ -21,7 +21,7 @@ module BareTest
21
21
  TINY = 0
22
22
 
23
23
  # Prerelease number - nil for release versions
24
- PRERELEASE = 2
24
+ PRERELEASE = 3
25
25
 
26
26
  # The version as a string
27
27
  STRING = %{#{MAJOR}.#{MINOR||0}.#{TINY||0}#{".pre#{PRERELEASE}" if PRERELEASE}}
@@ -145,7 +145,7 @@ BareTest.suite 'BareTest' do
145
145
 
146
146
  suite '#setup' do
147
147
  assert 'Fails if setup raises an exception' do
148
- setup = proc { raise 'Some error' }
148
+ setup = BareTest::Setup.new do raise 'Some error' end
149
149
  assertion = ::BareTest::Assertion.new(nil, 'assertion') do true end
150
150
  status = assertion.execute([setup])
151
151
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: baretest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0.pre2
4
+ version: 0.4.0.pre3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan Rusterholz
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-02-17 00:00:00 +01:00
12
+ date: 2010-02-24 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -72,6 +72,7 @@ files:
72
72
  - lib/baretest/use/mocha.rb
73
73
  - lib/baretest/use/rack_test.rb
74
74
  - lib/baretest/use/rr.rb
75
+ - lib/baretest/use/support.rb
75
76
  - lib/baretest/version.rb
76
77
  - lib/command.rb
77
78
  - lib/command/argument.rb
@@ -118,7 +119,7 @@ rdoc_options:
118
119
  - --tab-width
119
120
  - "2"
120
121
  - -t
121
- - baretest-0.4.0.pre2
122
+ - baretest-0.4.0.pre3
122
123
  require_paths:
123
124
  - lib
124
125
  required_ruby_version: !ruby/object:Gem::Requirement