File: implicit_subject.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 (57 lines) | stat: -rw-r--r-- 978 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
55
56
57
require "./spec/cases/helper"
require "maxitest/implicit_subject"

class DoNotCallMe
  def initialize
    raise "WRONG"
  end
end

describe String do
  it "has implicit subject" do
    _(subject).must_equal ""
  end

  describe Array do
    def other_method
      true
    end

    it "has nested implicit subject" do
      _(subject).must_equal []
      _(other_method).must_equal true
    end
  end

  describe Hash do
    it "has other nested implicit subject" do
      _(subject).must_equal({})
    end

    describe "strings" do
      it "does not overwrite subject" do
        _(subject).must_equal({})
      end
    end

    describe :symbols do
      it "does not overwrite subject" do
        _(subject).must_equal({})
      end
    end
  end

  describe DoNotCallMe do
    let(:subject) { 1 }

    it "can overwrite" do
      subject.must_equal 1
    end
  end
end

describe "without" do
  it "raises as expected" do
    assert_raises(NameError) { subject }
  end
end