Class: RSpec::Core::World
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Hooks
#after, #around, #before, #hooks, #run_hook, #run_hook!, #run_hook_filtered
Constructor Details
#initialize(configuration = RSpec.configuration) ⇒ World
Returns a new instance of World.
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/rspec/core/world.rb', line 8
def initialize(configuration=RSpec.configuration)
@configuration = configuration
@example_groups = []
@filtered_examples = Hash.new { |hash,group|
hash[group] = begin
examples = group.examples.dup
examples = apply_exclusion_filters(examples, exclusion_filter) if exclusion_filter
examples = apply_inclusion_filters(examples, inclusion_filter) if inclusion_filter
examples.uniq
end
}
end
|
Instance Attribute Details
#example_groups ⇒ Object
Returns the value of attribute example_groups.
5
6
7
|
# File 'lib/rspec/core/world.rb', line 5
def example_groups
@example_groups
end
|
#filtered_examples ⇒ Object
Returns the value of attribute filtered_examples.
5
6
7
|
# File 'lib/rspec/core/world.rb', line 5
def filtered_examples
@filtered_examples
end
|
#wants_to_quit ⇒ Object
Returns the value of attribute wants_to_quit.
5
6
7
|
# File 'lib/rspec/core/world.rb', line 5
def wants_to_quit
@wants_to_quit
end
|
Instance Method Details
#announce_exclusion_filter ⇒ Object
69
70
71
72
73
74
75
|
# File 'lib/rspec/core/world.rb', line 69
def announce_exclusion_filter
if exclusion_filter && RSpec.world.example_count.zero?
@configuration.reporter.message(
"No examples were matched. Perhaps #{exclusion_filter.inspect} is excluding everything?")
example_groups.clear
end
end
|
#announce_inclusion_filter ⇒ Object
57
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/rspec/core/world.rb', line 57
def announce_inclusion_filter
if inclusion_filter
if @configuration.run_all_when_everything_filtered? && RSpec.world.example_count.zero?
@configuration.reporter.message "No examples were matched by #{inclusion_filter.inspect}, running all"
@configuration.clear_inclusion_filter
filtered_examples.clear
else
@configuration.reporter.message "Run filtered using #{inclusion_filter.inspect}"
end
end
end
|
#apply_exclusion_filters(examples, conditions = {}) ⇒ Object
47
48
49
|
# File 'lib/rspec/core/world.rb', line 47
def apply_exclusion_filters(examples, conditions={})
examples.reject(&all_apply?(conditions))
end
|
#apply_inclusion_filters(examples, conditions = {}) ⇒ Object
Also known as:
find
41
42
43
|
# File 'lib/rspec/core/world.rb', line 41
def apply_inclusion_filters(examples, conditions={})
examples.select(&all_apply?(conditions))
end
|
29
30
31
|
# File 'lib/rspec/core/world.rb', line 29
def configure_group(group)
@configuration.configure_group(group)
end
|
#example_count ⇒ Object
37
38
39
|
# File 'lib/rspec/core/world.rb', line 37
def example_count
example_groups.collect {|g| g.descendants}.flatten.inject(0) { |sum, g| sum += g.filtered_examples.size }
end
|
#exclusion_filter ⇒ Object
25
26
27
|
# File 'lib/rspec/core/world.rb', line 25
def exclusion_filter
@configuration.exclusion_filter
end
|
#find_hook(hook, scope, group) ⇒ Object
79
80
81
|
# File 'lib/rspec/core/world.rb', line 79
def find_hook(hook, scope, group)
@configuration.find_hook(hook, scope, group)
end
|
#inclusion_filter ⇒ Object
21
22
23
|
# File 'lib/rspec/core/world.rb', line 21
def inclusion_filter
@configuration.filter
end
|
#preceding_declaration_line(filter_line) ⇒ Object
51
52
53
54
55
|
# File 'lib/rspec/core/world.rb', line 51
def preceding_declaration_line(filter_line)
declaration_line_numbers.inject(nil) do |highest_prior_declaration_line, line|
line <= filter_line ? line : highest_prior_declaration_line
end
end
|
#shared_example_groups ⇒ Object
33
34
35
|
# File 'lib/rspec/core/world.rb', line 33
def shared_example_groups
@shared_example_groups ||= {}
end
|