File: be.feature

package info (click to toggle)
ruby-rspec-expectations 2.14.2-1~bpo70%2B1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy-backports
  • size: 920 kB
  • sloc: ruby: 8,202; makefile: 4
file content (175 lines) | stat: -rw-r--r-- 5,046 bytes parent folder | download | duplicates (2)
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
Feature: "be" matchers

  There are several related "be" matchers:

    ```ruby
    obj.should be_true  # passes if obj is truthy (not nil or false)
    obj.should be_false # passes if obj is falsy (nil or false)
    obj.should be_nil   # passes if obj is nil
    obj.should be       # passes if obj is truthy (not nil or false)
    ```

  Scenario: be_true matcher
    Given a file named "be_true_spec.rb" with:
      """ruby
      describe "be_true matcher" do
        specify { true.should be_true }
        specify { 7.should be_true }
        specify { "foo".should be_true }
        specify { nil.should_not be_true }
        specify { false.should_not be_true }

        # deliberate failures
        specify { true.should_not be_true }
        specify { 7.should_not be_true }
        specify { "foo".should_not be_true }
        specify { nil.should be_true }
        specify { false.should be_true }
      end
      """
    When I run `rspec be_true_spec.rb`
    Then the output should contain "10 examples, 5 failures"
    And the output should contain:
      """
             expected: non-true value
                  got: true
      """
    And the output should contain:
      """
             expected: non-true value
                  got: 7
      """
    And the output should contain:
      """
             expected: non-true value
                  got: "foo"
      """
    And the output should contain:
      """
             expected: true value
                  got: nil
      """
    And the output should contain:
      """
             expected: true value
                  got: false
      """

  Scenario: be_false matcher
    Given a file named "be_false_spec.rb" with:
      """ruby
      describe "be_false matcher" do
        specify { nil.should be_false }
        specify { false.should be_false }
        specify { true.should_not be_false }
        specify { 7.should_not be_false }
        specify { "foo".should_not be_false }

        # deliberate failures
        specify { nil.should_not be_false }
        specify { false.should_not be_false }
        specify { true.should be_false }
        specify { 7.should be_false }
        specify { "foo".should be_false }
      end
      """
    When I run `rspec be_false_spec.rb`
    Then the output should contain "10 examples, 5 failures"
    And the output should contain:
      """
             expected: non-false value
                  got: nil
      """
    And the output should contain:
      """
             expected: non-false value
                  got: false
      """
    And the output should contain:
      """
             expected: false value
                  got: true
      """
    And the output should contain:
      """
             expected: false value
                  got: 7
      """
    And the output should contain:
      """
             expected: false value
                  got: "foo"
      """

  Scenario: be_nil matcher
    Given a file named "be_nil_spec.rb" with:
      """ruby
      describe "be_nil matcher" do
        specify { nil.should be_nil }
        specify { false.should_not be_nil }
        specify { true.should_not be_nil }
        specify { 7.should_not be_nil }
        specify { "foo".should_not be_nil }

        # deliberate failures
        specify { nil.should_not be_nil }
        specify { false.should be_nil }
        specify { true.should be_nil }
        specify { 7.should be_nil }
        specify { "foo".should be_nil }
      end
      """
    When I run `rspec be_nil_spec.rb`
    Then the output should contain "10 examples, 5 failures"
    And the output should contain:
      """
             expected: not nil
                  got: nil
      """
    And the output should contain:
      """
             expected: nil
                  got: false
      """
    And the output should contain:
      """
             expected: nil
                  got: true
      """
    And the output should contain:
      """
             expected: nil
                  got: 7
      """
    And the output should contain:
      """
             expected: nil
                  got: "foo"
      """

  Scenario: be matcher
    Given a file named "be_spec.rb" with:
      """ruby
      describe "be_matcher" do
        specify { true.should be }
        specify { 7.should be }
        specify { "foo".should be }
        specify { nil.should_not be }
        specify { false.should_not be }

        # deliberate failures
        specify { true.should_not be }
        specify { 7.should_not be }
        specify { "foo".should_not be }
        specify { nil.should be }
        specify { false.should be }
      end
      """
    When I run `rspec be_spec.rb`
    Then the output should contain all of these:
      | 10 examples, 5 failures             |
      | expected true to evaluate to false  |
      | expected 7 to evaluate to false     |
      | expected "foo" to evaluate to false |
      | expected nil to evaluate to true    |
      | expected false to evaluate to true  |