File: hide_undefined_constant.feature

package info (click to toggle)
ruby-rspec 3.13.0c0e0m0s1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,856 kB
  • sloc: ruby: 70,868; sh: 1,423; makefile: 99
file content (22 lines) | stat: -rw-r--r-- 860 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Feature: Hide Undefined Constant

  Hiding a constant that is already undefined is a no-op. This can be useful when a spec file
  may run in either an isolated environment (e.g. when running one spec file) or in a full
  environment with all parts of your code base loaded (e.g. when running your entire suite).

  Scenario: Hiding undefined constant
    Given a file named "hide_const_spec.rb" with:
      """ruby
      RSpec.describe "hiding UNDEFINED_CONSTANT" do
        it "has no effect" do
          hide_const("UNDEFINED_CONSTANT")
          expect { UNDEFINED_CONSTANT }.to raise_error(NameError)
        end

        it "is still undefined after the example completes" do
          expect { UNDEFINED_CONSTANT }.to raise_error(NameError)
        end
      end
      """
    When I run `rspec hide_const_spec.rb`
    Then the examples should all pass