test_bench-fixture 2.1.1.0 → 3.0.0.0.pre.1
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 +4 -4
- data/lib/test_bench/fixture/build.rb +39 -0
- data/lib/test_bench/fixture/controls/{result.rb → comment_style.rb} +1 -1
- data/lib/test_bench/fixture/controls/exception.rb +1 -1
- data/lib/test_bench/fixture/controls/fixture.rb +47 -7
- data/lib/test_bench/fixture/controls/{random.rb → message.rb} +1 -1
- data/lib/test_bench/fixture/controls/output.rb +3 -1
- data/lib/test_bench/fixture/controls/path.rb +7 -0
- data/lib/test_bench/fixture/controls/session.rb +19 -0
- data/lib/test_bench/fixture/controls/status.rb +7 -0
- data/lib/test_bench/fixture/controls/text.rb +7 -0
- data/lib/test_bench/fixture/controls/title.rb +1 -1
- data/lib/test_bench/fixture/controls.rb +9 -8
- data/lib/test_bench/fixture/evaluate.rb +10 -4
- data/lib/test_bench/fixture/fixture.rb +118 -106
- data/lib/test_bench/fixture.rb +4 -5
- metadata +29 -23
- data/lib/test_bench/fixture/actuate/class.rb +0 -95
- data/lib/test_bench/fixture/actuate/object.rb +0 -91
- data/lib/test_bench/fixture/controls/fixture/class.rb +0 -86
- data/lib/test_bench/fixture/controls/fixture/object/modules.rb +0 -39
- data/lib/test_bench/fixture/controls/fixture/object.rb +0 -31
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 45744e3e71121bf2f85bf466f4e04e8b383896cb57e84acb02c1865f53a3858f
|
4
|
+
data.tar.gz: c504febe7418482697b311f93d34cfde3f3b0512f4da567fb1a21b9b579295fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 282d574828712fddabe7afa79b65afba90584b049bfe0fa231559912cef8d1fbf0f6540bd9f2394b522cf12430f634c5cad26e9fdad6a0378e179e4032f3d25f
|
7
|
+
data.tar.gz: e491ffa0d88d18d45787076fe67d736a39e4c99ec48452978e0cbaaa92bcea4150c62459fdcfe47ca02d873c671895ac4c76a5add8447df145c542bb5bd06e2d
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module TestBench
|
2
|
+
module Fixture
|
3
|
+
module Build
|
4
|
+
Error = ::Class.new(RuntimeError)
|
5
|
+
|
6
|
+
def self.call(fixture_class, *, test_session: nil, **, &)
|
7
|
+
assure_fixture(fixture_class)
|
8
|
+
|
9
|
+
if fixture_class.respond_to?(:build)
|
10
|
+
constructor = :build
|
11
|
+
else
|
12
|
+
constructor = :new
|
13
|
+
end
|
14
|
+
|
15
|
+
fixture = fixture_class.public_send(constructor, *, **, &)
|
16
|
+
|
17
|
+
Session.configure(
|
18
|
+
fixture,
|
19
|
+
session: test_session,
|
20
|
+
attr_name: :test_session
|
21
|
+
)
|
22
|
+
|
23
|
+
fixture
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.assure_fixture(fixture_class)
|
27
|
+
is_class = fixture_class.instance_of?(::Class)
|
28
|
+
if not is_class
|
29
|
+
raise Error, "Not a class (Class: #{fixture_class})"
|
30
|
+
end
|
31
|
+
|
32
|
+
is_fixture_class = fixture_class.included_modules.include?(Fixture)
|
33
|
+
if not is_fixture_class
|
34
|
+
raise Error, "Not a fixture class (Class: #{fixture_class})"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -6,20 +6,60 @@ module TestBench
|
|
6
6
|
Example.new
|
7
7
|
end
|
8
8
|
|
9
|
-
|
10
|
-
|
9
|
+
class Example
|
10
|
+
include TestBench::Fixture
|
11
11
|
|
12
|
-
|
12
|
+
attr_accessor :actuated
|
13
13
|
|
14
|
-
|
14
|
+
attr_reader :some_argument
|
15
|
+
attr_reader :some_keyword_argument
|
16
|
+
attr_reader :some_block_argument
|
15
17
|
|
16
|
-
|
18
|
+
def initialize(some_argument=nil, some_keyword_argument: nil, &some_block_argument)
|
19
|
+
@some_argument = some_argument
|
20
|
+
@some_keyword_argument = some_keyword_argument
|
21
|
+
@some_block_argument = some_block_argument
|
22
|
+
end
|
17
23
|
|
18
|
-
|
24
|
+
def actuated?
|
25
|
+
actuated ? true : false
|
26
|
+
end
|
27
|
+
|
28
|
+
def call
|
29
|
+
self.actuated = true
|
30
|
+
end
|
19
31
|
end
|
20
32
|
|
21
|
-
class
|
33
|
+
class BuildMethod
|
22
34
|
include TestBench::Fixture
|
35
|
+
|
36
|
+
attr_accessor :some_argument
|
37
|
+
attr_accessor :some_optional_argument
|
38
|
+
attr_accessor :some_keyword_argument
|
39
|
+
attr_accessor :some_optional_keyword_argument
|
40
|
+
attr_accessor :some_block_argument
|
41
|
+
|
42
|
+
def self.build(some_argument, some_optional_argument=nil, some_keyword_argument:, some_optional_keyword_argument: nil, &some_block_argument)
|
43
|
+
instance = new
|
44
|
+
|
45
|
+
instance.some_argument = some_argument
|
46
|
+
instance.some_optional_argument = some_optional_argument
|
47
|
+
instance.some_keyword_argument = some_keyword_argument
|
48
|
+
instance.some_optional_keyword_argument = some_optional_keyword_argument
|
49
|
+
instance.some_block_argument = some_block_argument
|
50
|
+
|
51
|
+
instance
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
class NoBuildMethod
|
56
|
+
include TestBench::Fixture
|
57
|
+
|
58
|
+
attr_reader :some_argument
|
59
|
+
|
60
|
+
def initialize(some_argument)
|
61
|
+
@some_argument = some_argument
|
62
|
+
end
|
23
63
|
end
|
24
64
|
end
|
25
65
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module TestBench
|
2
|
+
module Fixture
|
3
|
+
module Controls
|
4
|
+
module Session
|
5
|
+
Message = TestBench::Session::Controls::Message
|
6
|
+
|
7
|
+
Exception = TestBench::Session::Controls::Exception
|
8
|
+
|
9
|
+
Status = TestBench::Session::Controls::Status
|
10
|
+
|
11
|
+
Path = TestBench::Session::Controls::Path
|
12
|
+
|
13
|
+
Title = TestBench::Session::Controls::Title
|
14
|
+
|
15
|
+
Text = TestBench::Session::Controls::Text
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -1,13 +1,14 @@
|
|
1
|
-
require 'test_bench/
|
1
|
+
require 'test_bench/output/controls'
|
2
2
|
|
3
|
-
require 'test_bench/fixture/controls/
|
4
|
-
require 'test_bench/fixture/controls/
|
3
|
+
require 'test_bench/fixture/controls/session'
|
4
|
+
require 'test_bench/fixture/controls/output'
|
5
|
+
|
6
|
+
require 'test_bench/fixture/controls/comment_style'
|
5
7
|
require 'test_bench/fixture/controls/exception'
|
8
|
+
require 'test_bench/fixture/controls/message'
|
9
|
+
require 'test_bench/fixture/controls/path'
|
10
|
+
require 'test_bench/fixture/controls/status'
|
11
|
+
require 'test_bench/fixture/controls/text'
|
6
12
|
require 'test_bench/fixture/controls/title'
|
7
13
|
|
8
14
|
require 'test_bench/fixture/controls/fixture'
|
9
|
-
require 'test_bench/fixture/controls/fixture/class'
|
10
|
-
require 'test_bench/fixture/controls/fixture/object/modules'
|
11
|
-
require 'test_bench/fixture/controls/fixture/object'
|
12
|
-
|
13
|
-
require 'test_bench/fixture/controls/output'
|
@@ -9,14 +9,20 @@ module TestBench
|
|
9
9
|
@block = block
|
10
10
|
end
|
11
11
|
|
12
|
-
def self.build(
|
12
|
+
def self.build(test_session:, &block)
|
13
13
|
instance = new(block)
|
14
|
-
|
14
|
+
|
15
|
+
Session.configure(
|
16
|
+
instance,
|
17
|
+
session: test_session,
|
18
|
+
attr_name: :test_session
|
19
|
+
)
|
20
|
+
|
15
21
|
instance
|
16
22
|
end
|
17
23
|
|
18
|
-
def self.call(
|
19
|
-
instance = build(
|
24
|
+
def self.call(test_session: nil, &block)
|
25
|
+
instance = build(test_session:, &block)
|
20
26
|
instance.()
|
21
27
|
instance
|
22
28
|
end
|
@@ -1,199 +1,211 @@
|
|
1
1
|
module TestBench
|
2
2
|
module Fixture
|
3
|
-
include TestBench::Session::Events
|
4
|
-
|
5
3
|
def test_session
|
6
4
|
@test_session ||= Session::Substitute.build
|
7
5
|
end
|
8
6
|
attr_writer :test_session
|
9
7
|
|
10
|
-
def
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
def comment(...)
|
16
|
-
Fixture.comment(test_session.telemetry, Commented, ...)
|
17
|
-
end
|
8
|
+
def self.assure_boolean(value, message_subject)
|
9
|
+
if not value == true || value == false
|
10
|
+
raise Session::Failure, "#{message_subject} given non-boolean value: #{value.inspect}"
|
11
|
+
end
|
18
12
|
|
19
|
-
|
20
|
-
Fixture.comment(test_session.telemetry, Detailed, ...)
|
13
|
+
return "#{message_subject} failed"
|
21
14
|
end
|
22
15
|
|
23
|
-
def assert(
|
24
|
-
|
25
|
-
raise TypeError, "Value #{result.inspect} isn't a boolean"
|
26
|
-
end
|
27
|
-
|
28
|
-
result = false if result.nil?
|
16
|
+
def assert(value)
|
17
|
+
failure_message = Fixture.assure_boolean(value, "Assertion")
|
29
18
|
|
30
|
-
test_session.assert(
|
19
|
+
test_session.assert(value, failure_message)
|
31
20
|
end
|
32
21
|
|
33
|
-
def refute(
|
34
|
-
|
35
|
-
raise TypeError, "Value #{result.inspect} isn't a boolean"
|
36
|
-
end
|
22
|
+
def refute(value)
|
23
|
+
failure_message = Fixture.assure_boolean(value, "Refutation")
|
37
24
|
|
38
|
-
|
25
|
+
negated_value = !value
|
39
26
|
|
40
|
-
test_session.assert(
|
27
|
+
test_session.assert(negated_value, failure_message)
|
41
28
|
end
|
42
29
|
|
43
30
|
def assert_raises(exception_class=nil, message=nil, strict: nil, &block)
|
44
31
|
if exception_class.nil?
|
45
|
-
strict
|
32
|
+
strict = false
|
46
33
|
exception_class = StandardError
|
47
|
-
else
|
48
|
-
strict = true if strict.nil?
|
49
34
|
end
|
50
35
|
|
51
|
-
|
36
|
+
if strict.nil?
|
37
|
+
strict = true
|
38
|
+
end
|
39
|
+
|
40
|
+
test_session.detail "Expected exception: #{exception_class}#{' (strict)' if strict}"
|
52
41
|
if not message.nil?
|
53
|
-
detail "Expected message: #{message.inspect}"
|
42
|
+
test_session.detail "Expected message: #{message.inspect}"
|
54
43
|
end
|
55
44
|
|
56
45
|
block.()
|
57
46
|
|
58
|
-
detail "(No exception was raised)"
|
59
|
-
|
60
47
|
rescue exception_class => exception
|
61
|
-
|
62
|
-
detail "Raised exception: #{exception.inspect}#{" (subclass of #{exception_class})" if exception.class < exception_class}"
|
48
|
+
test_session.detail "Raised exception: #{exception.inspect}#{" (subclass of #{exception_class})" if exception.class < exception_class}"
|
63
49
|
|
64
50
|
if strict && !exception.instance_of?(exception_class)
|
65
|
-
raise
|
51
|
+
raise
|
66
52
|
end
|
67
53
|
|
68
|
-
if message.nil?
|
69
|
-
|
54
|
+
if not message.nil?
|
55
|
+
assert(exception.message == message)
|
70
56
|
else
|
71
|
-
|
57
|
+
assert(true)
|
72
58
|
end
|
73
59
|
|
74
|
-
assert(result)
|
75
60
|
else
|
61
|
+
test_session.detail "(No exception was raised)"
|
76
62
|
assert(false)
|
77
63
|
end
|
78
64
|
|
79
65
|
def refute_raises(exception_class=nil, strict: nil, &block)
|
80
66
|
if exception_class.nil?
|
81
|
-
strict
|
67
|
+
strict = false
|
82
68
|
exception_class = StandardError
|
83
|
-
else
|
84
|
-
strict = true if strict.nil?
|
85
69
|
end
|
86
70
|
|
87
|
-
|
71
|
+
if strict.nil?
|
72
|
+
strict = true
|
73
|
+
end
|
74
|
+
|
75
|
+
test_session.detail "Prohibited exception: #{exception_class}#{' (strict)' if strict}"
|
88
76
|
|
89
77
|
block.()
|
90
78
|
|
91
|
-
detail "(No exception was raised)"
|
92
|
-
|
93
79
|
rescue exception_class => exception
|
94
80
|
|
95
|
-
detail "Raised exception: #{exception.inspect}#{" (subclass of #{exception_class})" if exception.class < exception_class}"
|
81
|
+
test_session.detail "Raised exception: #{exception.inspect}#{" (subclass of #{exception_class})" if exception.class < exception_class}"
|
96
82
|
|
97
83
|
if strict && !exception.instance_of?(exception_class)
|
98
|
-
raise
|
84
|
+
raise
|
99
85
|
end
|
100
86
|
|
101
87
|
assert(false)
|
88
|
+
|
102
89
|
else
|
90
|
+
test_session.detail "(No exception was raised)"
|
103
91
|
assert(true)
|
104
92
|
end
|
105
93
|
|
106
|
-
def
|
107
|
-
|
94
|
+
def self.comment_text_and_disposition(text_or_fixture, style: nil, disposition: nil)
|
95
|
+
case text_or_fixture
|
96
|
+
in String => text
|
97
|
+
style ||= Output::CommentStyle.detect
|
108
98
|
|
109
|
-
|
110
|
-
|
99
|
+
in Fixture => fixture
|
100
|
+
style ||= Output::CommentStyle.block
|
111
101
|
|
112
|
-
|
113
|
-
title = title&.to_str
|
102
|
+
test_session = fixture.test_session
|
114
103
|
|
115
|
-
|
116
|
-
end
|
104
|
+
text = Output::Get.(test_session)
|
117
105
|
|
118
|
-
|
119
|
-
|
106
|
+
in Object => object
|
107
|
+
style ||= Output::CommentStyle.detect
|
120
108
|
|
121
|
-
|
122
|
-
|
109
|
+
text = String.try_convert(object)
|
110
|
+
if text.nil?
|
111
|
+
raise TypeError, "no implicit conversion of #{object.class} into String"
|
112
|
+
end
|
113
|
+
end
|
123
114
|
|
124
|
-
|
125
|
-
title = title&.to_str
|
115
|
+
disposition ||= Output::CommentStyle.get_disposition(style)
|
126
116
|
|
127
|
-
|
117
|
+
return text, disposition
|
128
118
|
end
|
129
119
|
|
130
|
-
def
|
131
|
-
|
132
|
-
|
120
|
+
def comment(heading_text=nil, text_or_fixture, style: nil, disposition: nil)
|
121
|
+
if not heading_text.nil?
|
122
|
+
heading_style = Output::CommentStyle.heading
|
133
123
|
|
134
|
-
|
135
|
-
|
124
|
+
comment(heading_text, style: heading_style)
|
125
|
+
end
|
126
|
+
|
127
|
+
text, disposition = Fixture.comment_text_and_disposition(text_or_fixture, style:, disposition:)
|
136
128
|
|
137
|
-
|
129
|
+
test_session.comment(text, disposition)
|
138
130
|
end
|
139
131
|
|
140
|
-
def
|
141
|
-
|
132
|
+
def detail(heading_text=nil, text_or_fixture, style: nil, disposition: nil)
|
133
|
+
if not heading_text.nil?
|
134
|
+
heading_style = Output::CommentStyle.heading
|
142
135
|
|
143
|
-
|
144
|
-
text.to_str
|
136
|
+
detail(heading_text, style: heading_style)
|
145
137
|
end
|
146
138
|
|
147
|
-
|
148
|
-
quote = texts.last.end_with?("\n")
|
149
|
-
end
|
139
|
+
text, disposition = Fixture.comment_text_and_disposition(text_or_fixture, style:, disposition:)
|
150
140
|
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
141
|
+
test_session.detail(text, disposition)
|
142
|
+
end
|
143
|
+
|
144
|
+
def self.title(title)
|
145
|
+
if title.nil? || title.instance_of?(String)
|
146
|
+
return title
|
155
147
|
end
|
156
148
|
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
heading = nil
|
149
|
+
title_string = String.try_convert(title)
|
150
|
+
if title_string.nil?
|
151
|
+
raise TypeError, "can't convert #{title.class} into #{String}"
|
161
152
|
end
|
162
153
|
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
154
|
+
title_string
|
155
|
+
end
|
156
|
+
|
157
|
+
def test(title=nil, &block)
|
158
|
+
title = Fixture.title(title)
|
159
|
+
|
160
|
+
if block.nil?
|
161
|
+
skip_message = title
|
162
|
+
test_session.skip(skip_message)
|
163
|
+
return nil
|
167
164
|
end
|
168
165
|
|
169
|
-
|
170
|
-
event.text = text
|
171
|
-
event.quote = quote
|
172
|
-
event.heading = heading
|
166
|
+
result = test_session.test(title, &block)
|
173
167
|
|
174
|
-
|
168
|
+
Session::Result.resolve(result, strict: true)
|
169
|
+
end
|
175
170
|
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
end
|
171
|
+
def test!(...)
|
172
|
+
if not test(...)
|
173
|
+
throw(Session::ExecutionBreak)
|
180
174
|
end
|
181
175
|
end
|
182
176
|
|
183
|
-
def
|
184
|
-
|
177
|
+
def context(title=nil, &block)
|
178
|
+
title = Fixture.title(title)
|
179
|
+
|
180
|
+
if block.nil?
|
181
|
+
skip_message = title
|
182
|
+
test_session.skip(skip_message)
|
183
|
+
return nil
|
184
|
+
end
|
185
185
|
|
186
|
-
|
186
|
+
result = test_session.context(title, &block)
|
187
|
+
|
188
|
+
Session::Result.resolve(result, strict: true)
|
187
189
|
end
|
188
190
|
|
189
|
-
def
|
190
|
-
if
|
191
|
-
|
192
|
-
Actuate::Class.(fixture_class, ...)
|
193
|
-
else
|
194
|
-
object = fixture_class_or_object
|
195
|
-
Actuate::Object.(object, ...)
|
191
|
+
def context!(...)
|
192
|
+
if not context(...)
|
193
|
+
throw(Session::ExecutionBreak)
|
196
194
|
end
|
197
195
|
end
|
196
|
+
|
197
|
+
def execute(file_path)
|
198
|
+
test_session.execute(file_path)
|
199
|
+
end
|
200
|
+
|
201
|
+
def fixture(fixture_class, *, test_session: nil, **, &)
|
202
|
+
test_session ||= self.test_session
|
203
|
+
|
204
|
+
fixture = Build.(fixture_class, *, test_session:, **, &)
|
205
|
+
|
206
|
+
fixture.()
|
207
|
+
|
208
|
+
fixture
|
209
|
+
end
|
198
210
|
end
|
199
211
|
end
|
data/lib/test_bench/fixture.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
|
-
require 'test_bench/
|
1
|
+
require 'test_bench/output'
|
2
2
|
|
3
|
-
require 'test_bench/fixture/
|
4
|
-
require 'test_bench/fixture/actuate/object'
|
5
|
-
|
6
|
-
require 'test_bench/fixture/fixture'
|
3
|
+
require 'test_bench/fixture/build'
|
7
4
|
|
8
5
|
require 'test_bench/fixture/evaluate'
|
6
|
+
|
7
|
+
require 'test_bench/fixture/fixture'
|
metadata
CHANGED
@@ -1,17 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: test_bench-fixture
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0.0.pre.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
8
|
-
autorequire:
|
7
|
+
- Brightworks Digital
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date: 2023-07-27 00:00:00.000000000 Z
|
12
10
|
dependencies:
|
13
11
|
- !ruby/object:Gem::Dependency
|
14
|
-
name: test_bench-
|
12
|
+
name: test_bench-output
|
15
13
|
requirement: !ruby/object:Gem::Requirement
|
16
14
|
requirements:
|
17
15
|
- - ">="
|
@@ -25,7 +23,7 @@ dependencies:
|
|
25
23
|
- !ruby/object:Gem::Version
|
26
24
|
version: '0'
|
27
25
|
- !ruby/object:Gem::Dependency
|
28
|
-
name: test_bench-
|
26
|
+
name: test_bench-bootstrap
|
29
27
|
requirement: !ruby/object:Gem::Requirement
|
30
28
|
requirements:
|
31
29
|
- - ">="
|
@@ -38,32 +36,41 @@ dependencies:
|
|
38
36
|
- - ">="
|
39
37
|
- !ruby/object:Gem::Version
|
40
38
|
version: '0'
|
41
|
-
description:
|
42
|
-
|
39
|
+
description: A TestBench fixture is a pre-defined, reusable test abstraction. By including
|
40
|
+
TestBench::Fixture, any class can use the TestBench DSL. Fixture classes are typically
|
41
|
+
actuated as part of another TestBench test, but they can also be exercised and tested
|
42
|
+
in isolation.
|
43
|
+
email: development@bright.works
|
43
44
|
executables: []
|
44
45
|
extensions: []
|
45
46
|
extra_rdoc_files: []
|
46
47
|
files:
|
47
|
-
- lib/test_bench
|
48
|
-
- lib/test_bench/fixture
|
49
|
-
- lib/test_bench/fixture/
|
50
|
-
- lib/test_bench/fixture/controls
|
48
|
+
- lib/test_bench
|
49
|
+
- lib/test_bench/fixture
|
50
|
+
- lib/test_bench/fixture/build.rb
|
51
|
+
- lib/test_bench/fixture/controls
|
52
|
+
- lib/test_bench/fixture/controls/comment_style.rb
|
51
53
|
- lib/test_bench/fixture/controls/exception.rb
|
52
54
|
- lib/test_bench/fixture/controls/fixture.rb
|
53
|
-
- lib/test_bench/fixture/controls/
|
54
|
-
- lib/test_bench/fixture/controls/fixture/object.rb
|
55
|
-
- lib/test_bench/fixture/controls/fixture/object/modules.rb
|
55
|
+
- lib/test_bench/fixture/controls/message.rb
|
56
56
|
- lib/test_bench/fixture/controls/output.rb
|
57
|
-
- lib/test_bench/fixture/controls/
|
58
|
-
- lib/test_bench/fixture/controls/
|
57
|
+
- lib/test_bench/fixture/controls/path.rb
|
58
|
+
- lib/test_bench/fixture/controls/session.rb
|
59
|
+
- lib/test_bench/fixture/controls/status.rb
|
60
|
+
- lib/test_bench/fixture/controls/text.rb
|
59
61
|
- lib/test_bench/fixture/controls/title.rb
|
62
|
+
- lib/test_bench/fixture/controls.rb
|
60
63
|
- lib/test_bench/fixture/evaluate.rb
|
61
64
|
- lib/test_bench/fixture/fixture.rb
|
62
|
-
|
65
|
+
- lib/test_bench/fixture.rb
|
66
|
+
homepage: http://test-bench.software
|
63
67
|
licenses:
|
64
68
|
- MIT
|
65
|
-
metadata:
|
66
|
-
|
69
|
+
metadata:
|
70
|
+
homepage_uri: http://test-bench.software
|
71
|
+
source_code_uri: https://github.com/test-bench-demo/test-bench-fixture
|
72
|
+
allowed_push_host: https://rubygems.org
|
73
|
+
namespace: TestBench::Fixture
|
67
74
|
rdoc_options: []
|
68
75
|
require_paths:
|
69
76
|
- lib
|
@@ -78,8 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
78
85
|
- !ruby/object:Gem::Version
|
79
86
|
version: '0'
|
80
87
|
requirements: []
|
81
|
-
rubygems_version: 3.
|
82
|
-
signing_key:
|
88
|
+
rubygems_version: 3.6.9
|
83
89
|
specification_version: 4
|
84
|
-
summary:
|
90
|
+
summary: Pre-defined, reusable test abstractions using TestBench
|
85
91
|
test_files: []
|
@@ -1,95 +0,0 @@
|
|
1
|
-
module TestBench
|
2
|
-
module Fixture
|
3
|
-
module Actuate
|
4
|
-
module Class
|
5
|
-
Error = ::Class.new(RuntimeError)
|
6
|
-
|
7
|
-
def self.call(fixture_class, *, session: nil, **, &block)
|
8
|
-
if test_block?(fixture_class)
|
9
|
-
test_block = block
|
10
|
-
else
|
11
|
-
block_actuator = block
|
12
|
-
end
|
13
|
-
|
14
|
-
fixture = build_fixture(fixture_class, *, **, &test_block)
|
15
|
-
|
16
|
-
Session.configure(fixture, session:, attr_name: :test_session)
|
17
|
-
|
18
|
-
actuate(fixture, &block_actuator)
|
19
|
-
|
20
|
-
fixture
|
21
|
-
end
|
22
|
-
|
23
|
-
def self.actuate(fixture, &block_actuator)
|
24
|
-
if fixture.respond_to?(:call)
|
25
|
-
fixture_actuator = fixture
|
26
|
-
end
|
27
|
-
|
28
|
-
if block_actuator && fixture_actuator
|
29
|
-
raise Error, "Block argument given to fixture that has an actuator (Fixture Class: #{fixture.class})"
|
30
|
-
end
|
31
|
-
|
32
|
-
if block_actuator.nil? && fixture_actuator.nil?
|
33
|
-
raise Error, "No actuator"
|
34
|
-
end
|
35
|
-
|
36
|
-
if not block_actuator.nil?
|
37
|
-
block_actuator.(fixture)
|
38
|
-
else
|
39
|
-
fixture_actuator.()
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def self.build_fixture(fixture_class, ...)
|
44
|
-
constructor = constructor(fixture_class)
|
45
|
-
|
46
|
-
fixture_class.public_send(constructor, ...)
|
47
|
-
end
|
48
|
-
|
49
|
-
def self.test_block?(fixture_class)
|
50
|
-
assure_fixture(fixture_class)
|
51
|
-
|
52
|
-
constructor = constructor(fixture_class)
|
53
|
-
|
54
|
-
if constructor == :build
|
55
|
-
constructor_method = fixture_class.method(:build)
|
56
|
-
else
|
57
|
-
constructor_method = fixture_class.instance_method(:initialize)
|
58
|
-
end
|
59
|
-
|
60
|
-
constructor_parameters = constructor_method.parameters
|
61
|
-
|
62
|
-
constructor_parameters.any? do |(type, _)|
|
63
|
-
type == :block
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
def self.constructor(fixture_class)
|
68
|
-
assure_fixture(fixture_class)
|
69
|
-
|
70
|
-
if fixture_class.respond_to?(:build)
|
71
|
-
:build
|
72
|
-
else
|
73
|
-
:new
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
def self.assure_fixture(fixture_class)
|
78
|
-
is_class = fixture_class.instance_of?(::Class)
|
79
|
-
|
80
|
-
if not is_class
|
81
|
-
raise Error, "Not a class (Class: #{fixture_class})"
|
82
|
-
end
|
83
|
-
|
84
|
-
if is_class
|
85
|
-
is_fixture_class = fixture_class.included_modules.include?(Fixture)
|
86
|
-
end
|
87
|
-
|
88
|
-
if not is_fixture_class
|
89
|
-
raise Error, "Not a fixture class (Class: #{fixture_class})"
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
@@ -1,91 +0,0 @@
|
|
1
|
-
module TestBench
|
2
|
-
module Fixture
|
3
|
-
module Actuate
|
4
|
-
module Object
|
5
|
-
ModuleError = ::Class.new(RuntimeError)
|
6
|
-
|
7
|
-
def self.call(object, *modules, session: nil, &block_actuator)
|
8
|
-
extend(object, *modules)
|
9
|
-
|
10
|
-
Session.configure(object, session:, attr_name: :test_session)
|
11
|
-
|
12
|
-
block_actuator.(object)
|
13
|
-
end
|
14
|
-
|
15
|
-
def self.extend(object, *modules)
|
16
|
-
if modules.empty?
|
17
|
-
fixture_modules = fixture_modules(object)
|
18
|
-
else
|
19
|
-
fixture_modules = modules.map do |mod|
|
20
|
-
assure_included(object, mod)
|
21
|
-
|
22
|
-
fixture_module(mod)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
if fixture_modules.empty?
|
27
|
-
raise ModuleError, "No Fixture modules found -- #{object.inspect}"
|
28
|
-
end
|
29
|
-
|
30
|
-
fixture_modules.each do |fixture_module|
|
31
|
-
object.extend(fixture_module)
|
32
|
-
end
|
33
|
-
|
34
|
-
object.extend(Fixture)
|
35
|
-
end
|
36
|
-
|
37
|
-
def self.assure_included(object, mod)
|
38
|
-
if not object.is_a?(mod)
|
39
|
-
raise ModuleError, "Object doesn't include module -- #{mod.inspect}"
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def self.fixture_modules(object)
|
44
|
-
fixture_modules = []
|
45
|
-
|
46
|
-
targets = included_modules(object)
|
47
|
-
|
48
|
-
targets << object
|
49
|
-
|
50
|
-
targets.select do |target|
|
51
|
-
if fixture_module?(target)
|
52
|
-
fixture_module = fixture_module(target)
|
53
|
-
fixture_modules << fixture_module
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
fixture_modules
|
58
|
-
end
|
59
|
-
|
60
|
-
def self.fixture_module(object)
|
61
|
-
if not fixture_module?(object)
|
62
|
-
raise ModuleError, "Couldn't resolve a Fixture module -- #{object.inspect}"
|
63
|
-
end
|
64
|
-
|
65
|
-
target = fixture_module_target(object)
|
66
|
-
|
67
|
-
target.const_get(:Fixture, false)
|
68
|
-
end
|
69
|
-
|
70
|
-
def self.fixture_module?(object)
|
71
|
-
target = fixture_module_target(object)
|
72
|
-
|
73
|
-
target.const_defined?(:Fixture, false)
|
74
|
-
end
|
75
|
-
|
76
|
-
def self.fixture_module_target(object)
|
77
|
-
if object.is_a?(Module)
|
78
|
-
object
|
79
|
-
else
|
80
|
-
object.class
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
def self.included_modules(object)
|
85
|
-
modules = (object.class.included_modules | object.singleton_class.included_modules) - ::Object.included_modules
|
86
|
-
modules.sort_by(&:name)
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
@@ -1,86 +0,0 @@
|
|
1
|
-
module TestBench
|
2
|
-
module Fixture
|
3
|
-
module Controls
|
4
|
-
module Fixture
|
5
|
-
module Class
|
6
|
-
Example = Fixture::Example
|
7
|
-
|
8
|
-
class BuildMethod
|
9
|
-
include TestBench::Fixture
|
10
|
-
|
11
|
-
attr_accessor :some_argument
|
12
|
-
attr_accessor :some_keyword_argument
|
13
|
-
|
14
|
-
def self.build(some_argument=nil, some_keyword_argument: nil)
|
15
|
-
instance = new
|
16
|
-
instance.some_argument = some_argument
|
17
|
-
instance.some_keyword_argument = some_keyword_argument
|
18
|
-
instance
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
class NoBuildMethod
|
23
|
-
include TestBench::Fixture
|
24
|
-
|
25
|
-
attr_reader :some_argument
|
26
|
-
attr_reader :some_keyword_argument
|
27
|
-
|
28
|
-
def initialize(some_argument=nil, some_keyword_argument: nil)
|
29
|
-
@some_argument = some_argument
|
30
|
-
@some_keyword_argument = some_keyword_argument
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
class TestBlock
|
35
|
-
include TestBench::Fixture
|
36
|
-
|
37
|
-
attr_reader :test_block
|
38
|
-
|
39
|
-
def initialize(&test_block)
|
40
|
-
@test_block = test_block
|
41
|
-
end
|
42
|
-
|
43
|
-
NoBuildMethod = TestBlock
|
44
|
-
|
45
|
-
class BuildMethod
|
46
|
-
include TestBench::Fixture
|
47
|
-
|
48
|
-
attr_reader :test_block
|
49
|
-
|
50
|
-
def initialize(test_block)
|
51
|
-
@test_block = test_block
|
52
|
-
end
|
53
|
-
|
54
|
-
def self.build(&test_block)
|
55
|
-
new(test_block)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
None = Fixture::Class::BuildMethod
|
60
|
-
end
|
61
|
-
|
62
|
-
class Actuator
|
63
|
-
include TestBench::Fixture
|
64
|
-
|
65
|
-
attr_accessor :actuated
|
66
|
-
def actuated? = !!actuated
|
67
|
-
|
68
|
-
def call
|
69
|
-
self.actuated = true
|
70
|
-
end
|
71
|
-
|
72
|
-
class TestBlock < Actuator
|
73
|
-
attr_reader :test_block
|
74
|
-
|
75
|
-
def initialize(&test_block)
|
76
|
-
@test_block = test_block
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
NoActuator = Example
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
module TestBench
|
2
|
-
module Fixture
|
3
|
-
module Controls
|
4
|
-
module Fixture
|
5
|
-
module Object
|
6
|
-
module Modules
|
7
|
-
def self.included
|
8
|
-
[Extended, Included, NoFixture]
|
9
|
-
end
|
10
|
-
|
11
|
-
module Included
|
12
|
-
def self.example
|
13
|
-
self
|
14
|
-
end
|
15
|
-
|
16
|
-
module Fixture
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
module Extended
|
21
|
-
def self.example
|
22
|
-
self
|
23
|
-
end
|
24
|
-
|
25
|
-
module Fixture
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
module NoFixture
|
30
|
-
def self.example
|
31
|
-
self
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
module TestBench
|
2
|
-
module Fixture
|
3
|
-
module Controls
|
4
|
-
module Fixture
|
5
|
-
module Object
|
6
|
-
def self.example
|
7
|
-
object = Example.new
|
8
|
-
object.extend(Modules::Extended)
|
9
|
-
object
|
10
|
-
end
|
11
|
-
|
12
|
-
def self.fixture_modules
|
13
|
-
[
|
14
|
-
Modules::Extended::Fixture,
|
15
|
-
Modules::Included::Fixture,
|
16
|
-
Example::Fixture
|
17
|
-
]
|
18
|
-
end
|
19
|
-
|
20
|
-
class Example
|
21
|
-
include Modules::Included
|
22
|
-
include Modules::NoFixture
|
23
|
-
|
24
|
-
module Fixture
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|