Commit 42e15772e6a4d27f99ca7e5fd3913e738dea0261
1 parent
9268eb15
Exists in
master
and in
22 other branches
ErrorFixtures
Showing
2 changed files
with
22 additions
and
17 deletions
Show diff stats
| @@ -0,0 +1,18 @@ | @@ -0,0 +1,18 @@ | ||
| 1 | +class ErrorFixtures | ||
| 2 | + | ||
| 3 | + def self.create | ||
| 4 | + error = Kalibro::Entities::Error.new | ||
| 5 | + error.message = 'Error message from ErrorTest' | ||
| 6 | + error.stack_trace = [ | ||
| 7 | + StackTraceElementFixtures.create('my method 1', 42), | ||
| 8 | + StackTraceElementFixtures.create('my method 2', 84)] | ||
| 9 | + error | ||
| 10 | + end | ||
| 11 | + | ||
| 12 | + def self.create_hash | ||
| 13 | + {:message => 'Error message from ErrorTest', :stack_trace_element => [ | ||
| 14 | + StackTraceElementFixtures.create_hash('my method 1', 42), | ||
| 15 | + StackTraceElementFixtures.create_hash('my method 2', 84)]} | ||
| 16 | + end | ||
| 17 | + | ||
| 18 | +end |
plugins/mezuro/test/unit/kalibro/entities/error_test.rb
| 1 | require "test_helper" | 1 | require "test_helper" |
| 2 | -class ErrorTest < ActiveSupport::TestCase | ||
| 3 | 2 | ||
| 4 | - def self.fixture | ||
| 5 | - error = Kalibro::Entities::Error.new | ||
| 6 | - error.message = 'Error message from ErrorTest' | ||
| 7 | - element1 = StackTraceElementTest.fixture | ||
| 8 | - element2 = StackTraceElementTest.fixture('errorTestMethod', 84) | ||
| 9 | - error.stack_trace = [element1, element2] | ||
| 10 | - error | ||
| 11 | - end | 3 | +require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/error_fixtures" |
| 12 | 4 | ||
| 13 | - def self.fixture_hash | ||
| 14 | - element1 = StackTraceElementTest.fixture_hash | ||
| 15 | - element2 = StackTraceElementTest.fixture_hash('errorTestMethod', 84) | ||
| 16 | - {:message => 'Error message from ErrorTest', | ||
| 17 | - :stack_trace_element => [element1, element2]} | ||
| 18 | - end | 5 | +class ErrorTest < ActiveSupport::TestCase |
| 19 | 6 | ||
| 20 | def setup | 7 | def setup |
| 21 | - @hash = self.class.fixture_hash | ||
| 22 | - @error = self.class.fixture | 8 | + @hash = ErrorFixtures.create_hash |
| 9 | + @error = ErrorFixtures.create | ||
| 23 | end | 10 | end |
| 24 | 11 | ||
| 25 | should 'create error from hash' do | 12 | should 'create error from hash' do |