Skip to content

Commit

Permalink
Retool tests so that we can have a basis for less import dependency t…
Browse files Browse the repository at this point in the history
…est.
  • Loading branch information
metaskills committed Nov 18, 2011
1 parent 5d060cb commit c1c9681
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 17 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
Gemfile.lock
pkg/*
*.log
tmp/*
tmp/*
test/dummy_app/tmp/cache/assets/*
12 changes: 10 additions & 2 deletions test/cases/basics_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

class BasicsSpec < Less::Rails::Spec

let(:basics) { dummy_asset('basics') }

it 'must render variables' do
basics.must_match %r{#test-variable\{color:#4d926f;\}}
end
Expand All @@ -16,4 +14,14 @@ class BasicsSpec < Less::Rails::Spec
Less::Rails::CssCompressor.new.compress('.class {width: 1+1}').must_equal '.class{width:2;}'
end

it 'must hook into less import so that imported paths are declared as sprocket dependencies of the source file' do
flunk 'will need to use the basics asset, then change the frameworks/bootstrap/mixins.less file, then render basics again'
end

protected

def basics
dummy_asset 'basics'
end

end
3 changes: 3 additions & 0 deletions test/dummy_app/app/assets/stylesheets/basics.css.less
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@
.bordered { border: 1px solid black; }
#test-mixin span { .bordered; }

// Frameworks
@import "frameworks/bootstrap/mixins";
#test-radiused { .radiused; }
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

.radiused(@radius: 5px) {
border-radius: @radius;
}
2 changes: 1 addition & 1 deletion test/dummy_app/init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Application < ::Rails::Application
config.consider_all_requests_local = true

config.assets.enabled = true
config.assets.cache_store = config.cache_store
config.assets.cache_store = [:file_store, "#{config.root}/tmp/cache/assets/"]

end
end
Expand Down
Empty file added test/dummy_app/tmp/.gitkeep
Empty file.
Empty file.
32 changes: 19 additions & 13 deletions test/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,30 @@ module Less
module Rails

class Spec < MiniTest::Spec


include FileUtils

class << self

def dummy_app
Dummy::Application
end

def dummy_tmp
"#{dummy_app.root}/tmp"
end

end

before do
reset_config_options
reset_caches
end

protected

def dummy_app
Dummy::Application
end

delegate :dummy_app, :dummy_tmp, :to => :'self.class'

def dummy_config
dummy_app.config
end
Expand Down Expand Up @@ -51,16 +63,14 @@ def reset_caches
# Heavily inspired by Rails::Generators::TestCase.
class GeneratorSpec < Spec

include FileUtils

class_attribute :destination_root, :current_path, :generator_class, :default_arguments
delegate :destination_root, :current_path, :generator_class, :default_arguments, :to => :'self.class'

self.current_path = File.expand_path(Dir.pwd)
self.default_arguments = []
self.destination_root = "#{Dummy::Application.root}/tmp"
self.destination_root = "#{dummy_tmp}/destination_root"

before { destination_root_is_set? ; ensure_current_path ; prepare_destination ; no_color! ; setup_generator_class }
before { ensure_current_path ; prepare_destination ; no_color! ; setup_generator_class }
after { remove_destination ; ensure_current_path }

protected
Expand All @@ -69,10 +79,6 @@ def no_color!
Thor::Base.shell = Thor::Shell::Basic
end

def destination_root_is_set?
raise "You need to configure your Less::Rails::GeneratorSpec destination root." unless destination_root
end

def ensure_current_path
cd current_path
end
Expand Down

0 comments on commit c1c9681

Please sign in to comment.