File: rspec_matchers_spec.rb

package info (click to toggle)
ruby-rspec 3.8.0c0e1m0s0-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 6,640 kB
  • sloc: ruby: 65,844; sh: 807; makefile: 99
file content (43 lines) | stat: -rw-r--r-- 1,502 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
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
module RSpec::Matchers
  def __method_with_super
    super
  end

  module ModThatIncludesMatchers
    include RSpec::Matchers
  end

  RSpec.configure do |c|
    c.include RSpec::Matchers, :include_rspec_matchers => true
    c.include ModThatIncludesMatchers, :include_mod_that_includes_rspec_matchers => true
  end

  RSpec.describe self do
    shared_examples_for "a normal module with a method that supers" do
      it "raises the expected error (and not SystemStackError)" do
        expect { __method_with_super }.to raise_error(NoMethodError) # there is no __method_with_super in an ancestor
      end
    end

    it_behaves_like "a normal module with a method that supers"

    context "when RSpec::Matchers has been included in an example group" do
      include RSpec::Matchers
      it_behaves_like "a normal module with a method that supers"
    end

    context "when a module that includes RSpec::Matchers has been included in an example group" do
      include RSpec::Matchers::ModThatIncludesMatchers
      it_behaves_like "a normal module with a method that supers"
    end

    context "when RSpec::Matchers is included via configuration", :include_rspec_matchers => true do
      it_behaves_like "a normal module with a method that supers"
    end

    context "when RSpec::Matchers is included in a module that is included via configuration", :include_mod_that_includes_rspec_matchers => true do
      it_behaves_like "a normal module with a method that supers"
    end
  end
end