-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
Copy pathconstants_test.rb
30 lines (25 loc) · 1018 Bytes
/
constants_test.rb
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
require 'test_helper'
class ConstantsTest < ActiveSupport::TestCase
# This is used to test the constants at config/initializer
test 'should not match backtick' do
string = '@StlMaris123 @StlMaris123 `@StlMaris123`'
expect = 'REPLACE REPLACE `@StlMaris123`'
assert_equal expect, string.gsub(Callouts.const_get(:FINDER), ' REPLACE').lstrip!
end
test 'hashtag regex should not match initial hash' do
string = '#tag'
assert_no_match Callouts.const_get(:HASHTAG), string
end
test 'hashtag regex should match non-initial hash' do
string = 'this is a #tag'
assert_match Callouts.const_get(:HASHTAG), string
end
test 'hashtag regex should match colon' do
string = 'this is a #colon:tag'
assert string.scan(Callouts.const_get(:HASHTAG))[0][1] == 'colon:tag'
end
test 'hashtag regex should match multiple non-initial hash' do
string = 'this is a #tag #anotheRTag, #question:spectrometer'
assert string.scan(Callouts.const_get(:HASHTAG)).length == 3
end
end