Class: Fitting::Report::Tests

Inherits:
Object
  • Object
show all
Defined in:
lib/fitting/report/tests.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tests) ⇒ Tests

Returns a new instance of Tests.



8
9
10
# File 'lib/fitting/report/tests.rb', line 8

def initialize(tests)
  @tests = tests
end

Instance Attribute Details

#testsObject (readonly)

Returns the value of attribute tests.



6
7
8
# File 'lib/fitting/report/tests.rb', line 6

def tests
  @tests
end

Class Method Details

.new_from_configObject



12
13
14
15
16
17
18
19
20
21
# File 'lib/fitting/report/tests.rb', line 12

def self.new_from_config
  tests = []
  Dir["#{Fitting.configuration.rspec_json_path}/*.json"].each do |file|
    JSON.parse(File.read(file)).map do |test|
      tests.push(Fitting::Report::Test.new(test))
    end
  end
  tests.sort { |a, b| b.path <=> a.path }
  new(tests)
end

.new_from_outgoing_configObject



23
24
25
26
27
28
29
30
31
32
# File 'lib/fitting/report/tests.rb', line 23

def self.new_from_outgoing_config
  tests = []
  Dir["#{Fitting.configuration.webmock_json_path}/*.json"].each do |file|
    JSON.parse(File.read(file)).map do |test|
      tests.push(Fitting::Report::Test.new(test))
    end
  end
  tests.sort { |a, b| b.path <=> a.path }
  new(tests)
end

Instance Method Details

#push(test) ⇒ Object



58
59
60
# File 'lib/fitting/report/tests.rb', line 58

def push(test)
  tests.push(test)
end

#sizeObject



62
63
64
# File 'lib/fitting/report/tests.rb', line 62

def size
  tests.size
end

#to_aObject



66
67
68
# File 'lib/fitting/report/tests.rb', line 66

def to_a
  tests
end

#to_hObject



70
71
72
73
74
75
76
# File 'lib/fitting/report/tests.rb', line 70

def to_h
  return @hash if @hash

  @hash = tests.inject({}) do |res, test|
    res.merge!(test.id => test.to_h)
  end
end

#without_actionsObject



40
41
42
43
44
# File 'lib/fitting/report/tests.rb', line 40

def without_actions
  tests.each_with_object([]) do |test, result|
    result.push("#{test.method} #{test.path}") unless test.there_an_actions?
  end
end

#without_combinationsObject



52
53
54
55
56
# File 'lib/fitting/report/tests.rb', line 52

def without_combinations
  tests.each_with_object([]) do |test, result|
    result.push(test.path) unless test.there_an_combinations?
  end
end

#without_prefixesObject



34
35
36
37
38
# File 'lib/fitting/report/tests.rb', line 34

def without_prefixes
  tests.each_with_object([]) do |test, result|
    result.push(test.path) unless test.there_a_prefix?
  end
end

#without_responsesObject



46
47
48
49
50
# File 'lib/fitting/report/tests.rb', line 46

def without_responses
  tests.each_with_object([]) do |test, result|
    result.push(test.id) unless test.there_an_responses?
  end
end