class Cucumber::Core::Test::Case
Attributes
around_hooks[R]
source[R]
test_steps[R]
Public Class Methods
new(test_steps, source, around_hooks = [])
click to toggle source
# File lib/cucumber/core/test/case.rb, line 13 def initialize(test_steps, source, around_hooks = []) raise ArgumentError.new("test_steps should be an Array but is a #{test_steps.class}") unless test_steps.kind_of?(Array) @test_steps = test_steps @source = source @around_hooks = around_hooks end
Public Instance Methods
==(other)
click to toggle source
# File lib/cucumber/core/test/case.rb, line 112 def ==(other) eql?(other) end
all_locations()
click to toggle source
# File lib/cucumber/core/test/case.rb, line 88 def all_locations @all_locations ||= Ast::Location.merge(all_source.map(&:all_locations).flatten) end
all_source()
click to toggle source
# File lib/cucumber/core/test/case.rb, line 92 def all_source @all_source ||= (source + test_steps.map(&:source)).flatten.uniq end
describe_source_to(visitor, *args)
click to toggle source
# File lib/cucumber/core/test/case.rb, line 35 def describe_source_to(visitor, *args) source.reverse.each do |node| node.describe_to(visitor, *args) end self end
describe_to(visitor, *args)
click to toggle source
# File lib/cucumber/core/test/case.rb, line 24 def describe_to(visitor, *args) visitor.test_case(self, *args) do |child_visitor| compose_around_hooks(child_visitor, *args) do test_steps.each do |test_step| test_step.describe_to(child_visitor, *args) end end end self end
eql?(other)
click to toggle source
# File lib/cucumber/core/test/case.rb, line 108 def eql?(other) other.hash == hash end
feature()
click to toggle source
# File lib/cucumber/core/test/case.rb, line 100 def feature source.first end
hash()
click to toggle source
# File lib/cucumber/core/test/case.rb, line 104 def hash location.hash end
inspect()
click to toggle source
# File lib/cucumber/core/test/case.rb, line 96 def inspect "#<#{self.class}: #{location}>" end
keyword()
click to toggle source
# File lib/cucumber/core/test/case.rb, line 54 def keyword @keyword ||= NameBuilder.new(self).keyword end
language()
click to toggle source
# File lib/cucumber/core/test/case.rb, line 70 def language feature.language end
location()
click to toggle source
# File lib/cucumber/core/test/case.rb, line 74 def location source.last.location end
match_locations?(queried_locations)
click to toggle source
# File lib/cucumber/core/test/case.rb, line 78 def match_locations?(queried_locations) queried_locations.any? { |queried_location| all_source.any? { |node| node.all_locations.any? { |location| queried_location.match? location } } } end
match_name?(name_regexp)
click to toggle source
# File lib/cucumber/core/test/case.rb, line 66 def match_name?(name_regexp) source.any? { |node| node.respond_to?(:name) && node.name =~ name_regexp } end
name()
click to toggle source
# File lib/cucumber/core/test/case.rb, line 50 def name @name ||= NameBuilder.new(self).result end
step_count()
click to toggle source
# File lib/cucumber/core/test/case.rb, line 20 def step_count test_steps.count end
with_around_hooks(around_hooks)
click to toggle source
# File lib/cucumber/core/test/case.rb, line 46 def with_around_hooks(around_hooks) self.class.new(test_steps, source, around_hooks) end
with_steps(test_steps)
click to toggle source
# File lib/cucumber/core/test/case.rb, line 42 def with_steps(test_steps) self.class.new(test_steps, source, around_hooks) end
Private Instance Methods
compose_around_hooks(visitor, *args, &block)
click to toggle source
# File lib/cucumber/core/test/case.rb, line 118 def compose_around_hooks(visitor, *args, &block) around_hooks.reverse.reduce(block) do |continue, hook| -> { hook.describe_to(visitor, *args, &continue) } end.call end
match_single_tag_expression?(expression)
click to toggle source
# File lib/cucumber/core/test/case.rb, line 124 def match_single_tag_expression?(expression) if old_style_tag_expression?(expression) Cucumber::Core::Gherkin::TagExpression.new([expression]).evaluate(tags) else Cucumber::TagExpressions::Parser.new.parse(expression).evaluate(tags.map(&:name)) end end
old_style_tag_expression?(expression)
click to toggle source
# File lib/cucumber/core/test/case.rb, line 132 def old_style_tag_expression?(expression) expression.include?(',') || expression.include?('~') end