Top Level Namespace

Defined Under Namespace

Modules: Kernel, Rspeckled

Instance Method Summary collapse

Instance Method Details

#base64_digit_regexObject



11
12
13
# File 'lib/rspeckled/helpers/patterns.rb', line 11

def base64_digit_regex
  %r{[a-z0-9\+/=]}i
end

#encrypted_json_web_token_regexObject



50
51
52
53
54
55
# File 'lib/rspeckled/helpers/patterns.rb', line 50

def encrypted_json_web_token_regex
  /
    (#{json_web_token_base64_regex}+?\.){4}
    #{json_web_token_base64_regex}+?
  /x
end

#factory_nameObject



3
4
5
# File 'lib/rspeckled/helpers/factories.rb', line 3

def factory_name
  described_class.name.underscore
end

#fixture_filepath(filepath) ⇒ Object



15
16
17
# File 'lib/rspeckled/helpers/filepaths.rb', line 15

def fixture_filepath(filepath)
  "#{root_filepath}/spec/fixtures/#{filepath}"
end

#guid_regexObject



19
20
21
# File 'lib/rspeckled/helpers/patterns.rb', line 19

def guid_regex
  /[a-f0-9]{32}/i
end

#hex_digit_regexObject



15
16
17
# File 'lib/rspeckled/helpers/patterns.rb', line 15

def hex_digit_regex
  /[a-f0-9]/i
end

#iso8601_regexObject



7
8
9
# File 'lib/rspeckled/helpers/patterns.rb', line 7

def iso8601_regex
  /(-?(?:[1-9][0-9]*)?[0-9]{4})-(1[0-2]|0[1-9])-(3[01]|0[1-9]|[12][0-9])T(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])(\.[0-9]+)?((?:[\+\-]\d{2}:\d{2})|Z)?/
end

#json_responseObject



3
4
5
# File 'lib/rspeckled/helpers/responses.rb', line 3

def json_response
  JSON.load(response.body) # rubocop:disable Security/JSONLoad
end

#json_web_token_base64_regexObject



39
40
41
# File 'lib/rspeckled/helpers/patterns.rb', line 39

def json_web_token_base64_regex
  %r{[A-Za-z0-9_/\+\=\-]}
end

#json_web_token_regexObject



43
44
45
46
47
48
# File 'lib/rspeckled/helpers/patterns.rb', line 43

def json_web_token_regex
  /
    (#{json_web_token_base64_regex}+?\.){2}
    #{json_web_token_base64_regex}+?
  /x
end

#md5_regexObject



23
24
25
# File 'lib/rspeckled/helpers/patterns.rb', line 23

def md5_regex
  /[a-f0-9]{32}/i
end

#null_described_classObject



3
4
5
# File 'lib/rspeckled/helpers/null_objects.rb', line 3

def null_described_class
  "Null#{described_class.name}".constantize
end

#parse_fixture(filepath) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/rspeckled/helpers/filepaths.rb', line 23

def parse_fixture(filepath)
  contents = read_fixture(filepath)

  case filepath[/\.\w+\z/]
  when '.json'
    ::JSON.parse(contents)
  when '.eml'
    ::Mail.new(contents)
  else
    fail ArgumentError, "I don't know how to parse #{filepath}."
  end
end

#read_fixture(filepath) ⇒ Object



19
20
21
# File 'lib/rspeckled/helpers/filepaths.rb', line 19

def read_fixture(filepath)
  ::File.read(fixture_filepath(filepath))
end

#root_filepathObject



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/rspeckled/helpers/filepaths.rb', line 3

def root_filepath
  @root_filepath ||= begin
                       current_directory = Dir.pwd

                       until Dir.exist?(current_directory + '/spec')
                         current_directory += '/..'
                       end

                       File.expand_path(current_directory)
                     end
end

#sha_regexObject



27
28
29
# File 'lib/rspeckled/helpers/patterns.rb', line 27

def sha_regex
  /[a-f0-9]{64}/i
end

#test_email_regexObject



31
32
33
# File 'lib/rspeckled/helpers/patterns.rb', line 31

def test_email_regex
  /user\[email protected]/
end

#test_username_regexObject



35
36
37
# File 'lib/rspeckled/helpers/patterns.rb', line 35

def test_username_regex
  /username\d+/
end

#uuid_regexObject



3
4
5
# File 'lib/rspeckled/helpers/patterns.rb', line 3

def uuid_regex
  /[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/i
end