PageRenderTime 39ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

/vendor/plugins/has_markup/vendor/gems/thoughtbot-shoulda-2.0.4/test/other/convert_to_should_syntax_test.rb

https://github.com/technicalpickles/flockup
Ruby | 63 lines | 45 code | 18 blank | 0 comment | 2 complexity | 87c56a289d61bcbeb2deab23d50dc4ce MD5 | raw file
Possible License(s): GPL-2.0
  1. require 'test/unit'
  2. class ConvertToShouldSyntaxTest < Test::Unit::TestCase # :nodoc:
  3. BEFORE_FIXTURE = <<-EOS
  4. class DummyTest < Test::Unit::TestCase
  5. should "Not change this_word_with_underscores" do
  6. end
  7. def test_should_be_working
  8. assert true
  9. end
  10. def test_some_cool_stuff
  11. assert true
  12. end
  13. def non_test_method
  14. end
  15. end
  16. EOS
  17. AFTER_FIXTURE = <<-EOS
  18. class DummyTest < Test::Unit::TestCase
  19. should "Not change this_word_with_underscores" do
  20. end
  21. should "be working" do
  22. assert true
  23. end
  24. should "RENAME ME: test some cool stuff" do
  25. assert true
  26. end
  27. def non_test_method
  28. end
  29. end
  30. EOS
  31. FIXTURE_PATH = "./convert_to_should_syntax_fixture.dat"
  32. RUBY = ENV['RUBY'] || 'ruby'
  33. def test_convert_to_should_syntax
  34. File.open(FIXTURE_PATH, "w") {|f| f.write(BEFORE_FIXTURE)}
  35. cmd = "#{RUBY} #{File.join(File.dirname(__FILE__), '../../bin/convert_to_should_syntax')} #{FIXTURE_PATH}"
  36. output = `#{cmd}`
  37. File.unlink($1) if output.match(/has been stored in '([^']+)/)
  38. assert_match(/has been converted/, output)
  39. result = IO.read(FIXTURE_PATH)
  40. assert_equal result, AFTER_FIXTURE
  41. end
  42. def teardown
  43. File.unlink(FIXTURE_PATH)
  44. end
  45. end