Class: RSpec::Unit::TestCase::ExamplesCollection

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/rspec/unit/test_case.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(testcase, core_examples) ⇒ ExamplesCollection

Returns a new instance of ExamplesCollection.



141
142
143
# File 'lib/rspec/unit/test_case.rb', line 141

def initialize(testcase, core_examples)
  @testcase, @core_examples = testcase, core_examples
end

Instance Attribute Details

#core_examplesObject

Returns the value of attribute core_examples.



139
140
141
# File 'lib/rspec/unit/test_case.rb', line 139

def core_examples
  @core_examples
end

#testcaseObject

Returns the value of attribute testcase.



139
140
141
# File 'lib/rspec/unit/test_case.rb', line 139

def testcase
  @testcase
end

Instance Method Details

#<<(example) ⇒ Object



165
166
167
# File 'lib/rspec/unit/test_case.rb', line 165

def <<(example)
  core_examples << example
end

#eachObject



169
170
171
172
# File 'lib/rspec/unit/test_case.rb', line 169

def each
  core_examples.each{|ex| yield(ex)}
  tests.each{|test| yield(test)}
end

#empty?Boolean

Returns:

  • (Boolean)


157
158
159
# File 'lib/rspec/unit/test_case.rb', line 157

def empty?
  core_examples.empty? && number_of_tests == 0
end

#lastObject



161
162
163
# File 'lib/rspec/unit/test_case.rb', line 161

def last
  tests.last || core_examples.last
end

#number_of_testsObject



149
150
151
# File 'lib/rspec/unit/test_case.rb', line 149

def number_of_tests
  testcase.send(:number_of_tests)
end

#sizeObject



153
154
155
# File 'lib/rspec/unit/test_case.rb', line 153

def size
  core_examples.size + number_of_tests
end

#testsObject



145
146
147
# File 'lib/rspec/unit/test_case.rb', line 145

def tests
  testcase.send(:tests)
end

#to_aryObject



174
175
176
# File 'lib/rspec/unit/test_case.rb', line 174

def to_ary
  core_examples + tests
end

#uniqObject



178
179
180
# File 'lib/rspec/unit/test_case.rb', line 178

def uniq
  to_ary.uniq
end