mrspec 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c9b7422e1ee184d93d1efcb320e1d66d95261d72
4
- data.tar.gz: 2cb80072ccc287fce0ae9deeeaf5e4cf7714f755
3
+ metadata.gz: 4c2fcc823e51b94b52dba0d39f0b2440519373e8
4
+ data.tar.gz: 4ab34320cf0c8d6bba5726ba562276980ab711d4
5
5
  SHA512:
6
- metadata.gz: a4f44abb23f546d633264ad6d0f91d769cb8e56afc3c92051c4371bc2c5ae582f80aef74dae65ca1349d839775316fe0bc9311501c26e1019e02d7ee54ddc3f5
7
- data.tar.gz: 5d7e7dc0778e64e6d6269caf5b03930a5d09d24f0fc6844fabfecad914dd53edc9c07ce98863f18fe29890a399a83de7f1f0b2c55d44c201538daad5333c21cd
6
+ metadata.gz: f5d9fa09313eb832dcabdafb817a8778f1ba6cd416287d0fca519122cb303afad9f011d799e5bf8140590b0d41bb7b63e02dfe2ab4d2c0f8528f0bc144e071c8
7
+ data.tar.gz: d8a9f3f30ef85c8e552230e91a3abd16e65848efeb9916a9a2cfb35772341d6ad4eb18c0454a1082cf4c08ad9ea342c57161b9e1c08fac7fdbd4a4241ee5d326
@@ -88,6 +88,39 @@ Feature: mrspec
88
88
  And stdout does not include "Minitest.run_one_method"
89
89
 
90
90
 
91
+ Scenario: Minitest::Spec definitions without bodies show line of the declaration in the backtrace, and not the full backtrace
92
+ Given the file "skip_spec.rb":
93
+ """
94
+ require 'minitest/spec'
95
+ describe 'a' do
96
+ it 'has no body'
97
+ it('calls skip') { skip }
98
+ end
99
+
100
+ class A < Minitest::Spec
101
+ it 'has no body'
102
+ it('calls skip') { skip }
103
+ end
104
+
105
+ class Wat < Minitest::Test
106
+ extend Minitest::Spec::DSL
107
+ register_spec_type /^lol/, self
108
+ end
109
+ describe 'lol' do
110
+ it 'has no body'
111
+ it('calls skip') { skip }
112
+ end
113
+ """
114
+ When I run "mrspec skip_spec.rb"
115
+ Then stdout includes "skip_spec.rb:3"
116
+ Then stdout includes "skip_spec.rb:4"
117
+ Then stdout includes "skip_spec.rb:8"
118
+ Then stdout includes "skip_spec.rb:9"
119
+ Then stdout includes "skip_spec.rb:17"
120
+ Then stdout includes "skip_spec.rb:18"
121
+ And stdout does not include "/mrspec/"
122
+
123
+
91
124
  Scenario: Works with Minitest::Test, choosing intelligent names
92
125
  Given the file "some_test.rb":
93
126
  """
@@ -313,6 +346,47 @@ Feature: mrspec
313
346
  And stdout includes "tagged with 1 only"
314
347
  And stdout includes "untagged"
315
348
 
349
+
350
+ Scenario: Can add metadata to Minitest::Specs
351
+ Given the file "a_spec.rb":
352
+ """
353
+ require 'minitest/spec'
354
+
355
+ describe 'First' do
356
+ classmeta runthis: true
357
+ it('spec1') { }
358
+ end
359
+
360
+ class MySpec < Minitest::Spec
361
+ meta runthis: true
362
+ it('spec2') { }
363
+ it('spec3') { }
364
+ it('spec4') { }
365
+ end
366
+
367
+ class Wat < Minitest::Test
368
+ extend Minitest::Spec::DSL
369
+ register_spec_type /^Lol/, self
370
+
371
+ def bbq
372
+ 'rofl'
373
+ end
374
+ end
375
+
376
+ describe 'LolSpec!' do
377
+ meta runthis: true
378
+ it 'has different inheritance' do
379
+ assert self.kind_of? Wat
380
+ end
381
+ end
382
+ """
383
+ When I run 'mrspec -t runthis a_spec.rb'
384
+ Then the program ran successfully
385
+ And stdout includes "3 examples"
386
+ And stdout includes "0 failures"
387
+
388
+
389
+
316
390
  Scenario: Intelligently formats Minitest's assertions
317
391
  Given the file "test/some_assertions.rb":
318
392
  """
