Module: Fixtures::String

Extended by:
String
Includes:
Fixtures
Included in:
String
Defined in:
lib/data_model/fixtures/string.rb

Overview

Test data for string schemas

Instance Method Summary collapse

Instance Method Details

#allow_blankExample

a string example where blank strings are allowed

Returns:



71
72
73
74
75
76
77
78
79
80
# File 'lib/data_model/fixtures/string.rb', line 71

def allow_blank
  Example.new(
    [:string, { allow_blank: true }],
    variants: {
      blank: "",
      not_blank: "content",
      missing: nil
    },
  )
end

#dont_allow_blankExample

a string example where blank strings are not allowed

Returns:



84
85
86
87
88
89
90
91
# File 'lib/data_model/fixtures/string.rb', line 84

def dont_allow_blank
  Example.new(
    [:string, { allow_blank: false }],
    variants: {
      blank: ""
    },
  )
end

#emailExample

an email string example

Returns:



22
23
24
25
26
27
28
29
30
# File 'lib/data_model/fixtures/string.rb', line 22

def email
  Example.new(
    [:string, { format: "@" }],
    variants: {
      valid: "[email protected]",
      invalid: "invalid"
    },
  )
end

#exclusionExample

a string example where “invalid” is the only disallowed String

Returns:



59
60
61
62
63
64
65
66
67
# File 'lib/data_model/fixtures/string.rb', line 59

def exclusion
  Example.new(
    [:string, { excluded: ["invalid"] }],
    variants: {
      valid: "valid",
      inside: "invalid"
    },
  )
end

#inclusionExample

a string example where “valid” is the only allowed String

Returns:



47
48
49
50
51
52
53
54
55
# File 'lib/data_model/fixtures/string.rb', line 47

def inclusion
  Example.new(
    [:string, { included: ["valid"] }],
    variants: {
      valid: "valid",
      outside: "invalid"
    },
  )
end

#optionalExample

a string example that is optional

Returns:



34
35
36
37
38
39
40
41
42
43
# File 'lib/data_model/fixtures/string.rb', line 34

def optional
  Example.new(
    [:string, { optional: true }],
    variants: {
      valid: "valid",
      blank: "",
      missing: nil
    },
  )
end

#simpleExample

a simple string example

Returns:



9
10
11
12
13
14
15
16
17
18
# File 'lib/data_model/fixtures/string.rb', line 9

def simple
  Example.new(
    [:string],
    variants: {
      valid: "valid",
      other_type: 22,
      missing: nil
    },
  )
end