Permalink
Browse files

New test setup and hopefully a more sane engine initializer.

  • Loading branch information...
metaskills committed Oct 9, 2011
1 parent 189fc68 commit 56ec18dd2497047b28f0da1f0b5cb120af482f98
View
@@ -2,3 +2,5 @@
.bundle
Gemfile.lock
pkg/*
+log/*
+tmp/*
View
@@ -1,6 +1,11 @@
CHANGELOG
=========
+1.3.3 (unreleased)
+
+* New test setup and hopefully a more sane engine initializer.
+
+
1.3.2 (Sept 28, 2011)
---------------------
View
@@ -1,2 +1,5 @@
source :rubygems
gemspec
+
+gem 'less-rails', :path => ENV['LESS_RAILS_PATH'] if ENV['LESS_RAILS_PATH']
+
View
@@ -0,0 +1,5 @@
+guard 'minitest' do
+ watch(%r|^lib/less/rails/bootstrap/(.*)\.rb|) { |m| "test/cases/#{m[1]}_spec.rb" }
+ watch(%r|^test/spec_helper\.rb|) { "test/cases" }
+ watch(%r|^test/cases/(.*)_spec\.rb|)
+end
View
@@ -1 +1,14 @@
-require "bundler/gem_tasks"
+require 'bundler'
+require 'rake/testtask'
+
+Bundler::GemHelper.install_tasks
+
+Rake::TestTask.new do |t|
+ t.libs = ['lib','test']
+ t.test_files = Dir.glob("test/**/*_spec.rb").sort
+ t.verbose = true
+end
+
+task :default => [:test]
+task :spec => [:test]
+
@@ -15,4 +15,7 @@ Gem::Specification.new do |s|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]
s.add_runtime_dependency "less-rails", "~> 2.0.0"
+ s.add_development_dependency 'minitest'
+ s.add_development_dependency 'guard-minitest'
+ s.add_development_dependency 'rails', '~> 3.1.1'
end
@@ -5,5 +5,5 @@ module Bootstrap
end
end
-require 'less/rails'
-require "less/rails/bootstrap"
+require 'less-rails'
+require 'less/rails/bootstrap'
@@ -3,9 +3,8 @@ module Rails
module Bootstrap
class Engine < ::Rails::Engine
- config.after_initialize do |app|
- bootstrap_less_files = config.root + 'vendor/stylesheets/twitter/bootstrap'
- app.config.less.paths << bootstrap_less_files
+ initializer 'less-rails-bootstrap.setup', :after => 'less-rails.after.load_config_initializers', :group => :all do |app|
+ app.config.less.paths << File.join(config.root, 'vendor', 'assets', 'stylesheets')
end
end
@@ -1,7 +1,7 @@
module Less
module Rails
module Bootstrap
- VERSION = "1.3.2"
+ VERSION = "1.3.3"
end
end
end
View
@@ -0,0 +1,15 @@
+require 'spec_helper'
+
+class EngineSpec < Less::Rails::Bootstrap::Spec
+
+ it 'must be able to hook into a less-rails config' do
+ dummy_config.less.must_be_instance_of ActiveSupport::OrderedOptions
+ end
+
+ it 'must append engines assets stylesheets to less-rails load paths' do
+ dummy_config.less.paths.must_be_instance_of Array
+ dummy_config.less.paths.must_include project_root
+ end
+
+
+end
@@ -0,0 +1,72 @@
+require 'spec_helper'
+
+class UsageCssSpec < Less::Rails::Bootstrap::Spec
+
+ describe 'application.css' do
+
+ let(:app_css) { dummy_asset('application.css') }
+
+ it 'will render main bootstrap.less file and all included modules' do
+ app_css.must_include 'Bootstrap @VERSION', 'From boostrap.less'
+ app_css.must_include 'Forms.less', 'From forms.less'
+ app_css.must_include 'Snippets of reusable CSS', 'From mixins.less'
+ app_css.must_include 'Patterns.less', 'From patterns.less'
+ app_css.must_include 'Scaffolding', 'From scaffolding.less'
+ app_css.must_include 'Tables.less', 'From tables.less'
+ app_css.must_include 'Typography.less', 'From type.less'
+ app_css.must_include 'Variables.less', 'From variables.less'
+ end
+
+ it 'must include basic css afterward' do
+ app_css.must_include '#other-css { color: red; }', 'From our code afterward.'
+ end
+
+ end
+
+ describe 'framework.css.less' do
+
+ before { dummy_config.less.compress = true }
+
+ let(:framework_css) { dummy_asset('framework.css') }
+
+ it 'will render bootstrap functions' do
+ border_radius_line = line_for_framework_css('framework-border-radius')
+ border_radius_line.must_include '-webkit-border-radius:4px'
+ border_radius_line.must_include '-moz-border-radius:4px'
+ border_radius_line.must_include 'border-radius:4px'
+ end
+
+ it 'will render bootstrap variables' do
+ link_color_line = line_for_framework_css('framework-linkColor')
+ link_color_line.must_include 'color:#0069d6;'
+ end
+
+ end
+
+ describe 'individual.css.less' do
+
+ before { dummy_config.less.compress = true }
+
+ let(:individual_css) { dummy_asset('individual.css') }
+
+ it 'will render bootstrap variables and mixins' do
+ my_button_line = line_for_individual_css('individual-my-button')
+ my_button_line.must_include '-webkit-border-radius:10px'
+ my_button_line.must_include '-moz-border-radius:10px'
+ my_button_line.must_include 'border-radius:10px'
+ end
+
+ end
+
+
+ private
+
+ def line_for_framework_css(name)
+ framework_css.each_line.detect{ |line| line.include? name }.strip
+ end
+
+ def line_for_individual_css(name)
+ individual_css.each_line.detect{ |line| line.include? name }.strip
+ end
+
+end
@@ -0,0 +1,36 @@
+require 'spec_helper'
+
+class UsageJsSpec < Less::Rails::Bootstrap::Spec
+
+ describe 'application.js' do
+
+ let(:app_js) { dummy_asset('application.js') }
+
+ it 'will render main bootstrap.js file and all included modules' do
+ app_js.must_include 'bootstrap-alerts.js'
+ app_js.must_include 'bootstrap-dropdown.js'
+ app_js.must_include 'bootstrap-modal.js'
+ app_js.must_include 'bootstrap-popover.js'
+ app_js.must_include 'bootstrap-scrollspy.js'
+ app_js.must_include 'bootstrap-tabs.js'
+ app_js.must_include 'bootstrap-twipsy.js'
+ end
+
+ it 'must include basic js afterward' do
+ app_js.must_include '$(document).ready(function(){...});'
+ end
+
+ end
+
+ describe 'individual.css.less' do
+
+ let(:individual_js) { dummy_asset('individual.js') }
+
+ it 'will render bootstrap variables and mixins' do
+ individual_js.must_include 'bootstrap-modal.js'
+ end
+
+ end
+
+
+end
@@ -0,0 +1,3 @@
+//= require twitter/bootstrap
+
+$(document).ready(function(){...});
@@ -0,0 +1,2 @@
+//= require twitter/bootstrap/modal
+
@@ -0,0 +1,6 @@
+/*
+ *= require twitter/bootstrap
+*/
+
+#other-css { color: red; }
+
@@ -0,0 +1,6 @@
+@import "twitter/bootstrap";
+
+#framework-start{color:red;}
+
+#framework-border-radius { .border-radius(4px); }
+#framework-linkColor { color: @linkColor; }
@@ -0,0 +1,10 @@
+@import "twitter/bootstrap/variables";
+@import "twitter/bootstrap/mixins";
+
+.myButton(@radius: 5px) {
+ .border-radius(@radius);
+}
+
+#individual-my-button {
+ .myButton(10px);
+}
View
@@ -0,0 +1,21 @@
+require 'sprockets/railtie'
+require 'action_controller/railtie'
+require 'action_view/railtie'
+require 'action_view/base'
+require 'action_controller/base'
+
+module Dummy
+ class Application < ::Rails::Application
+
+ config.root = File.join __FILE__, '..'
+ config.active_support.deprecation = :stderr
+ config.cache_store = :memory_store
+ config.consider_all_requests_local = true
+
+ config.assets.enabled = true
+ config.assets.cache_store = config.cache_store
+
+ end
+end
+
+Dummy::Application.initialize!
Oops, something went wrong.

0 comments on commit 56ec18d

Please sign in to comment.