opal-rspec 0.4.0.beta3 → 0.4.0.beta4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (161) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -1
  3. data/.gitmodules +15 -0
  4. data/.travis.yml +12 -0
  5. data/.yardopts +5 -0
  6. data/CHANGELOG.md +3 -1
  7. data/Gemfile +6 -7
  8. data/README.md +2 -0
  9. data/Rakefile +12 -50
  10. data/lib/opal/rspec/version.rb +1 -1
  11. data/lib/opal/rspec.rb +14 -0
  12. data/opal/opal/rspec/async.rb +146 -11
  13. data/opal/opal/rspec/fixes.rb +18 -8
  14. data/opal/opal/rspec/requires.rb +45 -0
  15. data/opal/opal/rspec.rb +1 -24
  16. data/opal-rspec.gemspec +1 -1
  17. data/spec/async_spec.rb +4 -5
  18. data/spec/matchers_spec.rb +20 -0
  19. data/spec/named_subject_spec.rb +11 -0
  20. data/spec/should_syntax_spec.rb +17 -0
  21. data/vendor_lib/rspec/autorun.rb +2 -0
  22. data/vendor_lib/rspec/core/backport_random.rb +302 -0
  23. data/vendor_lib/rspec/core/backtrace_formatter.rb +65 -0
  24. data/vendor_lib/rspec/core/command_line.rb +36 -0
  25. data/vendor_lib/rspec/core/configuration.rb +1129 -0
  26. data/vendor_lib/rspec/core/configuration_options.rb +143 -0
  27. data/vendor_lib/rspec/core/drb_command_line.rb +26 -0
  28. data/vendor_lib/rspec/core/drb_options.rb +87 -0
  29. data/vendor_lib/rspec/core/dsl.rb +26 -0
  30. data/vendor_lib/rspec/core/example.rb +312 -0
  31. data/vendor_lib/rspec/core/example_group.rb +540 -0
  32. data/vendor_lib/rspec/core/filter_manager.rb +224 -0
  33. data/vendor_lib/rspec/core/flat_map.rb +17 -0
  34. data/vendor_lib/rspec/core/formatters/base_formatter.rb +291 -0
  35. data/vendor_lib/rspec/core/formatters/base_text_formatter.rb +307 -0
  36. data/vendor_lib/rspec/core/formatters/deprecation_formatter.rb +193 -0
  37. data/vendor_lib/rspec/core/formatters/documentation_formatter.rb +67 -0
  38. data/vendor_lib/rspec/core/formatters/helpers.rb +82 -0
  39. data/vendor_lib/rspec/core/formatters/html_formatter.rb +155 -0
  40. data/vendor_lib/rspec/core/formatters/html_printer.rb +408 -0
  41. data/vendor_lib/rspec/core/formatters/json_formatter.rb +99 -0
  42. data/vendor_lib/rspec/core/formatters/progress_formatter.rb +32 -0
  43. data/vendor_lib/rspec/core/formatters/snippet_extractor.rb +101 -0
  44. data/vendor_lib/rspec/core/formatters.rb +54 -0
  45. data/vendor_lib/rspec/core/hooks.rb +535 -0
  46. data/vendor_lib/rspec/core/memoized_helpers.rb +431 -0
  47. data/vendor_lib/rspec/core/metadata.rb +313 -0
  48. data/vendor_lib/rspec/core/mocking/with_absolutely_nothing.rb +11 -0
  49. data/vendor_lib/rspec/core/mocking/with_flexmock.rb +27 -0
  50. data/vendor_lib/rspec/core/mocking/with_mocha.rb +52 -0
  51. data/vendor_lib/rspec/core/mocking/with_rr.rb +27 -0
  52. data/vendor_lib/rspec/core/mocking/with_rspec.rb +27 -0
  53. data/vendor_lib/rspec/core/option_parser.rb +234 -0
  54. data/vendor_lib/rspec/core/ordering.rb +154 -0
  55. data/vendor_lib/rspec/core/pending.rb +110 -0
  56. data/vendor_lib/rspec/core/project_initializer.rb +88 -0
  57. data/vendor_lib/rspec/core/rake_task.rb +128 -0
  58. data/vendor_lib/rspec/core/reporter.rb +132 -0
  59. data/vendor_lib/rspec/core/ruby_project.rb +44 -0
  60. data/vendor_lib/rspec/core/runner.rb +97 -0
  61. data/vendor_lib/rspec/core/shared_context.rb +53 -0
  62. data/vendor_lib/rspec/core/shared_example_group/collection.rb +27 -0
  63. data/vendor_lib/rspec/core/shared_example_group.rb +146 -0
  64. data/vendor_lib/rspec/core/version.rb +7 -0
  65. data/vendor_lib/rspec/core/warnings.rb +22 -0
  66. data/vendor_lib/rspec/core/world.rb +131 -0
  67. data/vendor_lib/rspec/core.rb +203 -0
  68. data/vendor_lib/rspec/expectations/differ.rb +154 -0
  69. data/vendor_lib/rspec/expectations/errors.rb +9 -0
  70. data/vendor_lib/rspec/expectations/expectation_target.rb +87 -0
  71. data/vendor_lib/rspec/expectations/extensions/object.rb +29 -0
  72. data/vendor_lib/rspec/expectations/extensions.rb +1 -0
  73. data/vendor_lib/rspec/expectations/fail_with.rb +79 -0
  74. data/vendor_lib/rspec/expectations/handler.rb +68 -0
  75. data/vendor_lib/rspec/expectations/syntax.rb +182 -0
  76. data/vendor_lib/rspec/expectations/version.rb +8 -0
  77. data/vendor_lib/rspec/expectations.rb +75 -0
  78. data/vendor_lib/rspec/matchers/built_in/base_matcher.rb +68 -0
  79. data/vendor_lib/rspec/matchers/built_in/be.rb +213 -0
  80. data/vendor_lib/rspec/matchers/built_in/be_instance_of.rb +15 -0
  81. data/vendor_lib/rspec/matchers/built_in/be_kind_of.rb +11 -0
  82. data/vendor_lib/rspec/matchers/built_in/be_within.rb +55 -0
  83. data/vendor_lib/rspec/matchers/built_in/change.rb +141 -0
  84. data/vendor_lib/rspec/matchers/built_in/cover.rb +21 -0
  85. data/vendor_lib/rspec/matchers/built_in/eq.rb +22 -0
  86. data/vendor_lib/rspec/matchers/built_in/eql.rb +23 -0
  87. data/vendor_lib/rspec/matchers/built_in/equal.rb +48 -0
  88. data/vendor_lib/rspec/matchers/built_in/exist.rb +26 -0
  89. data/vendor_lib/rspec/matchers/built_in/has.rb +48 -0
  90. data/vendor_lib/rspec/matchers/built_in/include.rb +61 -0
  91. data/vendor_lib/rspec/matchers/built_in/match.rb +17 -0
  92. data/vendor_lib/rspec/matchers/built_in/match_array.rb +51 -0
  93. data/vendor_lib/rspec/matchers/built_in/raise_error.rb +154 -0
  94. data/vendor_lib/rspec/matchers/built_in/respond_to.rb +74 -0
  95. data/vendor_lib/rspec/matchers/built_in/satisfy.rb +30 -0
  96. data/vendor_lib/rspec/matchers/built_in/start_and_end_with.rb +48 -0
  97. data/vendor_lib/rspec/matchers/built_in/throw_symbol.rb +94 -0
  98. data/vendor_lib/rspec/matchers/built_in/yield.rb +297 -0
  99. data/vendor_lib/rspec/matchers/built_in.rb +39 -0
  100. data/vendor_lib/rspec/matchers/compatibility.rb +14 -0
  101. data/vendor_lib/rspec/matchers/configuration.rb +113 -0
  102. data/vendor_lib/rspec/matchers/dsl.rb +23 -0
  103. data/vendor_lib/rspec/matchers/generated_descriptions.rb +35 -0
  104. data/vendor_lib/rspec/matchers/matcher.rb +301 -0
  105. data/vendor_lib/rspec/matchers/method_missing.rb +12 -0
  106. data/vendor_lib/rspec/matchers/operator_matcher.rb +99 -0
  107. data/vendor_lib/rspec/matchers/pretty.rb +70 -0
  108. data/vendor_lib/rspec/matchers/test_unit_integration.rb +11 -0
  109. data/vendor_lib/rspec/matchers.rb +633 -0
  110. data/vendor_lib/rspec/mocks/any_instance/chain.rb +92 -0
  111. data/vendor_lib/rspec/mocks/any_instance/expectation_chain.rb +47 -0
  112. data/vendor_lib/rspec/mocks/any_instance/message_chains.rb +75 -0
  113. data/vendor_lib/rspec/mocks/any_instance/recorder.rb +200 -0
  114. data/vendor_lib/rspec/mocks/any_instance/stub_chain.rb +45 -0
  115. data/vendor_lib/rspec/mocks/any_instance/stub_chain_chain.rb +23 -0
  116. data/vendor_lib/rspec/mocks/argument_list_matcher.rb +104 -0
  117. data/vendor_lib/rspec/mocks/argument_matchers.rb +264 -0
  118. data/vendor_lib/rspec/mocks/arity_calculator.rb +66 -0
  119. data/vendor_lib/rspec/mocks/configuration.rb +111 -0
  120. data/vendor_lib/rspec/mocks/error_generator.rb +203 -0
  121. data/vendor_lib/rspec/mocks/errors.rb +12 -0
  122. data/vendor_lib/rspec/mocks/example_methods.rb +201 -0
  123. data/vendor_lib/rspec/mocks/extensions/marshal.rb +17 -0
  124. data/vendor_lib/rspec/mocks/framework.rb +36 -0
  125. data/vendor_lib/rspec/mocks/instance_method_stasher.rb +112 -0
  126. data/vendor_lib/rspec/mocks/matchers/have_received.rb +99 -0
  127. data/vendor_lib/rspec/mocks/matchers/receive.rb +112 -0
  128. data/vendor_lib/rspec/mocks/matchers/receive_messages.rb +72 -0
  129. data/vendor_lib/rspec/mocks/message_expectation.rb +643 -0
  130. data/vendor_lib/rspec/mocks/method_double.rb +209 -0
  131. data/vendor_lib/rspec/mocks/method_reference.rb +95 -0
  132. data/vendor_lib/rspec/mocks/mock.rb +7 -0
  133. data/vendor_lib/rspec/mocks/mutate_const.rb +406 -0
  134. data/vendor_lib/rspec/mocks/object_reference.rb +90 -0
  135. data/vendor_lib/rspec/mocks/order_group.rb +82 -0
  136. data/vendor_lib/rspec/mocks/proxy.rb +269 -0
  137. data/vendor_lib/rspec/mocks/proxy_for_nil.rb +37 -0
  138. data/vendor_lib/rspec/mocks/space.rb +95 -0
  139. data/vendor_lib/rspec/mocks/standalone.rb +3 -0
  140. data/vendor_lib/rspec/mocks/stub_chain.rb +51 -0
  141. data/vendor_lib/rspec/mocks/syntax.rb +374 -0
  142. data/vendor_lib/rspec/mocks/targets.rb +90 -0
  143. data/vendor_lib/rspec/mocks/test_double.rb +109 -0
  144. data/vendor_lib/rspec/mocks/verifying_double.rb +77 -0
  145. data/vendor_lib/rspec/mocks/verifying_message_expecation.rb +60 -0
  146. data/vendor_lib/rspec/mocks/verifying_proxy.rb +151 -0
  147. data/vendor_lib/rspec/mocks/version.rb +7 -0
  148. data/vendor_lib/rspec/mocks.rb +100 -0
  149. data/vendor_lib/rspec/support/caller_filter.rb +56 -0
  150. data/vendor_lib/rspec/support/spec/deprecation_helpers.rb +29 -0
  151. data/vendor_lib/rspec/support/spec/in_sub_process.rb +40 -0
  152. data/vendor_lib/rspec/support/spec/stderr_splitter.rb +50 -0
  153. data/vendor_lib/rspec/support/spec.rb +14 -0
  154. data/vendor_lib/rspec/support/version.rb +7 -0
  155. data/vendor_lib/rspec/support/warnings.rb +41 -0
  156. data/vendor_lib/rspec/support.rb +6 -0
  157. data/vendor_lib/rspec/version.rb +5 -0
  158. data/vendor_lib/rspec-expectations.rb +1 -0
  159. data/vendor_lib/rspec.rb +3 -0
  160. metadata +163 -4
  161. data/opal/opal/rspec/rspec.js +0 -20384
