<commit_before>Minispec::Metadata
==================

[![Build Status](https://secure.travis-ci.org/ordinaryzelig/minispec-metadata.png?branch=master)](http://travis-ci.org/ordinaryzelig/minispec-metadata)

https://github.com/ordinaryzelig/minispec-metadata

## Usage

```ruby
describe 'Usage', some: 'metadata' do

  before do
    # Example usefulness:
    # Capybara.current_driver = metadata[:driver]
  end

  it 'defines a metadata method', more: 'metadata' do
    metadata.must_equal(
      some: 'metadata',
      more: 'metadata',
    )
  end

  it 'gives priority to closest metadata', some: 'different metadata' do
    metadata.must_equal(
      some: 'different metadata',
    )
  end

  it 'provides a method to get the name of the spec' do
    spec_name.must_equal 'provides a method to get the name of the spec'
  end

  describe MiniSpecMetadata::DescribeWithMetadata, 'additional description' do

    it 'provides a method to get the descriptions' do
      spec_descriptions.must_equal [MiniSpecMetadata::DescribeWithMetadata, 'additional description']
    end

    # I say "shortcut" because you can easily get this without this gem via
    # self.class.desc
    it 'provides a shortcut to get the main description' do
      spec_description.must_equal MiniSpecMetadata::DescribeWithMetadata
    end

    it 'provides a method to get only the additional description' do
      spec_additional_description.must_equal 'additional description'
    end

  end

end
```

### Gotchas

If you registered a custom spec type and made it a subclass of MiniTest::Spec, e.g.:

```ruby
class IntegrationSpec < MiniTest::Spec
  register_spec_type(/integration$/, self)
end
MiniTest
```

then you will need to change your superclass to be a subclass of the spec type that allows metadata
(see Implementation below).
Just change it like this:

```ruby
class IntegrationSpec < MiniTest::Spec.spec_type(//)
  register_spec_type(/integration$/, self)
end
MiniTest
```
<commit_msg>Add note about VCR trick.<commit_after>Minispec::Metadata
==================

[![Build Status](https://secure.travis-ci.org/ordinaryzelig/minispec-metadata.png?branch=master)](http://travis-ci.org/ordinaryzelig/minispec-metadata)

https://github.com/ordinaryzelig/minispec-metadata

## Usage

```ruby
describe 'Usage', some: 'metadata' do

  before do
    # Example usefulness:
    # Capybara.current_driver = metadata[:driver]
  end

  it 'defines a metadata method', more: 'metadata' do
    metadata.must_equal(
      some: 'metadata',
      more: 'metadata',
    )
  end

  it 'gives priority to closest metadata', some: 'different metadata' do
    metadata.must_equal(
      some: 'different metadata',
    )
  end

  it 'provides a method to get the name of the spec' do
    spec_name.must_equal 'provides a method to get the name of the spec'
  end

  describe MiniSpecMetadata::DescribeWithMetadata, 'additional description' do

    it 'provides a method to get the descriptions' do
      spec_descriptions.must_equal [MiniSpecMetadata::DescribeWithMetadata, 'additional description']
    end

    # I say "shortcut" because you can easily get this without this gem via
    # self.class.desc
    it 'provides a shortcut to get the main description' do
      spec_description.must_equal MiniSpecMetadata::DescribeWithMetadata
    end

    it 'provides a method to get only the additional description' do
      spec_additional_description.must_equal 'additional description'
    end

  end

end
```

Another great use is to do a version of [Ryan Bates' VCR trick](http://railscasts.com/episodes/291-testing-with-vcr?view=asciicast).

```ruby
describe 'VCR trick' do

  it 'allows you to name your cassettes the same as the spec' do
    VCR.use_cassette spec_name do
    end
  end
end
```

### Gotchas

If you registered a custom spec type and made it a subclass of MiniTest::Spec, e.g.:

```ruby
class IntegrationSpec < MiniTest::Spec
  register_spec_type(/integration$/, self)
end
MiniTest
```

then you will need to change your superclass to be a subclass of the spec type that allows metadata
(see Implementation below).
Just change it like this:

```ruby
class IntegrationSpec < MiniTest::Spec.spec_type(//)
  register_spec_type(/integration$/, self)
end
MiniTest
```

{'fraction_non_alphanumeric': 0.09851869268751469, 'fraction_numerical': 0.0007053844345168116, 'mean_word_length': 4.034319526627219, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1132673', 'n_tokens_mistral': 1317, 'n_tokens_neox': 1234, 'n_words': 427}