tarka_matchers 0.0.53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +2 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/README.md +39 -0
- data/Rakefile +2 -0
- data/bin/console +7 -0
- data/bin/setup +5 -0
- data/bin/tarka_matchers +14 -0
- data/lib/tarka_matchers/action_dispatch_matchers.rb +5 -0
- data/lib/tarka_matchers/class_matchers.rb +5 -0
- data/lib/tarka_matchers/commands/calibrate.rb +57 -0
- data/lib/tarka_matchers/commands/install.rb +50 -0
- data/lib/tarka_matchers/expectation_matchers.rb +10 -0
- data/lib/tarka_matchers/formatters/difference.rb +41 -0
- data/lib/tarka_matchers/formatters/selected.rb +29 -0
- data/lib/tarka_matchers/formatters/styles.rb +15 -0
- data/lib/tarka_matchers/helpers/expectation/common.rb +25 -0
- data/lib/tarka_matchers/helpers/expectation/expect_capture.rb +53 -0
- data/lib/tarka_matchers/helpers/expectation/result.rb +16 -0
- data/lib/tarka_matchers/helpers/rails/action_dispatch/route_populator.rb +28 -0
- data/lib/tarka_matchers/helpers/string/sgr/sgr_codes.rb +127 -0
- data/lib/tarka_matchers/helpers/string/sgr/sgr_sequences/xterm.txt +108 -0
- data/lib/tarka_matchers/helpers/string/sgr/styled_capture.rb +28 -0
- data/lib/tarka_matchers/matchers/class/have_an_instance_variable_of.rb +39 -0
- data/lib/tarka_matchers/matchers/expectation/fail.rb +35 -0
- data/lib/tarka_matchers/matchers/expectation/have_a_description_of.rb +43 -0
- data/lib/tarka_matchers/matchers/expectation/have_a_failure_message_of.rb +41 -0
- data/lib/tarka_matchers/matchers/expectation/have_a_failure_message_when_negated_of.rb +41 -0
- data/lib/tarka_matchers/matchers/expectation/pass.rb +35 -0
- data/lib/tarka_matchers/matchers/expectation/support_block_expectations.rb +45 -0
- data/lib/tarka_matchers/matchers/rails/action_dispatch/be_named_as.rb +19 -0
- data/lib/tarka_matchers/matchers/regex/match_sections.rb +84 -0
- data/lib/tarka_matchers/matchers/string/sgr/be_red.rb +15 -0
- data/lib/tarka_matchers/rails_matchers.rb +1 -0
- data/lib/tarka_matchers/regex_matchers.rb +5 -0
- data/lib/tarka_matchers/ruby_matchers.rb +3 -0
- data/lib/tarka_matchers/sgr_matchers.rb +5 -0
- data/lib/tarka_matchers/version.rb +3 -0
- data/lib/tarka_matchers.rb +3 -0
- data/tarka_matchers.gemspec +35 -0
- metadata +200 -0
@@ -0,0 +1,127 @@
|
|
1
|
+
module TarkaMatchers
|
2
|
+
module Helpers
|
3
|
+
module SGR
|
4
|
+
module SGRCodes
|
5
|
+
def self.codes
|
6
|
+
{
|
7
|
+
reset: 0,
|
8
|
+
bold: 1,
|
9
|
+
faint: 2,
|
10
|
+
italic: 3,
|
11
|
+
single_underline: 4,
|
12
|
+
slow_blink: 5,
|
13
|
+
rapid_blink: 6,
|
14
|
+
negative: 7,
|
15
|
+
conceal: 8,
|
16
|
+
crossed_out: 9,
|
17
|
+
primary_font: 10,
|
18
|
+
secondary_font: 11,
|
19
|
+
tertiary_font: 12,
|
20
|
+
quaternary_font: 13,
|
21
|
+
quinary_font: 14,
|
22
|
+
senary_font: 15,
|
23
|
+
septenary_font: 16,
|
24
|
+
octonary_font: 17,
|
25
|
+
nonary_font: 18,
|
26
|
+
denary_font: 19,
|
27
|
+
fraktur_font: 20,
|
28
|
+
double_underline: 21,
|
29
|
+
default_color: 22,
|
30
|
+
not_italic_nor_fraktur: 23,
|
31
|
+
not_underlinee: 24,
|
32
|
+
not_blinking: 25,
|
33
|
+
reserved: 26.
|
34
|
+
positive: 27,
|
35
|
+
reveal: 28,
|
36
|
+
not_crossed_out: 29,
|
37
|
+
black_text: 30,
|
38
|
+
red_text: 31,
|
39
|
+
green_text: 32,
|
40
|
+
yellow_text: 33,
|
41
|
+
blue_text: 34,
|
42
|
+
magenta_text: 35,
|
43
|
+
cyan_text: 36,
|
44
|
+
white_text: 37,
|
45
|
+
extended_text: 38,
|
46
|
+
default_text: 39,
|
47
|
+
black_background: 40,
|
48
|
+
red_background: 41,
|
49
|
+
green_background: 42,
|
50
|
+
yellow_background: 43.
|
51
|
+
blue_background: 44,
|
52
|
+
magenta_background: 45,
|
53
|
+
cyan_background: 46,
|
54
|
+
white_background: 47,
|
55
|
+
extended_background: 48,
|
56
|
+
default_background: 49,
|
57
|
+
reserved: 50,
|
58
|
+
framed: 51,
|
59
|
+
encircled: 52,
|
60
|
+
overlined: 53,
|
61
|
+
not_framed_nor_circled: 54,
|
62
|
+
not_overlined: 55,
|
63
|
+
reserved: 56,
|
64
|
+
reserved: 57,
|
65
|
+
reserved: 58,
|
66
|
+
reserved: 59,
|
67
|
+
ideogram_underline: 60,
|
68
|
+
ideogram_double_underline: 61,
|
69
|
+
ideogram_overlinee: 62,
|
70
|
+
ideogram_double_overline: 63,
|
71
|
+
ideaogram_stress: 64,
|
72
|
+
not_ideogramed: 65,
|
73
|
+
reserved: 66,
|
74
|
+
reserved: 67,
|
75
|
+
reserved: 68,
|
76
|
+
reserved: 69,
|
77
|
+
reserved: 70,
|
78
|
+
reserved: 71,
|
79
|
+
reserved: 72,
|
80
|
+
reserved: 73,
|
81
|
+
reserved: 74,
|
82
|
+
reserved: 75,
|
83
|
+
reserved: 76,
|
84
|
+
reserved: 77,
|
85
|
+
reserved: 78,
|
86
|
+
reserved: 79,
|
87
|
+
reserved: 80,
|
88
|
+
reserved: 81,
|
89
|
+
reserved: 82,
|
90
|
+
reserved: 83,
|
91
|
+
reserved: 84,
|
92
|
+
reserved: 85,
|
93
|
+
reserved: 86,
|
94
|
+
reserved: 87,
|
95
|
+
reserved: 88,
|
96
|
+
reserved: 89,
|
97
|
+
light_black_text: 90,
|
98
|
+
light_red_text: 91,
|
99
|
+
light_green_text: 92,
|
100
|
+
light_yellow_text: 93,
|
101
|
+
light_blue_text: 94,
|
102
|
+
light_magenta_text: 95,
|
103
|
+
light_cyan_text: 96,
|
104
|
+
light_white_text: 97,
|
105
|
+
reserved: 98,
|
106
|
+
reserved: 99,
|
107
|
+
light_black_background: 100,
|
108
|
+
light_red_background: 101,
|
109
|
+
light_green_background: 102,
|
110
|
+
light_yellow_background: 103,
|
111
|
+
light_blue_background: 104,
|
112
|
+
light_magenta_background: 105,
|
113
|
+
light_cyan_background: 106,
|
114
|
+
light_white_background: 107,
|
115
|
+
increased_intensity: 1,
|
116
|
+
not_bold: 21,
|
117
|
+
default_intensity: 22,
|
118
|
+
right_side_line: 60,
|
119
|
+
double_right_side_line: 61,
|
120
|
+
left_side_line: 62,
|
121
|
+
double_left_side_line: 63
|
122
|
+
}
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
reset
|
2
|
+
bold
|
3
|
+
faint
|
4
|
+
italic
|
5
|
+
single_underline
|
6
|
+
slow_blink
|
7
|
+
rapid_blink
|
8
|
+
negative
|
9
|
+
conceal
|
10
|
+
crossed_out
|
11
|
+
primary_font
|
12
|
+
secondary_font
|
13
|
+
tertiary_font
|
14
|
+
quaternary_font
|
15
|
+
quinary_font
|
16
|
+
senary_font
|
17
|
+
septenary_font
|
18
|
+
octonary_font
|
19
|
+
nonary_font
|
20
|
+
denary_font
|
21
|
+
fraktur_font
|
22
|
+
double_underline
|
23
|
+
default_color
|
24
|
+
not_italic_nor_fraktur
|
25
|
+
not_underlinee
|
26
|
+
not_blinking
|
27
|
+
reserved
|
28
|
+
positive
|
29
|
+
reveal
|
30
|
+
not_crossed_out
|
31
|
+
black_text
|
32
|
+
red_text
|
33
|
+
green_text
|
34
|
+
yellow_text
|
35
|
+
blue_text
|
36
|
+
magenta_text
|
37
|
+
cyan_text
|
38
|
+
white_text
|
39
|
+
extended_text
|
40
|
+
default_text
|
41
|
+
black_background
|
42
|
+
red_background
|
43
|
+
green_background
|
44
|
+
yellow_background
|
45
|
+
blue_background
|
46
|
+
magenta_background
|
47
|
+
cyan_background
|
48
|
+
white_background
|
49
|
+
extended_background
|
50
|
+
default_background
|
51
|
+
reserved
|
52
|
+
framed
|
53
|
+
encircled
|
54
|
+
overlined
|
55
|
+
not_framed_nor_circled
|
56
|
+
not_overlined
|
57
|
+
reserved
|
58
|
+
reserved
|
59
|
+
reserved
|
60
|
+
reserved
|
61
|
+
ideogram_underline
|
62
|
+
ideogram_double_underline
|
63
|
+
ideogram_overlinee
|
64
|
+
ideogram_double_overline
|
65
|
+
ideaogram_stress
|
66
|
+
not_ideogramed
|
67
|
+
reserved
|
68
|
+
reserved
|
69
|
+
reserved
|
70
|
+
reserved
|
71
|
+
reserved
|
72
|
+
reserved
|
73
|
+
reserved
|
74
|
+
reserved
|
75
|
+
reserved
|
76
|
+
reserved
|
77
|
+
reserved
|
78
|
+
reserved
|
79
|
+
reserved
|
80
|
+
reserved
|
81
|
+
reserved
|
82
|
+
reserved
|
83
|
+
reserved
|
84
|
+
reserved
|
85
|
+
reserved
|
86
|
+
reserved
|
87
|
+
reserved
|
88
|
+
reserved
|
89
|
+
reserved
|
90
|
+
reserved
|
91
|
+
light_black_text
|
92
|
+
light_red_text
|
93
|
+
light_green_text
|
94
|
+
light_yellow_text
|
95
|
+
light_blue_text
|
96
|
+
light_magenta_text
|
97
|
+
light_cyan_text
|
98
|
+
light_white_text
|
99
|
+
reserved
|
100
|
+
reserved
|
101
|
+
light_black_background
|
102
|
+
light_red_background
|
103
|
+
light_green_background
|
104
|
+
light_yellow_background
|
105
|
+
light_blue_background
|
106
|
+
light_magenta_background
|
107
|
+
light_cyan_background
|
108
|
+
light_white_background
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'the_great_escape'
|
2
|
+
module TarkaMatchers
|
3
|
+
module Helpers
|
4
|
+
module SGR
|
5
|
+
class StyledCapture
|
6
|
+
STYLED = /\\e\[\d{1,3}m\K(?!\\e\[\d{1,3}m)(.+?)(?=\\e\[\d{1,3}m|$)/
|
7
|
+
CODE = /\\e\[\K\d{1,3}(?=m)/
|
8
|
+
|
9
|
+
def self.indexes_of string, regex
|
10
|
+
string.to_enum(:scan,regex).map do |v,|
|
11
|
+
si = $`.size
|
12
|
+
[si, v, si + v.length - 1]
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.capture string, number
|
17
|
+
#[]
|
18
|
+
#puts string
|
19
|
+
string = escape(string)
|
20
|
+
#puts '##################################'
|
21
|
+
puts self.indexes_of( string, /ab/)
|
22
|
+
#puts '##################################'
|
23
|
+
#.scan(CODE).uniq
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'tarka_matchers/helpers/expectation/result'
|
2
|
+
require 'tarka_matchers/formatters/difference'
|
3
|
+
module TarkaMatchers
|
4
|
+
module Matchers
|
5
|
+
module Class
|
6
|
+
def have_an_instance_variable_of instance_name
|
7
|
+
HaveAnInstanceVariableOf.new instance_name
|
8
|
+
end
|
9
|
+
|
10
|
+
class HaveAnInstanceVariableOf
|
11
|
+
def initialize instance_name
|
12
|
+
@instance_name = instance_name
|
13
|
+
end
|
14
|
+
|
15
|
+
def that_equals expected
|
16
|
+
@expected = expected
|
17
|
+
self
|
18
|
+
end
|
19
|
+
|
20
|
+
def matches? actual
|
21
|
+
@actual = actual.instance_variable_get(@instance_name)
|
22
|
+
@actual == @expected
|
23
|
+
end
|
24
|
+
|
25
|
+
def description
|
26
|
+
"contain an instance variable called, '#{@instance_name}', that equals '#{@expected}'."
|
27
|
+
end
|
28
|
+
|
29
|
+
def failure_message
|
30
|
+
"failed to #{description}\n#{TarkaMatchers::Formatters::Difference.difference(@expected,@actual)}"
|
31
|
+
end
|
32
|
+
|
33
|
+
def failure_message_when_negated
|
34
|
+
"did #{description}"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'tarka_matchers/helpers/expectation/result'
|
2
|
+
module TarkaMatchers
|
3
|
+
module Matchers
|
4
|
+
module Expectation
|
5
|
+
def fail
|
6
|
+
Fail.new
|
7
|
+
end
|
8
|
+
|
9
|
+
class Fail
|
10
|
+
def supports_block_expectations?; true; end
|
11
|
+
|
12
|
+
def matches? expectation
|
13
|
+
@actual = TarkaMatchers::Helpers::Expectation::Result.pass?{ expectation.call }
|
14
|
+
@actual != true
|
15
|
+
end
|
16
|
+
|
17
|
+
def description
|
18
|
+
"fail."
|
19
|
+
end
|
20
|
+
|
21
|
+
def report
|
22
|
+
"Spec result: #{@actual}"
|
23
|
+
end
|
24
|
+
|
25
|
+
def failure_message
|
26
|
+
"#{description} #{report}"
|
27
|
+
end
|
28
|
+
|
29
|
+
def failure_message_when_negated
|
30
|
+
"#{description} #{report}"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'tarka_matchers/formatters/difference'
|
2
|
+
require 'tarka_matchers/helpers/expectation/expect_capture'
|
3
|
+
require 'tarka_matchers/helpers/expectation/common'
|
4
|
+
module TarkaMatchers
|
5
|
+
module Matchers
|
6
|
+
module Expectation
|
7
|
+
def have_a_description_of expected
|
8
|
+
HaveADescriptionOf.new expected
|
9
|
+
end
|
10
|
+
|
11
|
+
class HaveADescriptionOf
|
12
|
+
include TarkaMatchers::Helpers::Expectation::Common
|
13
|
+
def initialize expected
|
14
|
+
@expected = expected
|
15
|
+
end
|
16
|
+
|
17
|
+
def supports_block_expectations?
|
18
|
+
true
|
19
|
+
end
|
20
|
+
|
21
|
+
def matches? actual
|
22
|
+
captured = TarkaMatchers::Helpers::Expectation::ExpectCapture.capture(actual)
|
23
|
+
@actual_matcher = captured[1]
|
24
|
+
@actual = escape(@actual_matcher.description.prepend captured[0])
|
25
|
+
clean!(@actual)
|
26
|
+
@actual == @expected
|
27
|
+
end
|
28
|
+
|
29
|
+
def description
|
30
|
+
"utilize a matcher that has a description of: '#{@expected}'"
|
31
|
+
end
|
32
|
+
|
33
|
+
def failure_message
|
34
|
+
"The matcher, '#{@actual_matcher.class}', does not have the expected description: #{TarkaMatchers::Formatters::Difference.difference(@expected,@actual)}"
|
35
|
+
end
|
36
|
+
|
37
|
+
def failure_message_when_negated
|
38
|
+
"#{description}"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'tarka_matchers/formatters/difference'
|
2
|
+
require 'tarka_matchers/helpers/expectation/expect_capture'
|
3
|
+
require 'tarka_matchers/helpers/expectation/common'
|
4
|
+
module TarkaMatchers
|
5
|
+
module Matchers
|
6
|
+
module Expectation
|
7
|
+
def have_a_failure_message_of expected
|
8
|
+
HaveAFailureMessageOf.new expected
|
9
|
+
end
|
10
|
+
|
11
|
+
class HaveAFailureMessageOf
|
12
|
+
include TarkaMatchers::Helpers::Expectation::Common
|
13
|
+
def initialize expected
|
14
|
+
@expected = expected
|
15
|
+
end
|
16
|
+
|
17
|
+
def supports_block_expectations?
|
18
|
+
true
|
19
|
+
end
|
20
|
+
|
21
|
+
def matches? actual
|
22
|
+
@actual_matcher = TarkaMatchers::Helpers::Expectation::ExpectCapture.capture(actual)[1]
|
23
|
+
@actual = clean!(escape(@actual_matcher.failure_message))
|
24
|
+
@actual == @expected
|
25
|
+
end
|
26
|
+
|
27
|
+
def description
|
28
|
+
"utilize a matcher that has a failure message of: '#{@expected}'"
|
29
|
+
end
|
30
|
+
|
31
|
+
def failure_message
|
32
|
+
"The matcher, '#{@actual_matcher.class}', does not have the expected failure message: #{TarkaMatchers::Formatters::Difference.difference(@expected,@actual)}"
|
33
|
+
end
|
34
|
+
|
35
|
+
def failure_message_when_negated
|
36
|
+
"#{description}"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'tarka_matchers/formatters/difference'
|
2
|
+
require 'tarka_matchers/helpers/expectation/expect_capture'
|
3
|
+
require 'tarka_matchers/helpers/expectation/common'
|
4
|
+
module TarkaMatchers
|
5
|
+
module Matchers
|
6
|
+
module Expectation
|
7
|
+
def have_a_failure_message_when_negated_of expected
|
8
|
+
HaveAFailureMessageWhenNegatedOf.new expected
|
9
|
+
end
|
10
|
+
|
11
|
+
class HaveAFailureMessageWhenNegatedOf
|
12
|
+
include TarkaMatchers::Helpers::Expectation::Common
|
13
|
+
def initialize expected
|
14
|
+
@expected = expected
|
15
|
+
end
|
16
|
+
|
17
|
+
def supports_block_expectations?
|
18
|
+
true
|
19
|
+
end
|
20
|
+
|
21
|
+
def matches? actual
|
22
|
+
@actual_matcher = TarkaMatchers::Helpers::Expectation::ExpectCapture.capture(actual)[1]
|
23
|
+
@actual = clean!(escape(@actual_matcher.failure_message_when_negated))
|
24
|
+
@actual == @expected
|
25
|
+
end
|
26
|
+
|
27
|
+
def description
|
28
|
+
"utilize a matcher that has a failure message when negated of: '#{@expected}'"
|
29
|
+
end
|
30
|
+
|
31
|
+
def failure_message
|
32
|
+
"The matcher, '#{@actual_matcher.class}', does not have the expected failure message when negated: #{TarkaMatchers::Formatters::Difference.difference(@expected,@actual)}"
|
33
|
+
end
|
34
|
+
|
35
|
+
def failure_message_when_negated
|
36
|
+
"#{description}"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|