@@ -0,0 +1,302 @@
1
+ # This code was (mostly) ported from the backports gem (https://github.com/marcandre/backports).
2
+ # The goal is to provide a random number generator in Ruby versions that do not have one.
3
+ # This was added to support localization of random spec ordering.
4
+ #
5
+ # These were in multiple files in backports, but merged into one here.
6
+
7
+ module RSpec
8
+ module Core
9
+ # Methods used internally by the backports.
10
+ module Backports
11
+ # Helper method to coerce a value into a specific class.
12
+ # Raises a TypeError if the coercion fails or the returned value
13
+ # is not of the right class.
14
+ # (from Rubinius)
15
+ def self.coerce_to(obj, cls, meth)
16
+ return obj if obj.kind_of?(cls)
17
+
18
+ begin
19
+ ret = obj.__send__(meth)
20
+ rescue Exception => e
21
+ raise TypeError, "Coercion error: #{obj.inspect}.#{meth} => #{cls} failed:\n" \
22
+ "(#{e.message})"
23
+ end
24
+ raise TypeError, "Coercion error: obj.#{meth} did NOT return a #{cls} (was #{ret.class})" unless ret.kind_of? cls
25
+ ret
26
+ end
27
+
28
+ def self.coerce_to_int(obj)
29
+ coerce_to(obj, Integer, :to_int)
30
+ end
31
+
32
+ # Used internally to make it easy to deal with optional arguments
33
+ # (from Rubinius)
34
+ Undefined = Object.new
35
+
36
+ class Random
37
+ # An implementation of Mersenne Twister MT19937 in Ruby
38
+ class MT19937
39
+ STATE_SIZE = 624
40
+ LAST_STATE = STATE_SIZE - 1
41
+ PAD_32_BITS = 0xffffffff
42
+
43
+ # See seed=
44
+ def initialize(seed)
45
+ self.seed = seed
46
+ end
47
+
48
+ LAST_31_BITS = 0x7fffffff
49
+ OFFSET = 397
50
+
51
+ # Generates a completely new state out of the previous one.
52
+ def next_state
53
+ STATE_SIZE.times do |i|
54
+ mix = @state[i] & 0x80000000 | @state[i+1 - STATE_SIZE] & 0x7fffffff
55
+ @state[i] = @state[i+OFFSET - STATE_SIZE] ^ (mix >> 1)
56
+ @state[i] ^= 0x9908b0df if mix.odd?
57
+ end
58
+ @last_read = -1
59
+ end
60
+
61
+ # Seed must be either an Integer (only the first 32 bits will be used)
62
+ # or an Array of Integers (of which only the first 32 bits will be used)
63
+ #
64
+ # No conversion or type checking is done at this level
65
+ def seed=(seed)
66
+ case seed
67
+ when Integer
68
+ @state = Array.new(STATE_SIZE)
69
+ @state[0] = seed & PAD_32_BITS
70
+ (1..LAST_STATE).each do |i|
71
+ @state[i] = (1812433253 * (@state[i-1] ^ @state[i-1]>>30) + i)& PAD_32_BITS
72
+ end
73
+ @last_read = LAST_STATE
74
+ when Array
75
+ self.seed = 19650218
76
+ i=1
77
+ j=0
78
+ [STATE_SIZE, seed.size].max.times do
79
+ @state[i] = (@state[i] ^ (@state[i-1] ^ @state[i-1]>>30) * 1664525) + j + seed[j] & PAD_32_BITS
80
+ if (i+=1) >= STATE_SIZE
81
+ @state[0] = @state[-1]
82
+ i = 1
83
+ end
84
+ j = 0 if (j+=1) >= seed.size
85
+ end
86
+ (STATE_SIZE-1).times do
87
+ @state[i] = (@state[i] ^ (@state[i-1] ^ @state[i-1]>>30) * 1566083941) - i & PAD_32_BITS
88
+ if (i+=1) >= STATE_SIZE
89
+ @state[0] = @state[-1]
90
+ i = 1
91
+ end
92
+ end
93
+ @state[0] = 0x80000000
94
+ else
95
+ raise ArgumentError, "Seed must be an Integer or an Array"
96
+ end
97
+ end
98
+
99
+ # Returns a random Integer from the range 0 ... (1 << 32)
100
+ def random_32_bits
101
+ next_state if @last_read >= LAST_STATE
102
+ @last_read += 1
103
+ y = @state[@last_read]
104
+ # Tempering
105
+ y ^= (y >> 11)
106
+ y ^= (y << 7) & 0x9d2c5680
107
+ y ^= (y << 15) & 0xefc60000
108
+ y ^= (y >> 18)
109
+ end
110
+
111
+ # Supplement the MT19937 class with methods to do
112
+ # conversions the same way as MRI.
113
+ # No argument checking is done here either.
114
+
115
+ FLOAT_FACTOR = 1.0/9007199254740992.0
116
+ # generates a random number on [0,1) with 53-bit resolution
117
+ def random_float
118
+ ((random_32_bits >> 5) * 67108864.0 + (random_32_bits >> 6)) * FLOAT_FACTOR;
119
+ end
120
+
121
+ # Returns an integer within 0...upto
122
+ def random_integer(upto)
123
+ n = upto - 1
124
+ nb_full_32 = 0
125
+ while n > PAD_32_BITS
126
+ n >>= 32
127
+ nb_full_32 += 1
128
+ end
129
+ mask = mask_32_bits(n)
130
+ begin
131
+ rand = random_32_bits & mask
132
+ nb_full_32.times do
133
+ rand <<= 32
134
+ rand |= random_32_bits
135
+ end
136
+ end until rand < upto
137
+ rand
138
+ end
139
+
140
+ def random_bytes(nb)
141
+ nb_32_bits = (nb + 3) / 4
142
+ random = nb_32_bits.times.map { random_32_bits }
143
+ random.pack("L" * nb_32_bits)[0, nb]
144
+ end
145
+
146
+ def state_as_bignum
147
+ b = 0
148
+ @state.each_with_index do |val, i|
149
+ b |= val << (32 * i)
150
+ end
151
+ b
152
+ end
153
+
154
+ def left # It's actually the number of words left + 1, as per MRI...
155
+ MT19937::STATE_SIZE - @last_read
156
+ end
157
+
158
+ def marshal_dump
159
+ [state_as_bignum, left]
160
+ end
161
+
162
+ def marshal_load(ary)
163
+ b, left = ary
164
+ @last_read = MT19937::STATE_SIZE - left
165
+ @state = Array.new(STATE_SIZE)
166
+ STATE_SIZE.times do |i|
167
+ @state[i] = b & PAD_32_BITS
168
+ b >>= 32
169
+ end
170
+ end
171
+
172
+ # Convert an Integer seed of arbitrary size to either a single 32 bit integer, or an Array of 32 bit integers
173
+ def self.convert_seed(seed)
174
+ seed = seed.abs
175
+ long_values = []
176
+ begin
177
+ long_values << (seed & PAD_32_BITS)
178
+ seed >>= 32
179
+ end until seed == 0
180
+
181
+ long_values.pop if long_values[-1] == 1 && long_values.size > 1 # Done to allow any kind of sequence of integers
182
+
183
+ long_values.size > 1 ? long_values : long_values.first
184
+ end
185
+
186
+ def self.[](seed)
187
+ new(convert_seed(seed))
188
+ end
189
+
190
+ private
191
+
192
+ MASK_BY = [1,2,4,8,16]
193
+ def mask_32_bits(n)
194
+ MASK_BY.each do |shift|
195
+ n |= n >> shift
196
+ end
197
+ n
198
+ end
199
+ end
200
+
201
+ # Implementation corresponding to the actual Random class of Ruby
202
+ # The actual random generator (mersenne twister) is in MT19937.
203
+ # Ruby specific conversions are handled in bits_and_bytes.
204
+ # The high level stuff (argument checking) is done here.
205
+ module Implementation
206
+ attr_reader :seed
207
+
208
+ def initialize(seed = 0)
209
+ super()
210
+ seed_rand seed
211
+ end
212
+
213
+ def seed_rand(new_seed = 0)
214
+ new_seed = Backports.coerce_to_int(new_seed)
215
+ @seed = nil unless defined?(@seed)
216
+ old, @seed = @seed, new_seed.nonzero? || Random.new_seed
217
+ @mt = MT19937[ @seed ]
218
+ old
219
+ end
220
+
221
+ def rand(limit = Backports::Undefined)
222
+ case limit
223
+ when Backports::Undefined
224
+ @mt.random_float
225
+ when Float
226
+ limit * @mt.random_float unless limit <= 0
227
+ when Range
228
+ _rand_range(limit)
229
+ else
230
+ limit = Backports.coerce_to_int(limit)
231
+ @mt.random_integer(limit) unless limit <= 0
232
+ end || raise(ArgumentError, "invalid argument #{limit}")
233
+ end
234
+
235
+ def bytes(nb)
236
+ nb = Backports.coerce_to_int(nb)
237
+ raise ArgumentError, "negative size" if nb < 0
238
+ @mt.random_bytes(nb)
239
+ end
240
+
241
+ def ==(other)
242
+ other.is_a?(Random) &&
243
+ seed == other.seed &&
244
+ left == other.send(:left) &&
245
+ state == other.send(:state)
246
+ end
247
+
248
+ def marshal_dump
249
+ @mt.marshal_dump << @seed
250
+ end
251
+
252
+ def marshal_load(ary)
253
+ @seed = ary.pop
254
+ @mt = MT19937.allocate
255
+ @mt.marshal_load(ary)
256
+ end
257
+
258
+ private
259
+
260
+ def state
261
+ @mt.state_as_bignum
262
+ end
263
+
264
+ def left
265
+ @mt.left
266
+ end
267
+
268
+ def _rand_range(limit)
269
+ range = limit.end - limit.begin
270
+ if (!range.is_a?(Float)) && range.respond_to?(:to_int) && range = Backports.coerce_to_int(range)
271
+ range += 1 unless limit.exclude_end?
272
+ limit.begin + @mt.random_integer(range) unless range <= 0
273
+ elsif range = Backports.coerce_to(range, Float, :to_f)
274
+ if range < 0
275
+ nil
276
+ elsif limit.exclude_end?
277
+ limit.begin + @mt.random_float * range unless range <= 0
278
+ else
279
+ # cheat a bit... this will reduce the nb of random bits
280
+ loop do
281
+ r = @mt.random_float * range * 1.0001
282
+ break limit.begin + r unless r > range
283
+ end
284
+ end
285
+ end
286
+ end
287
+ end
288
+
289
+ def self.new_seed
290
+ (2 ** 62) + Kernel.rand(2 ** 62)
291
+ end
292
+ end
293
+
294
+ class Random
295
+ include Implementation
296
+ class << self
297
+ include Implementation
298
+ end
299
+ end
300
+ end
301
+ end
302
+ end
@@ -0,0 +1,65 @@
1
+ module RSpec
2
+ module Core
3
+ class BacktraceFormatter
4
+ # This is only used externally by rspec-expectations. Can be removed once
5
+ # rspec-expectations uses
6
+ # RSpec.configuration.backtrace_formatter.format_backtrace instead.
7
+ def self.format_backtrace(backtrace, options = {})
8
+ RSpec.configuration.backtrace_formatter.format_backtrace(backtrace, options)
9
+ end
10
+
11
+ attr_accessor :exclusion_patterns, :inclusion_patterns
12
+
13
+ def initialize
14
+ @full_backtrace = false
15
+ @exclusion_patterns = [] << Regexp.union(
16
+ *["/lib\d*/ruby/",
17
+ "org/jruby/",
18
+ "bin/",
19
+ "/gems/",
20
+ "lib/rspec/(core|expectations|matchers|mocks)"].
21
+ map {|s| Regexp.new(s.gsub("/", File::SEPARATOR))}
22
+ )
23
+ @inclusion_patterns = [Regexp.new(Dir.getwd)]
24
+ end
25
+
26
+ def full_backtrace=(full_backtrace)
27
+ @full_backtrace = full_backtrace
28
+ end
29
+
30
+ def full_backtrace?
31
+ @full_backtrace || @exclusion_patterns.empty?
32
+ end
33
+
34
+ def format_backtrace(backtrace, options = {})
35
+ return backtrace if options[:full_backtrace]
36
+ backtrace.
37
+ take_while {|l| l != RSpec::Core::Runner::AT_EXIT_HOOK_BACKTRACE_LINE}.
38
+ map {|l| backtrace_line(l)}.
39
+ compact.
40
+ tap do |filtered|
41
+ if filtered.empty?
42
+ filtered.concat backtrace
43
+ filtered << ""
44
+ filtered << " Showing full backtrace because every line was filtered out."
45
+ filtered << " See docs for RSpec::Configuration#backtrace_exclusion_patterns and"
46
+ filtered << " RSpec::Configuration#backtrace_inclusion_patterns for more information."
47
+ end
48
+ end
49
+ end
50
+
51
+ # @api private
52
+ def backtrace_line(line)
53
+ RSpec::Core::Metadata::relative_path(line) unless exclude?(line)
54
+ rescue SecurityError
55
+ nil
56
+ end
57
+
58
+ # @api private
59
+ def exclude?(line)
60
+ return false if @full_backtrace
61
+ @exclusion_patterns.any? {|p| p =~ line} && @inclusion_patterns.none? {|p| p =~ line}
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,36 @@
1
+ module RSpec
2
+ module Core
3
+ class CommandLine
4
+ def initialize(options, configuration=RSpec::configuration, world=RSpec::world)
5
+ if Array === options
6
+ options = ConfigurationOptions.new(options)
7
+ options.parse_options
8
+ end
9
+ @options = options
10
+ @configuration = configuration
11
+ @world = world
12
+ end
13
+
14
+ # Configures and runs a suite
15
+ #
16
+ # @param [IO] err
17
+ # @param [IO] out
18
+ def run(err, out)
19
+ @configuration.error_stream = err
20
+ @configuration.output_stream = out if @configuration.output_stream == $stdout
21
+ @options.configure(@configuration)
22
+ @configuration.load_spec_files
23
+ @world.announce_filters
24
+
25
+ @configuration.reporter.report(@world.example_count) do |reporter|
26
+ begin
27
+ @configuration.run_hook(:before, :suite)
28
+ @world.ordered_example_groups.map {|g| g.run(reporter) }.all? ? 0 : @configuration.failure_exit_code
29
+ ensure
30
+ @configuration.run_hook(:after, :suite)
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end