Skip to content

Commit

Permalink
streamline tests, switch to minitest
Browse files Browse the repository at this point in the history
  • Loading branch information
glebm committed Aug 24, 2014
1 parent 88be095 commit 0ca86d3
Show file tree
Hide file tree
Showing 29 changed files with 119 additions and 258 deletions.
7 changes: 3 additions & 4 deletions Rakefile
Expand Up @@ -4,10 +4,9 @@ $:.unshift(lib_path) unless $:.include?(lib_path)
load './tasks/bower.rake'

require 'rake/testtask'
Rake::TestTask.new do |t|
t.libs << "test"
t.test_files = FileList['test/*_test.rb']
t.verbose = true
task :test do |t|
$: << File.expand_path('test/')
Dir.glob('./test/**/*_test.rb').each { |file| require file }
end

desc 'Dumps output to a CSS file for testing'
Expand Down
5 changes: 4 additions & 1 deletion bootstrap-sass.gemspec
Expand Up @@ -14,11 +14,14 @@ Gem::Specification.new do |s|
s.add_runtime_dependency 'sass', '~> 3.2'

# Testing dependencies
s.add_development_dependency 'test-unit', '~> 2.5.5'
s.add_development_dependency 'minitest', '~> 5.4.0'
s.add_development_dependency 'minitest-reporters', '~> 1.0.5'
# Integration testing
s.add_development_dependency 'capybara'
s.add_development_dependency 'poltergeist'
# Dummy Rails app dependencies
s.add_development_dependency 'actionpack', '>= 4.1.5'
s.add_development_dependency 'activesupport', '>= 4.1.5'
s.add_development_dependency 'json', '>= 1.8.1'
s.add_development_dependency 'sprockets-rails', '>= 2.1.3'
s.add_development_dependency 'autoprefixer-rails', '~> 1.1'
Expand Down
2 changes: 1 addition & 1 deletion lib/bootstrap-sass/engine.rb
Expand Up @@ -3,7 +3,7 @@ module Rails
class Engine < ::Rails::Engine
initializer 'bootstrap-sass.assets.precompile' do |app|
%w(stylesheets javascripts fonts images).each do |sub|
app.config.assets.paths << root.join('assets', sub)
app.config.assets.paths << root.join('assets', sub).to_s
end
app.config.assets.precompile << %r(bootstrap/glyphicons-halflings-regular\.(?:eot|svg|ttf|woff)$)
end
Expand Down
2 changes: 1 addition & 1 deletion tasks/bower.rake
@@ -1,5 +1,4 @@
require 'find'
require 'bootstrap-sass'
require 'json'
require 'pathname'

Expand All @@ -13,6 +12,7 @@ namespace :bower do

desc 'update main and version in bower.json'
task :generate do
require 'bootstrap-sass'
Dir.chdir Bootstrap.gem_path do
spec = JSON.parse(File.read 'bower.json')
js_paths = File.read(File.join Bootstrap.javascripts_path, 'bootstrap-sprockets.js').lines.map do |line|
Expand Down
2 changes: 1 addition & 1 deletion tasks/converter/less_conversion.rb
Expand Up @@ -89,7 +89,7 @@ def process_stylesheet_assets
when 'variables.less'
file = insert_default_vars(file)
file = unindent <<-SCSS + "\n" + file, 14
// When true, asset path helpers are used, otherwise regular `url()`` is used.
// When true, asset path helpers are used, otherwise the regular CSS `url()` is used.
// When there no function is defined, `fn('')` is parsed as string that equals the right hand side
// NB: in Sass 3.3 there is a native function: function-exists(twbs-font-path)
$bootstrap-sass-asset-helper: #{sass_fn_exists('twbs-font-path')} !default;
Expand Down
8 changes: 2 additions & 6 deletions test/compass_test.rb
@@ -1,13 +1,9 @@
require 'test_helper'

class CompassTest < Test::Unit::TestCase
class CompassTest < Minitest::Test
def test_create_project
command = 'rm -rf tmp/new-compass-project; bundle exec compass create tmp/new-compass-project -r bootstrap-sass --using bootstrap --trace --force'
success = if ENV['VERBOSE']
system command
else
silence_stream(STDOUT) { system(command) }
end
success = silence_stdout_if(!ENV['VERBOSE']) { system(command) }
assert success, 'Compass project creation failed!'
end
end
14 changes: 7 additions & 7 deletions test/compilation_test.rb
@@ -1,17 +1,17 @@
require 'test_helper'
require 'fileutils'
require 'sass'

