aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test
diff options
context:
space:
mode:
authorKasper Timm Hansen <kaspth@gmail.com>2015-10-07 22:43:29 +0200
committerKasper Timm Hansen <kaspth@gmail.com>2015-10-07 22:49:41 +0200
commit11a3e02237495fcb106297af875b2708d63c279e (patch)
treedcc6a70e4b54f23b80c24d79705ece73179fe3b6 /railties/test
parentda832016bf775a5b1daeec40d642bf6424a3018a (diff)
downloadrails-11a3e02237495fcb106297af875b2708d63c279e.tar.gz
rails-11a3e02237495fcb106297af875b2708d63c279e.tar.bz2
rails-11a3e02237495fcb106297af875b2708d63c279e.zip
Refactor create_test_file to take a pass option.
Lets us cut the verbose and straight up duplicated setup in 3 tests down to one line.
Diffstat (limited to 'railties/test')
-rw-r--r--railties/test/application/test_runner_test.rb38
1 files changed, 7 insertions, 31 deletions
diff --git a/railties/test/application/test_runner_test.rb b/railties/test/application/test_runner_test.rb
index 3eb2c2fd84..0aa6ce2252 100644
--- a/railties/test/application/test_runner_test.rb
+++ b/railties/test/application/test_runner_test.rb
@@ -341,45 +341,21 @@ module ApplicationTests
end
def test_output_inline_by_default
- app_file 'test/models/post_test.rb', <<-RUBY
- require 'test_helper'
-
- class PostTest < ActiveSupport::TestCase
- def test_post
- assert false, 'wups!'
- end
- end
- RUBY
+ create_test_file :models, 'post', pass: false
output = run_test_command('test/models/post_test.rb')
- assert_match %r{Running:\n\nF\n\nwups!\n\nbin/rails test test/models/post_test.rb:4}, output
+ assert_match %r{Running:\n\nPostTest\nF\n\nwups!\n\nbin/rails test test/models/post_test.rb:4}, output
end
- def test_no_failure_output_after_run_if_outputting_inline
- app_file 'test/models/post_test.rb', <<-RUBY
- require 'test_helper'
-
- class PostTest < ActiveSupport::TestCase
- def test_post
- assert false, 'wups!'
- end
- end
- RUBY
+ def test_only_inline_failure_output
+ create_test_file :models, 'post', pass: false
output = run_test_command('test/models/post_test.rb')
assert_match %r{Finished in.*\n\n1 runs, 1 assertions}, output
end
def test_fail_fast
- app_file 'test/models/post_test.rb', <<-RUBY
- require 'test_helper'
-
- class PostTest < ActiveSupport::TestCase
- def test_post
- assert false, 'wups!'
- end
- end
- RUBY
+ create_test_file :models, 'post', pass: false
assert_match(/Interrupt/,
capture(:stderr) { run_test_command('test/models/post_test.rb --fail-fast') })
@@ -441,14 +417,14 @@ module ApplicationTests
app_file 'db/schema.rb', ''
end
- def create_test_file(path = :unit, name = 'test')
+ def create_test_file(path = :unit, name = 'test', pass: true)
app_file "test/#{path}/#{name}_test.rb", <<-RUBY
require 'test_helper'
class #{name.camelize}Test < ActiveSupport::TestCase
def test_truth
puts "#{name.camelize}Test"
- assert true
+ assert #{pass}, 'wups!'
end
end
RUBY