@@ -1,6 +1,7 @@
1
1
  require 'minitest'
2
2
  require 'mrspec/minitest_assertion_for_rspec'
3
3
 
4
+
4
5
  module MRspec
5
6
  module DeclareMinitests
6
7
  extend self
@@ -46,7 +47,7 @@ module MRspec
46
47
 
47
48
  def wrap_test(example_group, klass, mname)
48
49
  metadata = klass.example_metadata[mname.intern]
49
- example = example_group.example example_name(mname), metadata do
50
+ example = example_group.example example_name(mname), metadata do
50
51
  instance = Minitest.run_one_method klass, mname
51
52
  next if instance.passed?
52
53
  pending 'skipped' if instance.skipped?
@@ -0,0 +1,21 @@
1
+ # Monkey in the middleing Minitest::Spec::DSL#it,
2
+ # and aliases to record the block in the user's code,
3
+ # this way the backtrace lines up with the logical definition site,
4
+ # and we don't risk filtering the entire backtrace
5
+ # which causes RSpec to not filter,
6
+ # and the entire backtrace is quite distracting
7
+ require 'minitest/spec'
8
+ dsl = Minitest::Spec::DSL
9
+ it_location = dsl.instance_method(:it).source_location
10
+ dsl.instance_methods
11
+ .map { |name| [name, dsl.instance_method(name)] }
12
+ .select { |name, method| method.source_location == it_location }
13
+ .each { |name, method|
14
+ dsl.__send__ :define_method, name do |*args, &block|
15
+ callsite = caller[0] || 'unknown-location:0:' # can't think of a situation where this wouldn't be true, but just in case
16
+ callsite =~ /^(.*?):(\d+):/
17
+ caller_filename, caller_lineno = $1, $2.to_i
18
+ block ||= eval 'proc { skip "(no tests defined)" }', binding, caller_filename, caller_lineno
19
+ method.bind(self).call(*args, &block)
20
+ end
21
+ }
@@ -1,3 +1,3 @@
1
1
  module MRspec
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
data/lib/mrspec.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'mrspec/version'
2
2
  require 'mrspec/minitest_metadata'
3
+ require 'mrspec/fix_backtraces_on_minitest_spec'
3
4
  require 'mrspec/runner'
4
5
  require 'mrspec/configuration'
5
6
  require 'mrspec/option_parser'
data/test/test_mrspec.rb CHANGED
@@ -155,6 +155,7 @@ class TestMRspec < Minitest::Spec
155
155
  it 'omits minitest code from the backtrace'
156
156
  it 'omits rspec code from the backtrace'
157
157
  it 'omits mrspec code from the backtrace'
158
+ it 'allows Minitest::Spec to be declared without bodies, and backtrace shows the call to the it block'
158
159
  end
159
160
 
160
161
  describe 'identifying which test to run' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mrspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Cheek
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-26 00:00:00.000000000 Z
11
+ date: 2015-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec-core
@@ -93,6 +93,7 @@ files:
93
93
  - lib/mrspec.rb
94
94
  - lib/mrspec/configuration.rb
95
95
  - lib/mrspec/declare_minitests.rb
96
+ - lib/mrspec/fix_backtraces_on_minitest_spec.rb
96
97
  - lib/mrspec/minitest_assertion_for_rspec.rb
97
98
  - lib/mrspec/minitest_metadata.rb
98
99
  - lib/mrspec/option_parser.rb