class CompilationTest < Test::Unit::TestCase
class CompilationTest < Minitest::Test
def test_compilation
path = 'assets/stylesheets'
%w(_bootstrap bootstrap/_theme).each do |file|
engine = Sass::Engine.for_file("#{path}/#{file}.scss", syntax: :scss, load_paths: [path])
assert_nothing_raised do
FileUtils.mkdir_p("tmp/#{File.dirname(file)}")
File.open("tmp/#{file}.css", 'w') { |f|
f.write engine.render
}
end
FileUtils.mkdir_p("tmp/#{File.dirname(file)}")
File.open("tmp/#{file}.css", 'w') { |f|
f.write engine.render
}
assert true # nothing was raised
end
end
end
2 changes: 1 addition & 1 deletion test/dummy_rails/README.rdoc
@@ -1,3 +1,3 @@
== README

This is a dummy app for testing REP
This is a minimal Rails app for testing
3 changes: 0 additions & 3 deletions test/dummy_rails/bin/bundle

This file was deleted.

4 changes: 0 additions & 4 deletions test/dummy_rails/bin/rails

This file was deleted.

4 changes: 0 additions & 4 deletions test/dummy_rails/bin/rake

This file was deleted.

17 changes: 16 additions & 1 deletion test/dummy_rails/config/application.rb
@@ -1,6 +1,15 @@
require File.expand_path('../boot', __FILE__)

require 'rails/all'
require 'rails'

%w(
action_controller
action_view
sprockets
).each do |framework|
require "#{framework}/railtie"
end

require 'slim-rails'
require 'jquery-rails'
require 'compass'
Expand All @@ -10,6 +19,12 @@
module Dummy
class Application < Rails::Application
config.assets.enabled = true if config.assets.respond_to?(:enabled)
config.to_prepare do
if ENV['VERBOSE']
STDERR.puts "Loaded Rails #{Rails::VERSION::STRING}, Sprockets #{Sprockets::VERSION}",
"Asset paths: #{Rails.application.config.assets.paths}"
end
end
end
end

Empty file removed test/dummy_rails/db/test.sqlite3
Empty file.
Empty file removed test/dummy_rails/lib/assets/.keep
Empty file.
Empty file.
58 changes: 0 additions & 58 deletions test/dummy_rails/public/404.html

This file was deleted.

58 changes: 0 additions & 58 deletions test/dummy_rails/public/422.html

This file was deleted.

57 changes: 0 additions & 57 deletions test/dummy_rails/public/500.html

This file was deleted.

Empty file.
11 changes: 6 additions & 5 deletions test/node_mincer_test.rb
@@ -1,7 +1,7 @@
require 'test_helper'
require 'json'

class NodeMincerTest < Test::Unit::TestCase
class NodeMincerTest < Minitest::Test
DUMMY_PATH = 'test/dummy_node_mincer'

def test_font_helper_without_suffix
Expand All @@ -21,13 +21,14 @@ def test_image_helper
end

def setup
tmp_dir = File.join Bootstrap.gem_path, 'tmp/node-mincer'
tmp_dir = File.join GEM_PATH, 'tmp/node-mincer'
command = "node manifest.js #{tmp_dir}"
Dir.chdir DUMMY_PATH do
assert silence_stream(STDOUT) {
success = Dir.chdir DUMMY_PATH do
silence_stdout_if !ENV['VERBOSE'] do
system(command)
}, 'Node.js Mincer compilation failed'
end
end
assert success, 'Node.js Mincer compilation failed'
manifest = JSON.parse(File.read("#{tmp_dir}/manifest.json"))
css_name = manifest["assets"]["application.css"]
@css = File.read("#{tmp_dir}/#{css_name}")
Expand Down
11 changes: 6 additions & 5 deletions test/node_sass_test.rb
@@ -1,15 +1,16 @@
require 'test_helper'
require 'fileutils'

class NodeSassTest < Test::Unit::TestCase
class NodeSassTest < Minitest::Test
def test_node_sass_compilation
path = 'assets/stylesheets'
%w(bootstrap bootstrap/_theme).each do |file|
FileUtils.mkdir_p "tmp/node-sass"
FileUtils.mkdir_p 'tmp/node-sass'
command = "node-sass #{path}/#{file} -o tmp/node-sass/#{File.basename file}.css"
assert silence_stream(STDOUT) {
system(command)
}, 'node-sass compilation failed'
success = silence_stderr_if !ENV['VERBOSE'] do
system command
end
assert success, 'node-sass compilation failed'
end
end
end
2 changes: 1 addition & 1 deletion test/pages_test.rb
@@ -1,7 +1,7 @@
require 'test_helper_rails'

class PagesTest < ActionDispatch::IntegrationTest
include ::IntegrationTest
include ::DummyRailsIntegration

def test_visit_root
visit root_path
Expand Down

0 comments on commit 0ca86d3

Please sign in to comment.