Class: TestCollection
- Inherits:
-
Object
- Object
- TestCollection
- Defined in:
- lib/sfb_scripts/test_running/test_collection.rb
Constant Summary collapse
- MultipleWorkingDirectoriesError =
Class.new(StandardError)
Instance Attribute Summary collapse
-
#query ⇒ Object
readonly
Returns the value of attribute query.
-
#tests ⇒ Object
readonly
Returns the value of attribute tests.
Instance Method Summary collapse
- #[](*args) ⇒ Object
- #all?(&block) ⇒ Boolean
- #empty? ⇒ Boolean
- #first ⇒ Object
- #full_paths ⇒ Object
- #in_one_engine? ⇒ Boolean
- #in_one_file? ⇒ Boolean
- #include_selenium? ⇒ Boolean
-
#initialize(tests_data = [], query: '') ⇒ TestCollection
constructor
A new instance of TestCollection.
- #is_one_test_method? ⇒ Boolean
- #present? ⇒ Boolean
- #relative_paths ⇒ Object
- #relative_paths_in(working_directory) ⇒ Object
- #remove_selenium! ⇒ Object
- #selenium_tests ⇒ Object
- #size ⇒ Object
- #working_dir ⇒ Object
- #working_dirs ⇒ Object
Constructor Details
#initialize(tests_data = [], query: '') ⇒ TestCollection
Returns a new instance of TestCollection.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/sfb_scripts/test_running/test_collection.rb', line 7 def initialize(tests_data=[], query: '') @query = query @tests = tests_data.map do |test_data| test_data = {file: test_data} if test_data.is_a?(String) TestCase.new( full_path: test_data[:file], line: test_data[:line] ) end.compact end |
Instance Attribute Details
#query ⇒ Object (readonly)
Returns the value of attribute query.
5 6 7 |
# File 'lib/sfb_scripts/test_running/test_collection.rb', line 5 def query @query end |
#tests ⇒ Object (readonly)
Returns the value of attribute tests.
5 6 7 |
# File 'lib/sfb_scripts/test_running/test_collection.rb', line 5 def tests @tests end |
Instance Method Details
#[](*args) ⇒ Object
34 35 36 |
# File 'lib/sfb_scripts/test_running/test_collection.rb', line 34 def [](*args) tests[*args] end |
#all?(&block) ⇒ Boolean
38 39 40 |
# File 'lib/sfb_scripts/test_running/test_collection.rb', line 38 def all?(&block) tests.all?(&block) end |
#empty? ⇒ Boolean
18 19 20 |
# File 'lib/sfb_scripts/test_running/test_collection.rb', line 18 def empty? tests.empty? end |
#first ⇒ Object
30 31 32 |
# File 'lib/sfb_scripts/test_running/test_collection.rb', line 30 def first tests.first end |
#full_paths ⇒ Object
50 51 52 |
# File 'lib/sfb_scripts/test_running/test_collection.rb', line 50 def full_paths @full_paths ||= tests.map {|t| t.full_path }.uniq end |
#in_one_engine? ⇒ Boolean
46 47 48 |
# File 'lib/sfb_scripts/test_running/test_collection.rb', line 46 def in_one_engine? working_dirs.size == 1 end |
#in_one_file? ⇒ Boolean
42 43 44 |
# File 'lib/sfb_scripts/test_running/test_collection.rb', line 42 def in_one_file? full_paths.size == 1 end |
#include_selenium? ⇒ Boolean
66 67 68 |
# File 'lib/sfb_scripts/test_running/test_collection.rb', line 66 def include_selenium? ! selenium_tests.empty? end |
#is_one_test_method? ⇒ Boolean
84 85 86 |
# File 'lib/sfb_scripts/test_running/test_collection.rb', line 84 def is_one_test_method? (size == 1) && tests.first.is_method? end |
#present? ⇒ Boolean
22 23 24 |
# File 'lib/sfb_scripts/test_running/test_collection.rb', line 22 def present? ! empty? end |
#relative_paths ⇒ Object
54 55 56 |
# File 'lib/sfb_scripts/test_running/test_collection.rb', line 54 def relative_paths @relative_paths ||= tests.map {|t| t.relative_path }.uniq end |
#relative_paths_in(working_directory) ⇒ Object
62 63 64 |
# File 'lib/sfb_scripts/test_running/test_collection.rb', line 62 def relative_paths_in(working_directory) tests.select {|t| t.working_dir == working_directory}.map {|t| t.relative_path }.uniq end |
#remove_selenium! ⇒ Object
70 71 72 |
# File 'lib/sfb_scripts/test_running/test_collection.rb', line 70 def remove_selenium! @tests = tests - selenium_tests end |
#selenium_tests ⇒ Object
74 75 76 |
# File 'lib/sfb_scripts/test_running/test_collection.rb', line 74 def selenium_tests tests.select {|t| t.full_path.match(/selenium/)} end |
#size ⇒ Object
26 27 28 |
# File 'lib/sfb_scripts/test_running/test_collection.rb', line 26 def size tests.size end |
#working_dir ⇒ Object
78 79 80 81 82 |
# File 'lib/sfb_scripts/test_running/test_collection.rb', line 78 def working_dir raise MultipleWorkingDirectoriesError.new("Can't run tests for more than one engine") unless working_dirs.size == 1 return working_dirs.first end |
#working_dirs ⇒ Object
58 59 60 |
# File 'lib/sfb_scripts/test_running/test_collection.rb', line 58 def working_dirs @working_dirs ||= tests.map {|t| t.working_dir }.uniq end |