Class: Rake::FitTask::AcceptanceTestSuite
- Inherits:
-
Object
- Object
- Rake::FitTask::AcceptanceTestSuite
- Defined in:
- lib/fittask.rb
Instance Attribute Summary collapse
-
#report_path ⇒ Object
Returns the value of attribute report_path.
-
#test_path ⇒ Object
Returns the value of attribute test_path.
-
#tests ⇒ Object
Returns the value of attribute tests.
Instance Method Summary collapse
- #<<(test) ⇒ Object
-
#initialize ⇒ AcceptanceTestSuite
constructor
A new instance of AcceptanceTestSuite.
- #run_tests(with_report = false) ⇒ Object
- #run_tests_with_reports ⇒ Object
- #verify(test, result) ⇒ Object
Constructor Details
#initialize ⇒ AcceptanceTestSuite
Returns a new instance of AcceptanceTestSuite.
128 129 130 131 |
# File 'lib/fittask.rb', line 128 def initialize @tests = [] @test_path = @report_path = '' end |
Instance Attribute Details
#report_path ⇒ Object
Returns the value of attribute report_path.
127 128 129 |
# File 'lib/fittask.rb', line 127 def report_path @report_path end |
#test_path ⇒ Object
Returns the value of attribute test_path.
127 128 129 |
# File 'lib/fittask.rb', line 127 def test_path @test_path end |
#tests ⇒ Object
Returns the value of attribute tests.
127 128 129 |
# File 'lib/fittask.rb', line 127 def tests @tests end |
Instance Method Details
#<<(test) ⇒ Object
132 133 134 |
# File 'lib/fittask.rb', line 132 def << test @tests << test end |
#run_tests(with_report = false) ⇒ Object
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/fittask.rb', line 138 def run_tests with_report=false all_passed = true @tests.each do |test| begin runner_args = [@test_path + "#{test[:name]}.html"] puts "Running #{test[:name]}.html" if with_report report_file = @report_path + "Report_#{test[:name]}.html" puts " (Writing report to #{report_file})" runner_args << report_file runner = Rake::FitReportRunner.new else runner = Rake::FitRunner.new end opts = test[:encoding].nil? ? nil : {:encoding => test[:encoding]} runner.run runner_args, opts result = runner.fixture.counts verify test, result rescue Exception => e puts " #{test[:name]} failed: #{e}" all_passed = false end end all_passed end |
#run_tests_with_reports ⇒ Object
136 |
# File 'lib/fittask.rb', line 136 def run_tests_with_reports; run_tests true; end |
#verify(test, result) ⇒ Object
166 167 168 169 170 171 172 173 174 175 |
# File 'lib/fittask.rb', line 166 def verify test, result [:exceptions, :wrong].each { |symbol| test[symbol] = 0 if test[symbol].nil? } [:right, :wrong, :ignores, :exceptions].each do |symbol| count = result.method(symbol).call expected = test[symbol] unless expected.nil? || count == expected raise Exception.new("#{expected} #{symbol} expected, found #{count} instead.") end end end |