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
23
# File 'lib/cucumber/core/test/case.rb', line 12

def initialize(id, name, test_steps, location, parent_locations, tags, language, around_hooks = [])
  raise ArgumentError, "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



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

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

#describe_to(visitor, *args) ⇒ Object



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

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)


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

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

#hashObject



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

def hash
  location.hash
end

#inspectObject



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

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

#match_locations?(queried_locations) ⇒ Boolean

Returns:

  • (Boolean)


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

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)


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

def match_name?(name_regexp)
  name =~ name_regexp
end

#match_tags?(*expressions) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#matching_locationsObject



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

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

#step_countObject



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

def step_count
  test_steps.count
end

#with_around_hooks(around_hooks) ⇒ Object



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

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



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

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