File: end_with.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 (48 lines) | stat: -rw-r--r-- 1,636 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
Feature: `end_with` matcher

  Use the `end_with` matcher to specify that a string or array ends with the expected
  characters or elements.

  ```ruby
    expect("this string").to end_with "string"
    expect("this string").not_to end_with "stringy"
    expect([0, 1, 2]).to end_with 1, 2
  ```

  Scenario: String usage
    Given a file named "example_spec.rb" with:
      """ruby
      RSpec.describe "this string" do
        it { is_expected.to end_with "string" }
        it { is_expected.not_to end_with "stringy" }

        # deliberate failures
        it { is_expected.not_to end_with "string" }
        it { is_expected.to end_with "stringy" }
      end
      """
    When I run `rspec example_spec.rb`
    Then the output should contain all of these:
      | 4 examples, 2 failures                          |
      | expected "this string" not to end with "string" |
      | expected "this string" to end with "stringy"    |

  Scenario: Array usage
    Given a file named "example_spec.rb" with:
      """ruby
      RSpec.describe [0, 1, 2, 3, 4] do
        it { is_expected.to end_with 4 }
        it { is_expected.to end_with 3, 4 }
        it { is_expected.not_to end_with 3 }
        it { is_expected.not_to end_with 0, 1, 2, 3, 4, 5 }

        # deliberate failures
        it { is_expected.not_to end_with 4 }
        it { is_expected.to end_with 3 }
      end
      """
    When I run `rspec example_spec.rb`
    Then the output should contain all of these:
      | 6 examples, 2 failures                     |
      | expected [0, 1, 2, 3, 4] not to end with 4 |
      | expected [0, 1, 2, 3, 4] to end with 3     |