minispec-metadata 2.0.0 → 3.0.0

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: 3b3e8197843d0b0115644bd53b223e5cf1855d17
4
- data.tar.gz: 2d74dd7985cfa56a119b3e354fefb314df0a14a0
3
+ metadata.gz: 38ce1b63b96b84af69f5727f5eb38d963fe75e99
4
+ data.tar.gz: a8ac8f3f33abc5350eb57d50dd325668121e3803
5
5
  SHA512:
6
- metadata.gz: 32bb94f89f459d02737b0bf1697b7aed6eed25de6225c46c3a0805bb7b77d7a0393e98a4738fe989fd44d59924e4c9c8a92339a4a15f3813991ed45c9be605c1
7
- data.tar.gz: f47ca8c8c4798c238f82282c6bb69b8f0d05bd3bb10ada125aa9f1b6baf15667d0c3a012da02f7d98eef2fe85efc1a3aab92e5f8ce068e07a62b686a414a23cc
6
+ metadata.gz: 341212cc6062f980ddee800d6a17f8c4d0103f6e7d98f6acb7bacaa2a10ef7670f0c75a910e06943329c40a640b3b6bbee14343a40db7b2f90d05e87c3b28df9
7
+ data.tar.gz: 607554c3ddc34877eba6fb2cf1810e2deab07d354448512177de7196588b2d5450aa323cde58fa637764b9f0263fd00b7212842ee0c8c5d1ce603ca659f837ac
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ ruby-2.1.2
data/.travis.yml CHANGED
@@ -3,6 +3,7 @@ rvm:
3
3
  - 1.9.2
4
4
  - 1.9.3
5
5
  - 2.0.0
6
+ - 2.1.2
6
7
 
7
8
  script: bundle exec rake
8
9
 
