Class: ButterflyNet::TestUnitAdapter
- Inherits:
-
Object
- Object
- ButterflyNet::TestUnitAdapter
- Defined in:
- lib/butterfly_net/test_unit_adapter.rb
Instance Attribute Summary collapse
-
#assertion_sets ⇒ Object
readonly
Returns the value of attribute assertion_sets.
Instance Method Summary collapse
- #add_command(line) ⇒ Object
- #close_assertion_set ⇒ Object
- #create_file(filename) ⇒ Object
-
#initialize ⇒ TestUnitAdapter
constructor
A new instance of TestUnitAdapter.
- #test_methods ⇒ Object
Constructor Details
#initialize ⇒ TestUnitAdapter
Returns a new instance of TestUnitAdapter.
6 7 8 |
# File 'lib/butterfly_net/test_unit_adapter.rb', line 6 def initialize @assertion_sets = [] end |
Instance Attribute Details
#assertion_sets ⇒ Object (readonly)
Returns the value of attribute assertion_sets.
4 5 6 |
# File 'lib/butterfly_net/test_unit_adapter.rb', line 4 def assertion_sets @assertion_sets end |
Instance Method Details
#add_command(line) ⇒ Object
10 11 12 13 |
# File 'lib/butterfly_net/test_unit_adapter.rb', line 10 def add_command(line) @assertion_sets << TestUnitMethod.new unless @assertion_sets.last @assertion_sets.last << line end |
#close_assertion_set ⇒ Object
15 16 17 |
# File 'lib/butterfly_net/test_unit_adapter.rb', line 15 def close_assertion_set @assertion_sets << TestUnitMethod.new end |
#create_file(filename) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/butterfly_net/test_unit_adapter.rb', line 19 def create_file(filename) return nil if @assertion_sets.empty? file = File.open(filename, 'w+') file.puts "require \"test/unit\"\n\nclass TempTest < Test::Unit::TestCase" test_methods.each do |test_method| file.puts "\n #{test_method}" end file.puts "\nend" ensure file.close if file # todo: closing is good, but prevent writing partial data in case of exception end |
#test_methods ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/butterfly_net/test_unit_adapter.rb', line 33 def test_methods method_strings = [] @assertion_sets.each_with_index do |assertions, i| method_strings << assertions.text(i + 1) end method_strings end |