Module: CARPS::Test

Defined in:
lib/carps/test.rb,
lib/carps/util/editor.rb,
lib/carps/util/process.rb

Overview

Testing utilities, for the wizard (also used for unit tests)

Defined Under Namespace

Modules: Editor Classes: Mutate

Class Method Summary collapse

Class Method Details

.editor(editor) ⇒ Object

Test the editor



119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/carps/util/editor.rb', line 119

def Test::editor editor
   puts "The editor should launch, then you should edit this paragraph:"
   before = "Please edit me."
   puts before
   puts "Once you are done editing, save the file and close the editor."
   if after = editor.edit(before)
      if after == before
         Test::multi_fail "Your editor is detaching itself into the background.", "You did not edit the paragraph.  Do so!", "The editor did not save the file correctly.", "The editor did not load the file correctly."
      else
         before_good = UI::confirm "Before you starting editing, did the editor display this text?\n#{before}"
         if before_good
            after_good = UI::confirm "Did you change that to this?\n#{after}"
            if after_good
               return true
            else
               Editor::save_fail
            end
         else
            Editor::load_fail
         end
      end
   else
      Editor::save_fail
   end

end

.multi_fail(*reasons) ⇒ Object

There can sometimes be more than one reason why the test has failed.



24
25
26
# File 'lib/carps/test.rb', line 24

def Test::multi_fail *reasons
   Test::test_failed "Either:\n\t" + reasons.join("\nor\t")
end

.test_failed(msg) ⇒ Object



28
29
30
# File 'lib/carps/test.rb', line 28

def Test::test_failed msg
   UI::put_error msg
end