Class: Smartest::TestCase
- Inherits:
-
Object
- Object
- Smartest::TestCase
- Defined in:
- lib/smartest/test_case.rb
Instance Attribute Summary collapse
-
#around_test_hooks ⇒ Object
readonly
Returns the value of attribute around_test_hooks.
-
#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:, around_test_hooks: []) ⇒ TestCase
constructor
A new instance of TestCase.
Constructor Details
#initialize(name:, metadata:, block:, location:, around_test_hooks: []) ⇒ TestCase
Returns a new instance of TestCase.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/smartest/test_case.rb', line 7 def initialize(name:, metadata:, block:, location:, around_test_hooks: []) 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 @around_test_hooks = around_test_hooks.dup.freeze @fixture_names = ParameterExtractor.required_keyword_names(block, usage: :test) end |
Instance Attribute Details
#around_test_hooks ⇒ Object (readonly)
Returns the value of attribute around_test_hooks.
5 6 7 |
# File 'lib/smartest/test_case.rb', line 5 def around_test_hooks @around_test_hooks end |
#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
19 20 21 |
# File 'lib/smartest/test_case.rb', line 19 def includes_line?(line) includes_line_range?(line..line) end |
#includes_line_range?(range) ⇒ Boolean
23 24 25 26 27 28 |
# File 'lib/smartest/test_case.rb', line 23 def includes_line_range?(range) return false unless location current_range = line_range current_range.begin <= range.end && range.begin <= current_range.end end |