Class: Cucumber::Core::Test::Case

Inherits:
Object
  • Object
show all
Defined in:
lib/cucumber/core/test/case.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, name, test_steps, location, parent_locations, tags, language, around_hooks = []) ⇒ Case

Returns a new instance of Case.

Raises:

  • (ArgumentError)


12
13
14
15
16
17
18
19
20
21
22
# File 'lib/cucumber/core/test/case.rb', line 12

def initialize(id, name, test_steps, location, parent_locations, tags, language, around_hooks = [])
  raise ArgumentError.new("test_steps should be an Array but is a #{test_steps.class}") unless test_steps.is_a?(Array)
  @id = id
  @name = name
  @test_steps = test_steps
  @location = location
  @parent_locations = parent_locations
  @tags = tags
  @language = language
  @around_hooks = around_hooks
end

Instance Attribute Details

#around_hooksObject (readonly)

Returns the value of attribute around_hooks.



10
11
12
# File 'lib/cucumber/core/test/case.rb', line 10

def around_hooks
  @around_hooks
end

#idObject (readonly)

Returns the value of attribute id.



10
11
12
# File 'lib/cucumber/core/test/case.rb', line 10

def id
  @id
end

#languageObject (readonly)

Returns the value of attribute language.



10
11
12
# File 'lib/cucumber/core/test/case.rb', line 10

def language
  @language
end

#locationObject (readonly)

Returns the value of attribute location.



10
11
12
# File 'lib/cucumber/core/test/case.rb', line 10

def location
  @location
end

#nameObject (readonly)

Returns the value of attribute name.



10
11
12
# File 'lib/cucumber/core/test/case.rb', line 10

def name
  @name
end

#parent_locationsObject (readonly)

Returns the value of attribute parent_locations.



10
11
12
# File 'lib/cucumber/core/test/case.rb', line 10

def parent_locations
  @parent_locations
end

#tagsObject (readonly)

Returns the value of attribute tags.



10
11
12
# File 'lib/cucumber/core/test/case.rb', line 10

def tags
  @tags
end

#test_stepsObject (readonly)

Returns the value of attribute test_steps.



10
11
12
# File 'lib/cucumber/core/test/case.rb', line 10

def test_steps
  @test_steps
end

Instance Method Details

#==(other) ⇒ Object



84
85
86
# File 'lib/cucumber/core/test/case.rb', line 84

def ==(other)
  eql?(other)
end

#describe_to(visitor, *args) ⇒ Object



28
29
30
31
32
33
34
35
36
37
# File 'lib/cucumber/core/test/case.rb', line 28

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) ⇒ Boolean

Returns:

  • (Boolean)


80
81
82
# File 'lib/cucumber/core/test/case.rb', line 80

def eql?(other)
  other.hash == hash
end

#hashObject



76
77
78
# File 'lib/cucumber/core/test/case.rb', line 76

def hash
  location.hash
end

#inspectObject



72
73
74
# File 'lib/cucumber/core/test/case.rb', line 72

def inspect
  "#<#{self.class}: #{location}>"
end

#match_locations?(queried_locations) ⇒ Boolean

Returns:

  • (Boolean)


55
56
57
58
59
60
61
# File 'lib/cucumber/core/test/case.rb', line 55

def match_locations?(queried_locations)
  queried_locations.any? do |queried_location|
    matching_locations.any? do |location|
      queried_location.match? location
    end
  end
end

#match_name?(name_regexp) ⇒ Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/cucumber/core/test/case.rb', line 51

def match_name?(name_regexp)
  name =~ name_regexp
end

#match_tags?(*expressions) ⇒ Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/cucumber/core/test/case.rb', line 47

def match_tags?(*expressions)
  expressions.flatten.all? { |expression| match_single_tag_expression?(expression) }
end

#matching_locationsObject



63
64
65
66
67
68
69
70
# File 'lib/cucumber/core/test/case.rb', line 63

def matching_locations
  [
    parent_locations,
    location,
    tags.map(&:location),
    test_steps.map(&:matching_locations)
  ].flatten
end

#step_countObject



24
25
26
# File 'lib/cucumber/core/test/case.rb', line 24

def step_count
  test_steps.count
end

#with_around_hooks(around_hooks) ⇒ Object



43
44
45
# File 'lib/cucumber/core/test/case.rb', line 43

def with_around_hooks(around_hooks)
  self.class.new(id, name, test_steps, location, parent_locations, tags, language, around_hooks)
end

#with_steps(test_steps) ⇒ Object



39
40
41
# File 'lib/cucumber/core/test/case.rb', line 39

def with_steps(test_steps)
  self.class.new(id, name, test_steps, location, parent_locations, tags, language, around_hooks)
end