File: let_all.rb

package info (click to toggle)
ruby-maxitest 6.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 504 kB
  • sloc: ruby: 1,583; makefile: 7
file content (54 lines) | stat: -rw-r--r-- 1,080 bytes parent folder | download
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
44
45
46
47
48
49
50
51
52
53
54
require "./spec/cases/helper"

# executing sub-classes first makes the tests fail
Maxitest.static_class_order = true

describe "A" do
  order_dependent!

  let(:calls) { [] }
  let_all(:foo) { calls << 1; nil }

  describe "subclass gets randomly executed first" do
    it "is called when used" do
      _(calls).must_equal []
      _(foo).must_be_nil
      _(calls).must_equal [1]
    end
  end

  describe "then another subclass" do
    it "is not called multiple times" do
      _(calls).must_equal []
      _(foo).must_be_nil
      _(calls).must_equal []
    end
  end

  describe "overwrite" do
    let_all(:foo) { calls << 2; true }

    it "can overwrite" do
      _(calls).must_equal []
      _(foo).must_equal true
      _(calls).must_equal [2]
    end
  end

  describe "nested" do
    it "is not called multiple times from child classes" do
      _(calls).must_equal []
      _(foo).must_be_nil
      _(calls).must_equal []
    end
  end
end

describe "B" do
  let_all(:foo) { :foo }

  it "does not go across class boundaries" do
    _(foo).must_equal :foo
  end
end