Class: Omnitest::Skeptic
- Inherits:
-
Object
show all
- Extended by:
- Core::Configurable
- Defined in:
- lib/omnitest/skeptic.rb,
lib/omnitest/skeptic/cli.rb,
lib/omnitest/skeptic/spy.rb,
lib/omnitest/skeptic/spies.rb,
lib/omnitest/skeptic/errors.rb,
lib/omnitest/skeptic/result.rb,
lib/omnitest/skeptic/version.rb,
lib/omnitest/skeptic/evidence.rb,
lib/omnitest/skeptic/scenario.rb,
lib/omnitest/skeptic/validator.rb,
lib/omnitest/skeptic/validation.rb,
lib/omnitest/skeptic/configuration.rb,
lib/omnitest/skeptic/test_manifest.rb,
lib/omnitest/skeptic/test_statuses.rb,
lib/omnitest/skeptic/test_transitions.rb,
lib/omnitest/skeptic/validator_registry.rb,
lib/omnitest/skeptic/property_definition.rb,
lib/omnitest/skeptic/scenario_definition.rb
Defined Under Namespace
Modules: Spies, TestStatuses, TestTransitions
Classes: BaseCLI, CLI, Configuration, Evidence, FeatureNotImplementedError, PropertyDefinition, Result, Scenario, ScenarioCheckError, ScenarioDefinition, ScenarioFailure, Spy, TestManifest, Validation, ValidationFailure, Validator, ValidatorRegistry
Constant Summary
collapse
- VERSION =
'0.0.3'
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(psychic = Psychic.new) ⇒ Skeptic
Returns a new instance of Skeptic.
54
55
56
57
|
# File 'lib/omnitest/skeptic.rb', line 54
def initialize(psychic = Psychic.new)
psychic = Psychic.new(psychic) if psychic.is_a? Hash
@psychic = psychic
end
|
Class Method Details
.acts_on_scenario(action) ⇒ Object
27
28
29
30
31
32
33
|
# File 'lib/omnitest/skeptic.rb', line 27
def acts_on_scenario(action)
define_method action do | regex = 'all', options = {} |
scenarios(regex, options).each do | scenario |
scenario.public_send(action)
end
end
end
|
.acts_on_scenario_with_options(action) ⇒ Object
35
36
37
38
39
40
41
|
# File 'lib/omnitest/skeptic.rb', line 35
def acts_on_scenario_with_options(action)
define_method action do | regex = 'all', options = {} |
scenarios(regex, options).each do | scenario |
scenario.public_send(action, options)
end
end
end
|
.validate(desc, scope = { suite: //, scenario: // }, &block) ⇒ Object
45
46
47
48
49
50
51
|
# File 'lib/omnitest/skeptic.rb', line 45
def validate(desc, scope = { suite: //, scenario: // }, &block)
fail ArgumentError, 'You must pass block' unless block_given?
validator = Omnitest::Skeptic::Validator.new(desc, scope, &block)
Omnitest::Skeptic::ValidatorRegistry.register validator
validator
end
|
Instance Method Details
#all_scenarios ⇒ Object
77
78
79
|
# File 'lib/omnitest/skeptic.rb', line 77
def all_scenarios
@scenarios ||= build_scenarios
end
|
#build_scenarios ⇒ Object
67
68
69
70
71
|
# File 'lib/omnitest/skeptic.rb', line 67
def build_scenarios
scenario_definitions.map do | scenario_definition |
scenario_definition.build @psychic
end
end
|
#manifest ⇒ Object
59
60
61
|
# File 'lib/omnitest/skeptic.rb', line 59
def manifest
Skeptic.configuration.manifest
end
|
#scenario(name) ⇒ Object
73
74
75
|
# File 'lib/omnitest/skeptic.rb', line 73
def scenario(name)
scenarios.find { |s| s.name == name }
end
|
#scenario_definitions ⇒ Object
63
64
65
|
# File 'lib/omnitest/skeptic.rb', line 63
def scenario_definitions
manifest.scenario_definitions
end
|
#scenarios(regexp = 'all', options = {}) ⇒ Object
97
98
99
100
101
102
103
|
# File 'lib/omnitest/skeptic.rb', line 97
def scenarios(regexp = 'all', options = {})
selected_scenarios = select_scenarios regexp
selected_scenarios.keep_if { |scenario| scenario.failed? == options[:failed] } unless options[:failed].nil?
selected_scenarios.keep_if { |scenario| scenario.skipped? == options[:skipped] } unless options[:skipped].nil?
selected_scenarios.keep_if { |scenario| scenario.sample? == options[:samples] } unless options[:samples].nil?
selected_scenarios
end
|
#select_scenarios(regexp) ⇒ Object
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
# File 'lib/omnitest/skeptic.rb', line 81
def select_scenarios(regexp)
regexp ||= 'all'
if regexp == 'all'
return all_scenarios
else
selected_scenarios = all_scenarios.find { |c| c.full_name == regexp } ||
all_scenarios.select { |c| c.full_name =~ /#{regexp}/i }
end
if selected_scenarios.is_a? Array
selected_scenarios
else
[selected_scenarios]
end
end
|
#summary ⇒ Object
105
106
107
108
109
110
111
112
113
|
# File 'lib/omnitest/skeptic.rb', line 105
def summary
summary_data = ["#{scenarios.size} scenarios"]
scenarios.group_by(&:status).each do | _status, group |
status_description = group.first.status_description.gsub(/\(.*/, '')
summary_data << "#{group.size} #{status_description.downcase}"
end
summary_data.join("\n ")
end
|