Permalink
Browse files

more stuff

  • Loading branch information...
1 parent 7eaf5af commit 8ea79371607e646e886049f2d86cb43c9b6f3695 @chalmagean committed Dec 16, 2010
Showing with 83 additions and 5 deletions.
  1. +1 −0 .rspec
  2. +28 −0 Gemfile.lock
  3. +2 −2 Rakefile
  4. +14 −0 lib/css_filter.rb
  5. +38 −3 spec/css_filter_spec.rb
View
1 .rspec
@@ -1 +1,2 @@
--color
+--format documentation
View
28 Gemfile.lock
@@ -0,0 +1,28 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ diff-lcs (1.1.2)
+ git (1.2.5)
+ jeweler (1.5.1)
+ bundler (~> 1.0.0)
+ git (>= 1.2.5)
+ rake
+ rake (0.8.7)
+ rcov (0.9.9)
+ rspec (2.1.0)
+ rspec-core (~> 2.1.0)
+ rspec-expectations (~> 2.1.0)
+ rspec-mocks (~> 2.1.0)
+ rspec-core (2.1.0)
+ rspec-expectations (2.1.0)
+ diff-lcs (~> 1.1.2)
+ rspec-mocks (2.1.0)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ bundler (~> 1.0.0)
+ jeweler (~> 1.5.1)
+ rcov
+ rspec (~> 2.1.0)
View
4 Rakefile
@@ -15,8 +15,8 @@ Jeweler::Tasks.new do |gem|
gem.name = "css_filter"
gem.homepage = "http://github.com/mixandgo/css_filter"
gem.license = "MIT"
- gem.summary = %Q{TODO: one-line summary of your gem}
- gem.description = %Q{TODO: longer description of your gem}
+ gem.summary = %Q{Clean up dead css code}
+ gem.description = %Q{A little utility to clean up unused css from your rails project}
gem.email = "cezar@mixandgo.com"
gem.authors = ["Cezar Halmagean"]
# Include your dependencies below. Runtime dependencies are required when using your gem,
View
14 lib/css_filter.rb
@@ -0,0 +1,14 @@
+class CSSFilter
+
+ def initialize(*args)
+ @css_dir = args.pop
+ end
+
+ def css_dir
+ @css_dir
+ end
+
+ def css_files
+ Dir.glob("#{css_dir}/*.css")
+ end
+end
View
41 spec/css_filter_spec.rb
@@ -1,7 +1,42 @@
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
-describe "CssFilter" do
- it "fails" do
- fail "hey buddy, you should probably rename this file and start specing for real"
+describe CSSFilter, " when initialized" do
+ before(:each) do
+ @css_filter = mock(CSSFilter)
+ end
+
+ context "with arguments" do
+ it "should store the css dir" do
+ CSSFilter.new("/test").css_dir.should_not be_nil
+ end
+ end
+
+ context "with no arguments" do
+ it "should not store the css dir" do
+ CSSFilter.new.css_dir.should be_nil
+ end
end
end
+
+describe CSSFilter, "#css_files" do
+ before(:each) do
+ @css_filter = CSSFilter.new('/test')
+ end
+
+ it "should recurse into subdirectories"
+
+ context "if files exist" do
+ it "should return a list of css files" do
+ files = ['test1.css', 'test2.css']
+ Dir.stub!(:glob).with("/test/*.css").and_return(files)
+ @css_filter.css_files.should == files
+ end
+ end
+
+ context "if no files exist" do
+ it "should return nil" do
+ Dir.stub!(:glob).with("/test/*.css").and_return(nil)
+ @css_filter.css_files.should be_nil
+ end
+ end
+end

0 comments on commit 8ea7937

Please sign in to comment.