Sha256: 9342a0a44319016a4e365677319e61f5546dd7e2054bc6d5f95bfbf19accfbf9
Contents?: true
Size: 1.15 KB
Versions: 1
Compression:
Stored size: 1.15 KB
Contents
require "minitest/autorun" require "minitest-rails" require 'rails' require 'rails/generators' require 'generators/minitest/model/model_generator' require 'fileutils' class TestModelGenerator < MiniTest::Unit::TestCase Rails::Generators.no_color! def test_model_generator text = capture(:stdout) do MiniTest::Generators::ModelGenerator.start ['user'] end assert_equal " create test/models/user_test.rb\n", text assert File.exists? 'test/models/user_test.rb' contents = open('test/models/user_test.rb').read assert_match /class UserTest < MiniTest::Unit::TestCase/m, contents ensure # TODO: Don't write the files # I agree, it would be better to mock the file getting written FileUtils.rm_r 'test/models' end def test_model_generator_spec text = capture(:stdout) do MiniTest::Generators::ModelGenerator.start ['user', '--spec'] end assert_equal " create test/models/user_test.rb\n", text assert File.exists? 'test/models/user_test.rb' contents = open('test/models/user_test.rb').read assert_match /describe User do/m, contents ensure FileUtils.rm_r 'test/models' end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
minitest-rails-0.0.1 | test/test_model_generator.rb |