Top Level Namespace
Defined Under Namespace
Modules: LogicHelper, TokenUtil
Classes: BoolConverter, DefaultConverter, FloatConverter, IntConverter, Operator, ParameterGenerator, Rast, RastSpec, Rule, RuleEvaluator, RuleProcessor, RuleValidator, SpecDSL, StrConverter
Instance Method Summary
collapse
-
#_it_title(expected, scenario) ⇒ Object
-
#append_exclusion_title ⇒ Object
-
#append_inclusion_title ⇒ Object
-
#build_it(scenario, output, key) ⇒ Object
-
#build_title ⇒ Object
-
#execute_and_format_result(scope, block_params) ⇒ Object
-
#generate_rspec(scope: nil, scenario: {}, expected: '') ⇒ Object
-
#rast(rasted_subject, &block) ⇒ Object
-
#spec(subject: nil, name: '', fixtures: [], spec_id: '', &block) ⇒ Object
-
#xrast(rasted_subject) ⇒ Object
Instance Method Details
#_it_title(expected, scenario) ⇒ Object
157
158
159
160
161
162
163
|
# File 'lib/rast/spec_dsl.rb', line 157
def _it_title(expected, scenario)
spec_params = scenario.keys.inject('') do |output, key|
build_it(scenario, output, key)
end
"[#{expected}]=[#{spec_params}]"
end
|
#append_exclusion_title ⇒ Object
121
122
123
124
125
|
# File 'lib/rast/spec_dsl.rb', line 121
def append_exclusion_title
exclusion = @fixtures.first[:spec].exclude_clause
exclusion = exclusion.join if exclusion.is_a? Array
exclusion ? ", EXCLUDE: '#{exclusion}'" : ''
end
|
#append_inclusion_title ⇒ Object
127
128
129
130
131
|
# File 'lib/rast/spec_dsl.rb', line 127
def append_inclusion_title
inclusion = @fixtures.first[:spec].include_clause
inclusion = inclusion.join if inclusion.is_a? Array
inclusion ? ", ONLY: '#{inclusion}'" : ''
end
|
#build_it(scenario, output, key) ⇒ Object
165
166
167
168
169
|
# File 'lib/rast/spec_dsl.rb', line 165
def build_it(scenario, output, key)
output += ', ' unless output == ''
calc_key = scenario[key].nil? ? 'nil' : scenario[key]
output + "#{key}: #{calc_key}"
end
|
152
153
154
155
|
# File 'lib/rast/spec_dsl.rb', line 152
def execute_and_format_result(scope, block_params)
actual = scope.execute_block.call(*block_params)
actual.nil? ? 'nil' : actual.to_s
end
|
#generate_rspec(scope: nil, scenario: {}, expected: '') ⇒ Object
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
# File 'lib/rast/spec_dsl.rb', line 133
def generate_rspec(scope: nil, scenario: {}, expected: '')
it _it_title(expected, scenario) do
block_params = scenario.values
@mysubject = scope.subject
class << self
define_method(:subject) { @mysubject }
end
unless scope.prepare_block.nil?
instance_exec(*block_params, &scope.prepare_block)
end
actual = execute_and_format_result(scope, block_params)
expect(actual).to eq(expected)
end
end
|
#rast(rasted_subject, &block) ⇒ Object
53
54
55
|
# File 'lib/rast.rb', line 53
def rast(rasted_subject, &block)
Rast.new(rasted_subject, &block)
end
|
#spec(subject: nil, name: '', fixtures: [], spec_id: '', &block) ⇒ Object
172
173
174
175
176
177
178
179
180
|
# File 'lib/rast/spec_dsl.rb', line 172
def spec(subject: nil, name: '', fixtures: [], spec_id: '', &block)
SpecDSL.new(
subject: subject,
name: name,
fixtures: fixtures,
spec_id: spec_id,
&block
)
end
|
#xrast(rasted_subject) ⇒ Object
57
58
59
|
# File 'lib/rast.rb', line 57
def xrast(rasted_subject)
p "xrast skipped #{rasted_subject}"
end
|