File: any.feature

package info (click to toggle)
ruby-contracts 0.17-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 624 kB
  • sloc: ruby: 3,805; makefile: 4; sh: 2
file content (44 lines) | stat: -rw-r--r-- 788 bytes parent folder | download | duplicates (4)
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
Feature: Any

  Passes for any argument.

  ```ruby
  Contract C::Any => String
  ```

  Scenario: Accepts any argument
    Given a file named "any_usage.rb" with:
    """ruby
    require "contracts"
    C = Contracts

    class Example
      include Contracts::Core

      Contract C::Any => String
      def self.stringify(x)
        x.inspect
      end
    end

    puts Example.stringify(25)
    puts Example.stringify(37.59)
    puts Example.stringify("foo")
    puts Example.stringify(:foo)
    puts Example.stringify(nil)
    puts Example.stringify(Object)
    """
    When I run `ruby any_usage.rb`
    Then output should contain:
    """
    25
    37.59
    "foo"
    :foo
    nil
    Object
    """
    And output should not contain:
    """
    Contract violation for
    """