Permalink
Browse files

convert specs to shoulda

  • Loading branch information...
1 parent f9acaf0 commit 231257a7bbc04f3e07365cbcf65872eafb2f6d7c @grosser grosser committed Feb 13, 2010
Showing with 71 additions and 67 deletions.
  1. +70 −67 test/more_test.rb
  2. +1 −0 test/test_helper.rb
View
@@ -1,102 +1,105 @@
require 'test_helper'
class MoreTest < ActiveSupport::TestCase
- def setup
+ setup do
[:compression, :header, :destination_path, :source_path].each do |variable|
Less::More.send("#{variable}=", nil)
end
end
- def teardown
- `rm -rf #{css_path}`
- end
-
- def prepare_for_generate
- Less::More.source_path = 'less_files'
- Less::More.destination_path = 'css'
+ context :header do
+ should "be true by default" do
+ assert_equal Less::More.header, true
+ end
- `rm -rf #{css_path}`
- `mkdir -p #{css_path}`
+ should "be overwriteable" do
+ Less::More.header = false
+ assert_equal false, Less::More.header
+ end
end
- def css_path
- "#{Rails.root}/public/css"
- end
+ context :source_path do
+ should "be app/stylesheets by default" do
+ assert_equal 'app/stylesheets', Less::More.source_path
+ end
- test "header is true by default" do
- assert_equal Less::More.header, true
+ should "be overwritteable" do
+ Less::More.source_path = 'xxx'
+ assert_equal 'xxx', Less::More.source_path
+ end
end
- test "header can be overwritten" do
- Less::More.header = false
- assert_equal false, Less::More.header
- end
+ context :destination_path do
+ should "be public/stylesheets by default" do
+ assert_equal 'stylesheets', Less::More.destination_path
+ end
- test "source_path is app/stylesheets by default" do
- assert_equal 'app/stylesheets', Less::More.source_path
+ should "be overwritteable" do
+ Less::More.destination_path = 'xxx'
+ assert_equal 'xxx', Less::More.destination_path
+ end
end
- test "source_path can be overwritten" do
- Less::More.source_path = 'xxx'
- assert_equal 'xxx', Less::More.source_path
- end
+ context :compression do
+ should "be off by default" do
+ assert_equal nil, Less::More.compression
+ end
- test "destination_path is public/stylesheets by default" do
- assert_equal 'stylesheets', Less::More.destination_path
+ should "be overwritteable" do
+ Less::More.compression = true
+ assert_equal true, Less::More.compression
+ end
end
- test "destination_path can be overwritten" do
- Less::More.destination_path = 'xxx'
- assert_equal 'xxx', Less::More.destination_path
+ def css_path
+ "#{Rails.root}/public/css"
end
- test "compression is off by default" do
- assert_equal nil, Less::More.compression
- end
+ context :generate do
+ setup do
+ Less::More.source_path = 'less_files'
+ Less::More.destination_path = 'css'
+ `mkdir -p #{css_path}`
+ end
- test "compression can be overwritten" do
- Less::More.compression = true
- assert_equal true, Less::More.compression
- end
+ teardown do
+ `rm -rf #{css_path}`
+ end
- test "generate includes imported partials" do
- prepare_for_generate
- Less::More.generate_all
- css = File.read(File.join(css_path, 'test.css'))
- assert css.include?(".allforms { font-size: 110%; }
+ should "include imported partials" do
+ Less::More.generate_all
+ css = File.read(File.join(css_path, 'test.css'))
+ assert css.include?(".allforms { font-size: 110%; }
body { color: #222222; }
form {
font-size: 110%;
color: #ffffff;
}")
- end
+ end
- test "generate does not parse css" do
- prepare_for_generate
- Less::More.generate_all
- original_css = File.read(File.join(css_path, 'plain.css'))
- assert_equal File.read(File.join(Rails.root,'less_files', 'plain.css')), original_css
- end
+ should "not parse css" do
+ Less::More.generate_all
+ original_css = File.read(File.join(css_path, 'plain.css'))
+ assert_equal File.read(File.join(Rails.root,'less_files', 'plain.css')), original_css
+ end
- test "generate adds disclaimer-header when active" do
- prepare_for_generate
- Less::More.header = true
- Less::More.generate_all
- css = File.read(File.join(css_path, 'test.css'))
- assert_match /^\/\*/, css # starts with comment -> header
- end
+ should "add disclaimer-header when active" do
+ Less::More.header = true
+ Less::More.generate_all
+ css = File.read(File.join(css_path, 'test.css'))
+ assert_match /^\/\*/, css # starts with comment -> header
+ end
- test "generate uses no header when not set" do
- prepare_for_generate
- Less::More.header = false
- Less::More.generate_all
- css = File.read(File.join(css_path, 'test.css'))
- assert_match /^\.allforms/, css
- end
+ should "not include header when not set" do
+ Less::More.header = false
+ Less::More.generate_all
+ css = File.read(File.join(css_path, 'test.css'))
+ assert_match /^\.allforms/, css
+ end
- test "generate does not generate partials" do
- prepare_for_generate
- Less::More.generate_all
- assert !File.exist?(File.join(css_path, '_global.css'))
+ should "not generate partials" do
+ Less::More.generate_all
+ assert !File.exist?(File.join(css_path, '_global.css'))
+ end
end
end
View
@@ -3,6 +3,7 @@
require 'rubygems'
require 'active_support'
require 'active_support/test_case'
+require 'shoulda'
class Rails
def self.root

0 comments on commit 231257a

Please sign in to comment.