data/CHANGELOG.md ADDED
@@ -0,0 +1,8 @@
1
+ ## 3.0.0
2
+
3
+ * Total rewrite.
4
+ * Fix bug with `it` clashing with `describe` when they were on the same level. (@jrochkind)
5
+ * Remove `spec_description`. Just use `self.class.desc`
6
+ * Rename `spec_descriptions` to `descs` (to try to stay close to Minitest naming) and moved it to the spec class level.
7
+ * Rename `spec_additional_description` to `additional_desc` (that's what Minitest calls it) and moved it to the spec class level.
8
+ * Rename `MiniSpec` to `Minispec`. The gem is named like it should be camel-cased this way.
data/README.md CHANGED
@@ -8,6 +8,7 @@ https://github.com/ordinaryzelig/minispec-metadata
8
8
  ## Usage
9
9
 
10
10
  ```ruby
11
+ # readme.spec.rb
11
12
  require 'minitest/autorun'
12
13
  require 'minispec-metadata'
13
14
 
@@ -31,24 +32,23 @@ describe 'Usage', some: 'metadata' do
31
32
  )
32
33
  end
33
34
 
34
- it 'provides a method to get the name of the spec' do
35
- spec_name.must_equal 'provides a method to get the name of the spec'
35
+ it 'provides a method to get the description of the spec' do
36
+ desc.must_equal 'provides a method to get the description of the spec'
36
37
  end
37
38
 
38
- describe MiniSpecMetadata::DescribeWithMetadata, 'additional description' do
39
+ describe MinispecMetadata, 'additional description' do
39
40
 
40
41
  it 'provides a method to get the descriptions' do
41
- spec_descriptions.must_equal [MiniSpecMetadata::DescribeWithMetadata, 'additional description']
42
+ self.class.descs.must_equal [MinispecMetadata, 'additional description']
42
43
  end
43
44
 
44
- # I say "shortcut" because you can easily get this without this gem via
45
- # self.class.desc
46
- it 'provides a shortcut to get the main description' do
47
- spec_description.must_equal MiniSpecMetadata::DescribeWithMetadata
45
+ it 'provides a method to get only the additional description' do
46
+ self.class.additional_desc.must_equal ['additional description']
48
47
  end
49
48
 
50
- it 'provides a method to get only the additional description' do
51
- spec_additional_description.must_equal 'additional description'
49
+ it 'is not needed to get the described object' do
50
+ # This is built in to Minitest, you don't need this gem to do this.
51
+ self.class.desc.must_equal MinispecMetadata
52
52
  end
53
53
 
54
54
  end
@@ -68,7 +68,7 @@ Another great use is to do a version of [Ryan Bates' VCR trick](http://railscast
68
68
  ```ruby
69
69
  describe 'VCR trick' do
70
70
  it 'allows you to name your cassettes the same as the spec' do
71
- VCR.use_cassette spec_name do
71
+ VCR.use_cassette desc do
72
72
  end
73
73
  end
74
74
  end
@@ -90,7 +90,7 @@ Or install it yourself:
90
90
 
91
91
  ## Additional description gotcha
92
92
 
93
- By default, Minitest allows 2 descriptions:
93
+ In Minitest <= 4, Minitest allows 2 descriptions:
94
94
 
95
95
  ```ruby
96
96
  describe 'Description 1', 'Description 2'
@@ -108,3 +108,9 @@ But in pure Minitest, it would have been used as the additional description.
108
108
  I personally have never seen anybody use the additional description,
109
109
  and I think the "symbols as metadata" feature is more useful.
110
110
  So I allowed this breakage of Minitest behavior.
111
+
112
+ ## Compatibility
113
+
114
+ Tested with Minitest 4 and up.
115
+ Might work with older versions but I haven't tested them.
116
+ See .travis to see Ruby versions tested.
@@ -7,3 +7,12 @@ if MiniTest.const_defined?(:Unit)
7
7
  end
8
8
  end
9
9
  end
10
+
11
+ # Y U NO Ruby 2.0????
12
+ unless Kernel.public_method_defined? :__dir__
13
+ module Kernel
14
+ def __dir__
15
+ File.dirname(File.expand_path(__FILE__))
16
+ end
17
+ end
18
+ end
@@ -1,9 +1,30 @@
1
1
  require 'minitest/spec'
2
- require_relative 'core_extensions'
2
+ require_relative 'backwards'
3
3
 
4
4
  require "minispec-metadata/version"
5
- require 'minispec-metadata/describe_with_metadata'
6
- require 'minispec-metadata/spec_with_metadata'
7
5
 
8
- module MiniSpecMetadata
6
+ require 'minispec-metadata/it'
7
+ require 'minispec-metadata/describe'
8
+
9
+ module MinispecMetadata
10
+
11
+ module_function
12
+
13
+ def extract_metadata!(args)
14
+ metadata = {}
15
+ args.delete_if do |arg|
16
+ case arg
17
+ when Hash
18
+ metadata.merge! arg
19
+ when Symbol
20
+ metadata.merge!(arg => true)
21
+ else
22
+ false
23
+ end
24
+ end
25
+ metadata
26
+ end
27
+
9
28
  end
29
+
30
+ MiniSpecMetadata = MinispecMetadata
@@ -0,0 +1,47 @@
1
+ module MinispecMetadata
2
+ module Describe
3
+
4
+ def describe(desc, *additional_desc, &block)
5
+ metadata = MinispecMetadata.extract_metadata! additional_desc
6
+
7
+ cls = super(desc, *additional_desc, &block)
8
+ cls.extend ClassMethods
9
+
10
+ cls.additional_desc = additional_desc
11
+ cls.describe_metadata = metadata || {}
12
+
13
+ cls
14
+ end
15
+
16
+ module ClassMethods
17
+
18
+ attr_reader :additional_desc
19
+
20
+ def describe_metadata
21
+ super_describe_metadata =
22
+ if superclass.respond_to? :describe_metadata
23
+ superclass.describe_metadata
24
+ else
25
+ {}
26
+ end
27
+ super_describe_metadata.merge(@describe_metadata)
28
+ end
29
+
30
+ def descs
31
+ [desc, *additional_desc].compact
32
+ end
33
+
34
+ def additional_desc=(additional_desc)
35
+ @additional_desc = additional_desc.freeze
36
+ end
37
+
38
+ def describe_metadata=(metadata)
39
+ @describe_metadata = metadata.freeze
40
+ end
41
+
42
+ end
43
+
44
+ end
45
+ end
46
+
47
+ Object.send :include, MinispecMetadata::Describe
@@ -1,4 +1,4 @@
1
- module MiniSpecMetadata
1
+ module MinispecMetadata
2
2
  module DescribeWithMetadata
3
3
 
4
4
  def describe(desc, *_args, &block)
@@ -42,4 +42,4 @@ module MiniSpecMetadata
42
42
  end
43
43
  end
44
44
 
45
- Object.send :include, MiniSpecMetadata::DescribeWithMetadata
45
+ Object.send :include, MinispecMetadata::DescribeWithMetadata
@@ -0,0 +1,45 @@
1
+ module MinispecMetadata
2
+ module It
3
+
4
+ def self.included(spec_class)
5
+ spec_class.extend ClassMethods
6
+ end
7
+
8
+ module ClassMethods
9
+
10
+ def it(description, *metadata, &block)
11
+ name = super description, &block
12
+
13
+ metadata = MinispecMetadata.extract_metadata!(metadata)
14
+
15
+ self.it_descriptions[name] = description
16
+ self.metadata_by_test_name[name] = metadata
17
+
18
+ name
19
+ end
20
+ alias_method :specify, :it
21
+
22
+ def metadata_by_test_name
23
+ @metadata_by_test_name ||= {}
24
+ end
25
+
26
+ def it_descriptions
27
+ @it_descriptions ||= {}
28
+ end
29
+
30
+ end
31
+
32
+ def metadata
33
+ self.class.describe_metadata.merge(
34
+ self.class.metadata_by_test_name.fetch(name)
35
+ )
36
+ end
37
+
38
+ def desc
39
+ self.class.it_descriptions.fetch(name)
40
+ end
41
+
42
+ end
43
+ end
44
+
45
+ Minitest::Spec.send :include, MinispecMetadata::It
@@ -1,4 +1,4 @@
1
- module MiniSpecMetadata
1
+ module MinispecMetadata
2
2
  module SpecWithMetadata
3
3
 
4
4
  def self.included(spec_class)
@@ -63,4 +63,4 @@ module MiniSpecMetadata
63
63
  end
64
64
  end
65
65
 
66
- MiniTest::Spec.send :include, MiniSpecMetadata::SpecWithMetadata
66
+ MiniTest::Spec.send :include, MinispecMetadata::SpecWithMetadata
@@ -1,3 +1,3 @@
1
- module MiniSpecMetadata
2
- VERSION = "2.0.0"
1
+ module MinispecMetadata
2
+ VERSION = "3.0.0"
3
3
  end
@@ -5,7 +5,7 @@ require 'minispec-metadata/version'
5
5
 
6
6
  Gem::Specification.new do |gem|
7
7
  gem.name = "minispec-metadata"
8
- gem.version = MiniSpecMetadata::VERSION
8
+ gem.version = MinispecMetadata::VERSION
9
9
  gem.authors = ["Jared Ning"]
10
10
  gem.email = ["jared@redningja.com"]
11
11
  gem.description = %q{MiniTest::Spec metadata}
@@ -0,0 +1,130 @@
1
+ require_relative 'helper'
2
+
3
+ describe MinispecMetadata::Describe, super_meta: 'data' do
4
+
5
+ describe 'as 2nd arg after description', second: '2nd' do
6
+
7
+ it 'is accessible with metadata method' do
8
+ metadata.fetch(:second).must_equal '2nd'
9
+ end
10
+
11
+ end
12
+
13
+ describe 'as 3rd arg after additional description', 'more description', third: '3rd' do
14
+
15
+ it 'is accessible with metadata method' do
16
+ metadata.fetch(:third).must_equal '3rd'
17
+ end
18
+
19
+ end
20
+
21
+ describe 'when just a symbol is passed', :axiom, :vcr do
22
+ it 'uses symbols as true values' do
23
+ metadata.fetch(:axiom).must_equal true
24
+ metadata.fetch(:vcr).must_equal true
25
+ end
26
+ end
27
+
28
+ describe 'duplicate', first: '1st' do
29
+
30
+ it 'correctly scopes metadata to current description' do
31
+ metadata.must_equal(first: '1st', super_meta: 'data')
32
+ metadata.key?(:second).must_equal false
33
+ end
34
+
35
+ end
36
+
37
+ describe 'duplicate', second: '2nd' do
38
+
39
+ it 'correctly scopes metadata to current description' do
40
+ metadata.must_equal(second: '2nd', super_meta: 'data')
41
+ metadata.key?(:first).must_equal false
42
+ end
43
+
44
+ end
45
+
46
+ describe 'nested', sub: 'desc' do
47
+
48
+ it 'inherits from surrounding description', lowest: 'totem' do
49
+ metadata.must_equal(
50
+ super_meta: 'data',
51
+ sub: 'desc',
52
+ lowest: 'totem',
53
+ )
54
+ end
55
+
56
+ it 'gives nearest metadata priority', sub: 'zero', super_meta: 'priority' do
57
+ metadata.must_equal(
58
+ sub: 'zero',
59
+ super_meta: 'priority',
60
+ )
61
+ end
62
+
63
+ end
64
+
65
+ desc_class = describe 'return value' do
66
+
67
+ it 'equals description class' do
68
+ desc_class.must_equal self.class
69
+ end
70
+
71
+ end
72
+
73
+ end
74
+
75
+ if MiniTest.const_defined?(:Unit) # Minitest version 4 (maybe before too?)
76
+
77
+ # Only allows 1 additional description.
78
+ describe MinispecMetadata::Describe, 'additional description' do
79
+
80
+ it 'provides a method to get the descriptions' do
81
+ self.class.descs.must_equal [MinispecMetadata::Describe, 'additional description']
82
+ end
83
+
84
+ it 'provides a method to get only the additional description' do
85
+ self.class.additional_desc.must_equal ['additional description']
86
+ end
87
+
88
+ describe 'nested describe with no additional description' do
89
+
90
+ it 'does not inherit additional description from parent' do
91
+ self.class.additional_desc.must_be_empty
92
+ end
93
+
94
+ end
95
+
96
+ end
97
+
98
+ else
99
+
100
+ # Minitest version 5
101
+ describe MinispecMetadata::Describe, 'additional description', 'even more' do
102
+
103
+ it 'provides a method to get the descriptions' do
104
+ self.class.descs.must_equal [MinispecMetadata::Describe, 'additional description', 'even more']
105
+ end
106
+
107
+ it 'provides a method to get only the additional description' do
108
+ self.class.additional_desc.must_equal ['additional description', 'even more']
109
+ end
110
+
111
+ describe 'nested describe with no additional description' do
112
+
113
+ it 'does not inherit additional description from parent' do
114
+ self.class.additional_desc.must_be_empty
115
+ end
116
+
117
+ end
118
+
119
+ end
120
+
121
+ end
122
+
123
+ describe MinispecMetadata::Describe, 'additional description', :respect do
124
+
125
+ it 'respects additional description' do
126
+ self.class.name.must_equal 'MinispecMetadata::Describe::additional description'
127
+ metadata.must_equal(respect: true)
128
+ end
129
+
130
+ end
data/spec/it.spec.rb ADDED
@@ -0,0 +1,78 @@
1
+ require_relative 'helper'
2
+
3
+ describe MinispecMetadata::It do
4
+
5
+ it 'stores metadata for current spec', meta: 'data' do
6
+ metadata.fetch(:meta).must_equal 'data'
7
+ end
8
+
9
+ specify 'it works with #specify', 1 => 2 do
10
+ metadata.fetch(1).must_equal 2
11
+ end
12
+
13
+ it 'returns empty hash when no metadata set' do
14
+ metadata.must_equal({})
15
+ end
16
+
17
+ name = it 'returns name' do
18
+ name.must_match /test_/
19
+ end
20
+
21
+ describe 'before/after hooks' do
22
+
23
+ before do
24
+ metadata.fetch(:before).must_equal 'accessible'
25
+ end
26
+
27
+ it 'is accessible in hooks', before: 'accessible', after: 'also accessible' do
28
+ pass
29
+ end
30
+
31
+ after do
32
+ metadata.fetch(:after).must_equal 'also accessible'
33
+ end
34
+
35
+ end
36
+
37
+ describe 'with description metadata', description_meta: 'data' do
38
+
39
+ it 'inherits metadata from description' do
40
+ metadata.fetch(:description_meta).must_equal 'data'
41
+ end
42
+
43
+ it "uses symbols as true values", :verity, :words_are_hard do
44
+ metadata.must_equal(
45
+ description_meta: 'data',
46
+ verity: true,
47
+ words_are_hard: true,
48
+ )
49
+ end
50
+
51
+ describe 'in a nested describe', 'with no metadata' do
52
+
53
+ it 'works', works: true do
54
+ metadata.must_equal(description_meta: 'data', works: true)
55
+ end
56
+
57
+ end
58
+
59
+ describe 'in a nested describe', with_metadata: true do
60
+
61
+ it 'works', works: true do
62
+ metadata.must_equal(works: true, with_metadata: true, description_meta: 'data')
63
+ end
64
+
65
+ end
66
+
67
+ end
68
+
69
+ end
70
+
71
+ describe MinispecMetadata::It, '#desc' do
72
+
73
+ it 'provides a method to get the name of the spec' do
74
+ desc.must_equal 'provides a method to get the name of the spec'
75
+ end
76
+
77
+ end
78
+
@@ -0,0 +1,30 @@
1
+ require_relative 'helper'
2
+
3
+ describe MinispecMetadata do
4
+
5
+ describe '#extract_metadata!' do
6
+
7
+ it 'extracts from a hash' do
8
+ metadata = MinispecMetadata.extract_metadata! [{asdf: true}]
9
+ metadata.must_equal asdf: true
10
+ end
11
+
12
+ it 'extracts from symbols, returns hash keys with true values' do
13
+ metadata = MinispecMetadata.extract_metadata! [:asdf, :fdsa]
14
+ metadata.must_equal asdf: true, fdsa: true
15
+ end
16
+
17
+ it 'extracts a mix' do
18
+ metadata = MinispecMetadata.extract_metadata! [:asdf, {fdsa: true}]
19
+ metadata.must_equal asdf: true, fdsa: true
20
+ end
21
+
22
+ it 'descructively removes metadata from args' do
23
+ args = [:asdf, 'description']
24
+ metadata = MinispecMetadata.extract_metadata! args
25
+ args.must_equal ['description']
26
+ end
27
+
28
+ end
29
+
30
+ end
@@ -0,0 +1,9 @@
1
+ require_relative 'helper'
2
+
3
+ readme = File.readlines(__dir__ + '/../README.md').map(&:chomp)
4
+ specs =
5
+ readme.select do |line, idx|
6
+ true if (line == '# readme.spec.rb')..(line == '```')
7
+ end[0...-1]
8
+ .join("\n")
9
+ instance_eval specs
@@ -0,0 +1,18 @@
1
+ require_relative 'helper'
2
+
3
+ # Confirmed to not work with v2.0.0.
4
+ # Thanks to @jrochkind.
5
+ describe "top level describe" do
6
+ describe "an inner describe" do
7
+ before do
8
+ desc.wont_be_nil
9
+ end
10
+ it "an example inside inner describe" do
11
+ desc.must_equal 'an example inside inner describe'
12
+ end
13
+ end
14
+
15
+ it "another top level example" do
16
+ desc.must_equal 'another top level example'
17
+ end
18
+ end
metadata CHANGED
@@ -1,55 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minispec-metadata
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jared Ning
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-14 00:00:00.000000000 Z
11
+ date: 2014-12-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: awesome_print
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  description: MiniTest::Spec metadata
@@ -59,23 +59,29 @@ executables: []
59
59
  extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
- - .gitignore
63
- - .rvmrc
64
- - .travis.yml
62
+ - ".gitignore"
63
+ - ".ruby-version"
64
+ - ".travis.yml"
65
+ - CHANGELOG.md
65
66
  - Gemfile
66
67
  - LICENSE.txt
67
68
  - README.md
68
69
  - Rakefile
69
70
  - gemfiles/minitest-4.gemfile
70
- - lib/core_extensions.rb
71
+ - lib/backwards.rb
71
72
  - lib/minispec-metadata.rb
73
+ - lib/minispec-metadata/describe.rb
72
74
  - lib/minispec-metadata/describe_with_metadata.rb
75
+ - lib/minispec-metadata/it.rb
73
76
  - lib/minispec-metadata/spec_with_metadata.rb
74
77
  - lib/minispec-metadata/version.rb
75
78
  - minispec-metadata.gemspec
76
- - spec/describe_with_metadata.spec.rb
79
+ - spec/describe.spec.rb
77
80
  - spec/helper.rb
78
- - spec/spec_with_metadata.spec.rb
81
+ - spec/it.spec.rb
82
+ - spec/minispec_metadata.spec.rb
83
+ - spec/readme.spec.rb
84
+ - spec/regression.spec.rb
79
85
  homepage: https://github.com/ordinaryzelig/minispec-metadata
80
86
  licenses:
81
87
  - MIT
@@ -86,21 +92,24 @@ require_paths:
86
92
  - lib
87
93
  required_ruby_version: !ruby/object:Gem::Requirement
88
94
  requirements:
89
- - - '>='
95
+ - - ">="
90
96
  - !ruby/object:Gem::Version
91
97
  version: '0'
92
98
  required_rubygems_version: !ruby/object:Gem::Requirement
93
99
  requirements:
94
- - - '>='
100
+ - - ">="
95
101
  - !ruby/object:Gem::Version
96
102
  version: '0'
97
103
  requirements: []
98
104
  rubyforge_project:
99
- rubygems_version: 2.0.3
105
+ rubygems_version: 2.2.2
100
106
  signing_key:
101
107
  specification_version: 4
102
108
  summary: Pass metadata to MiniTest::Spec descriptions and specs like in RSpec.
103
109
  test_files:
104
- - spec/describe_with_metadata.spec.rb
110
+ - spec/describe.spec.rb
105
111
  - spec/helper.rb
106
- - spec/spec_with_metadata.spec.rb
112
+ - spec/it.spec.rb
113
+ - spec/minispec_metadata.spec.rb
114
+ - spec/readme.spec.rb
115
+ - spec/regression.spec.rb
data/.rvmrc DELETED
@@ -1 +0,0 @@
1
- rvm --create 2.0.0-p0@minispec-metadata
@@ -1,97 +0,0 @@
1
- require_relative 'helper'
2
-
3
- describe MiniSpecMetadata::DescribeWithMetadata, super_meta: 'data' do
4
-
5
- describe 'as 2nd arg after description', second: '2nd' do
6
-
7
- it 'is accessible with metadata method' do
8
- metadata.fetch(:second).must_equal '2nd'
9
- end
10
-
11
- end
12
-
13
- describe 'as 3rd arg after additional description', 'more description', third: '3rd' do
14
-
15
- it 'is accessible with metadata method' do
16
- metadata.fetch(:third).must_equal '3rd'
17
- end
18
-
19
- end
20
-
21
- describe 'when just a symbol is passed', :axiom, :vcr do
22
- it 'uses symbols as true values' do
23
- metadata.fetch(:axiom).must_equal true
24
- metadata.fetch(:vcr).must_equal true
25
- end
26
- end
27
-
28
- describe 'duplicate', first: '1st' do
29
-
30
- it 'correctly scopes metadata to current description' do
31
- metadata.fetch(:first).must_equal '1st'
32
- metadata.key?(:second).must_equal false
33
- end
34
-
35
- end
36
-
37
- describe 'duplicate', second: '2nd' do
38
-
39
- it 'correctly scopes metadata to current description' do
40
- metadata.fetch(:second).must_equal '2nd'
41
- metadata.key?(:first).must_equal false
42
- end
43
-
44
- end
45
-
46
- describe 'nested', sub: 'desc' do
47
-
48
- it 'inherits from surrounding description', lowest: 'totem' do
49
- metadata.must_equal(
50
- super_meta: 'data',
51
- sub: 'desc',
52
- lowest: 'totem',
53
- )
54
- end
55
-
56
- it 'gives nearest metadata priority', sub: 'zero', super_meta: 'priority' do
57
- metadata.must_equal(
58
- sub: 'zero',
59
- super_meta: 'priority',
60
- )
61
- end
62
-
63
- end
64
-
65
- desc_class = describe 'return value' do
66
-
67
- it 'equals description class' do
68
- desc_class.must_equal self.class
69
- end
70
-
71
- end
72
-
73
- end
74
-
75
- describe MiniSpecMetadata::DescribeWithMetadata, 'additional description' do
76
-
77
- it 'provides a method to get the descriptions' do
78
- spec_descriptions.must_equal [MiniSpecMetadata::DescribeWithMetadata, 'additional description']
79
- end
80
-
81
- it 'provides a shortcut to get the main description' do
82
- spec_description.must_equal MiniSpecMetadata::DescribeWithMetadata
83
- end
84
-
85
- it 'provides a method to get only the additional description' do
86
- spec_additional_description.must_equal 'additional description'
87
- end
88
-
89
- describe 'nested describe with no additional description' do
90
-
91
- it 'does not inherit additional description from parent' do
92
- spec_additional_description.must_be_nil
93
- end
94
-
95
- end
96
-
97
- end
@@ -1,88 +0,0 @@
1
- require_relative 'helper'
2
-
3
- describe MiniSpecMetadata::SpecWithMetadata, description_meta: 'data' do
4
-
5
- it 'accepts metadata arg', {} do
6
- pass
7
- end
8
-
9
- it 'stores metadata for current spec', meta: 'data' do
10
- metadata.fetch(:meta).must_equal 'data'
11
- end
12
-
13
- it 'inherits metadata from description' do
14
- metadata.fetch(:description_meta).must_equal 'data'
15
- end
16
-
17
- it "uses symbols as true values", :verity, :words_are_hard do
18
- metadata.fetch(:verity).must_equal true
19
- metadata.fetch(:words_are_hard).must_equal true
20
- end
21
-
22
- specify 'it works with #specify', 1 => 2 do
23
- metadata.fetch(1).must_equal 2
24
- end
25
-
26
- name = it 'returns name' do
27
- name.must_equal name
28
- end
29
-
30
- describe 'in a nested describe', 'with no metadata' do
31
-
32
- it 'works', works: true do
33
- metadata[:works].must_equal true
34
- end
35
-
36
- end
37
-
38
- describe 'in a nested describe', with_metadata: true do
39
-
40
- it 'works', works: true do
41
- metadata[:with_metadata].must_equal true
42
- metadata[:works].must_equal true
43
- end
44
-
45
- end
46
-
47
- end
48
-
49
- describe MiniSpecMetadata::SpecWithMetadata, 'with no metadata' do
50
-
51
- it 'returns empty hash when no metadata set' do
52
- metadata.must_equal({})
53
- end
54
-
55
- end
56
-
57
- describe MiniSpecMetadata::SpecWithMetadata do
58
-
59
- before do
60
- metadata.fetch(:before).must_equal 'accessible'
61
- end
62
-
63
- it 'is accessible in hooks', before: 'accessible', after: 'also accessible' do
64
- pass
65
- end
66
-
67
- after do
68
- metadata.fetch(:after).must_equal 'also accessible'
69
- end
70
-
71
- end
72
-
73
- describe MiniSpecMetadata::SpecWithMetadata, 'test name' do
74
-
75
- it 'provides a method to get the name of the spec' do
76
- spec_name.must_equal 'provides a method to get the name of the spec'
77
- end
78
-
79
- end
80
-
81
- describe MiniSpecMetadata::SpecWithMetadata, 'additional description', :respect do
82
-
83
- it 'respects additional description' do
84
- self.class.name.must_equal 'MiniSpecMetadata::SpecWithMetadata::additional description'
85
- metadata.must_equal({respect: true})
86
- end
87
-
88
- end