Class: Smartest::TestCase
- Inherits:
-
Object
- Object
- Smartest::TestCase
- Defined in:
- lib/smartest/test_case.rb
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#fixture_names ⇒ Object
readonly
Returns the value of attribute fixture_names.
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #includes_line?(line) ⇒ Boolean
- #includes_line_range?(range) ⇒ Boolean
-
#initialize(name:, metadata:, block:, location:) ⇒ TestCase
constructor
A new instance of TestCase.
Constructor Details
#initialize(name:, metadata:, block:, location:) ⇒ TestCase
Returns a new instance of TestCase.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/smartest/test_case.rb', line 7 def initialize(name:, metadata:, block:, location:) raise ArgumentError, "test name is required" if name.nil? || name.to_s.empty? raise ArgumentError, "test block is required" unless block @name = name.to_s @metadata = @block = block @location = location @fixture_names = ParameterExtractor.required_keyword_names(block, usage: :test) end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
5 6 7 |
# File 'lib/smartest/test_case.rb', line 5 def block @block end |
#fixture_names ⇒ Object (readonly)
Returns the value of attribute fixture_names.
5 6 7 |
# File 'lib/smartest/test_case.rb', line 5 def fixture_names @fixture_names end |
#location ⇒ Object (readonly)
Returns the value of attribute location.
5 6 7 |
# File 'lib/smartest/test_case.rb', line 5 def location @location end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
5 6 7 |
# File 'lib/smartest/test_case.rb', line 5 def @metadata end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/smartest/test_case.rb', line 5 def name @name end |
Instance Method Details
#includes_line?(line) ⇒ Boolean
18 19 20 |
# File 'lib/smartest/test_case.rb', line 18 def includes_line?(line) includes_line_range?(line..line) end |
#includes_line_range?(range) ⇒ Boolean
22 23 24 25 26 27 |
# File 'lib/smartest/test_case.rb', line 22 def includes_line_range?(range) return false unless location current_range = line_range current_range.begin <= range.end && range.begin <= current_range.end end |