RSpec Matcher define_constant(constant_name).of_type(Type)

Table of Contents

Features

Makes sure block defines a constant and removes the constant after block is done.

Requirements

  1. MRI 2.x

  2. RSpec 3.x

Setup

To install, type the following:

gem install rspec_matcher_define_constant

Add the following to your Gemfile:

gem "rspec_matcher_define_constant"

Usage

RSpec.describe "a block that defines a constant" do
  subject do
    proc do
      Object.const_set "Stuff", 1
    end
  end

  it "defines Stuff" do
    expect { subject.call }.to define_constant "Stuff"
    # Stuff is not defined here.
  end
end

Tests

To test, run:

bundle exec rake

Versioning

Read Semantic Versioning for details. Briefly, it means:

Code of Conduct

Please note that this project is released with a CODE OF CONDUCT. By participating in this project you agree to abide by its terms.

Contributions

Read CONTRIBUTING for details.

License

Copyright © 2016 Pooyan Khosravi}[]. Read the {LICENSE for details.

History

Read the CHANGELOG for details. Built with Gemsmith.

Credits

Developed by {Pooyan Khosravi}[].