Sha256: 8c3925e9c27cba8d330d99d8071563e5340c2ad1b172b841b7aa96c95a951202
Contents?: true
Size: 1.67 KB
Versions: 1
Compression:
Stored size: 1.67 KB
Contents
require 'test_helper' class CLI < MiniTest::Unit::TestCase def setup @templates_path = "#{File.dirname(__FILE__)}/../lib/sinatra_generator/templates" @tmp_dir = Dir.mktmpdir Dir.chdir @tmp_dir end def teardown Dir.chdir('..') FileUtils.remove_entry @tmp_dir end # sinatra new blog def test_command_new SinatraGenerator::CLI.start ['new','blog'] assert File.directory? "blog" Dir.chdir 'blog' do assert File.exist?('main.rb'), 'main.rb not found' assert File.exist?('Gemfile'), 'Gemfile not found' assert File.exist?('config.ru'), 'config.ru not found' end end # sinatra new blog -p def test_option_profile SinatraGenerator::CLI.start ['new','blog', '-p'] Dir.chdir 'blog' do assert_equal File.read('Procfile'), File.read("#{@templates_path}/Procfile") end end # sinatra new blog -v def test_option_views SinatraGenerator::CLI.start ['new','blog', '-v'] Dir.chdir 'blog' do assert File.directory?('views'), 'views not found' Dir.chdir 'views' do assert_equal File.read('index.erb'), File.read("#{@templates_path}/index.erb") end end end # sinatra new blog -av def test_option_assets_with_views SinatraGenerator::CLI.start ['new','blog', '-av'] Dir.chdir 'blog' do assert File.directory?('public'), 'public not found' assert File.directory?('views'), 'views not found' Dir.chdir 'views' do assert_match /<link rel="stylesheet" href="\/stylesheets\/main.css">/, File.read('layout.erb') # assert_includes File.read('layout.erb'), '<link rel="stylesheet" href="/stylesheets/main.css">' end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sinatra_generator-0.1.0 | test/cli_test.rb |