Class: RSpec::Abq::TestCase
- Inherits:
-
Object
- Object
- RSpec::Abq::TestCase
- Defined in:
- lib/rspec/abq/test_case.rb
Overview
ABQ’s representation of a test case
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#meta ⇒ Object
readonly
Returns the value of attribute meta.
-
#rerun_file_path ⇒ Object
readonly
Returns the value of attribute rerun_file_path.
-
#scoped_id ⇒ Object
readonly
Returns the value of attribute scoped_id.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
Class Method Summary collapse
-
.end_marker ⇒ Object
Faux test case to mark end of all tests.
-
.parse_scope(scope) ⇒ Object
Parses a scope n:m:q:r into [n, m, q, r] Invariant of RSpec is that a scope n:m:q:r is contained in a scope n:m:q.
-
.scope_contains(outer, inner) ⇒ Object
‘scope_contains outer inner` is true iff the inner scope is deeper than the outer scope.
-
.scope_leftover(outer, inner) ⇒ Object
‘scope_leftover outer inner` returns the partial scopes of `inner` that are deeper than `outer`.
Instance Method Summary collapse
- #directly_in_group?(group) ⇒ Boolean
- #in_group?(group) ⇒ Boolean
-
#initialize(id, tags, meta) ⇒ TestCase
constructor
A new instance of TestCase.
- #is_example?(example) ⇒ Boolean
Constructor Details
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
13 14 15 |
# File 'lib/rspec/abq/test_case.rb', line 13 def id @id end |
#meta ⇒ Object (readonly)
Returns the value of attribute meta.
15 16 17 |
# File 'lib/rspec/abq/test_case.rb', line 15 def @meta end |
#rerun_file_path ⇒ Object (readonly)
Returns the value of attribute rerun_file_path.
16 17 18 |
# File 'lib/rspec/abq/test_case.rb', line 16 def rerun_file_path @rerun_file_path end |
#scoped_id ⇒ Object (readonly)
Returns the value of attribute scoped_id.
17 18 19 |
# File 'lib/rspec/abq/test_case.rb', line 17 def scoped_id @scoped_id end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
14 15 16 |
# File 'lib/rspec/abq/test_case.rb', line 14 def @tags end |
Class Method Details
.end_marker ⇒ Object
Faux test case to mark end of all tests. Will never match any group or test ID, since the scoped_id is empty.
68 69 70 |
# File 'lib/rspec/abq/test_case.rb', line 68 def self.end_marker @end_marker ||= TestCase.new("[]", [], {}) end |
.parse_scope(scope) ⇒ Object
Parses a scope n:m:q:r into [n, m, q, r] Invariant of RSpec is that a scope n:m:q:r is contained in a scope n:m:q
21 22 23 |
# File 'lib/rspec/abq/test_case.rb', line 21 def self.parse_scope(scope) scope.split(":") end |
.scope_contains(outer, inner) ⇒ Object
‘scope_contains outer inner` is true iff the inner scope is deeper than the outer scope.
30 31 32 |
# File 'lib/rspec/abq/test_case.rb', line 30 def self.scope_contains(outer, inner) inner.take(outer.length) == outer end |
.scope_leftover(outer, inner) ⇒ Object
‘scope_leftover outer inner` returns the partial scopes of `inner` that are deeper than `outer`.
39 40 41 |
# File 'lib/rspec/abq/test_case.rb', line 39 def self.scope_leftover(outer, inner) inner[outer.length..] || [] end |
Instance Method Details
#directly_in_group?(group) ⇒ Boolean
52 53 54 55 56 57 58 59 |
# File 'lib/rspec/abq/test_case.rb', line 52 def directly_in_group?(group) return false unless in_group?(group) group_scope = self.class.parse_scope(group.[:scoped_id]) additional_scoping = self.class.scope_leftover(group_scope, @scope) raise "#{@id} not inside #{group_scope}, but we thought it was" if additional_scoping.empty? additional_scoping.length == 1 end |
#in_group?(group) ⇒ Boolean
44 45 46 47 48 49 |
# File 'lib/rspec/abq/test_case.rb', line 44 def in_group?(group) return false if group.[:rerun_file_path] != @rerun_file_path group_scope = self.class.parse_scope(group.[:scoped_id]) self.class.scope_contains(group_scope, @scope) end |
#is_example?(example) ⇒ Boolean
62 63 64 |
# File 'lib/rspec/abq/test_case.rb', line 62 def is_example?(example) example.[:rerun_file_path] == @rerun_file_path && self.class.parse_scope(example.[:scoped_id]) == @scope end |