From 8ef8bd1457b137d6f96eea35fc3bb82e4f33f8bd Mon Sep 17 00:00:00 2001 From: Olivier Amblet Date: Sat, 30 Oct 2010 18:36:44 +0200 Subject: [PATCH] guard 'compass' :configuration_file => 'my_custom.rb' Should now work. Need to create the watchers as well. --- Guardfile | 5 +- README.textile | 16 ++ lib/guard/compass.rb | 44 ++++- lib/guard/compass/templates/Guardfile | 7 +- lib/guard/reporter.rb | 19 ++ .../_utilities.scssc | Bin 0 -> 12228 bytes .../_reset.scssc | Bin 0 -> 1189 bytes .../bad_src_directory/bad_src/ie.scss | 5 + .../bad_src_directory/bad_src/print.scss | 3 + .../bad_src_directory/bad_src/screen.scss | 6 + spec/fixtures/bad_src_directory/config.rb | 9 + .../_utilities.scssc | Bin 0 -> 12228 bytes .../_reset.scssc | Bin 0 -> 1189 bytes .../another_config_location/config.rb | 9 + .../another_src_location/ie.scss | 5 + .../another_src_location/print.scss | 3 + .../another_src_location/screen.scss | 6 + spec/fixtures/dsl/simple/Guardfile | 1 + .../_utilities.scssc | Bin 0 -> 12228 bytes .../_reset.scssc | Bin 0 -> 1189 bytes spec/fixtures/no_config_file/src/ie.scss | 5 + spec/fixtures/no_config_file/src/print.scss | 3 + spec/fixtures/no_config_file/src/screen.scss | 6 + spec/guard/compass_spec.rb | 181 ++++++++++++++---- spec/guard/dsl_spec.rb | 19 ++ spec/guard/reporter_spec.rb | 19 ++ spec/spec_helper.rb | 5 +- 27 files changed, 325 insertions(+), 51 deletions(-) create mode 100644 lib/guard/reporter.rb create mode 100644 spec/fixtures/bad_src_directory/.sass-cache/77242121e92e5208094a0a0f6fbd9eb05d2c3832/_utilities.scssc create mode 100644 spec/fixtures/bad_src_directory/.sass-cache/804c142587e371bce0dd76315d953aa707422b74/_reset.scssc create mode 100644 spec/fixtures/bad_src_directory/bad_src/ie.scss create mode 100644 spec/fixtures/bad_src_directory/bad_src/print.scss create mode 100644 spec/fixtures/bad_src_directory/bad_src/screen.scss create mode 100644 spec/fixtures/bad_src_directory/config.rb create mode 100644 spec/fixtures/custom_config_file/.sass-cache/77242121e92e5208094a0a0f6fbd9eb05d2c3832/_utilities.scssc create mode 100644 spec/fixtures/custom_config_file/.sass-cache/804c142587e371bce0dd76315d953aa707422b74/_reset.scssc create mode 100644 spec/fixtures/custom_config_file/another_config_location/config.rb create mode 100644 spec/fixtures/custom_config_file/another_src_location/ie.scss create mode 100644 spec/fixtures/custom_config_file/another_src_location/print.scss create mode 100644 spec/fixtures/custom_config_file/another_src_location/screen.scss create mode 100644 spec/fixtures/dsl/simple/Guardfile create mode 100644 spec/fixtures/no_config_file/.sass-cache/77242121e92e5208094a0a0f6fbd9eb05d2c3832/_utilities.scssc create mode 100644 spec/fixtures/no_config_file/.sass-cache/804c142587e371bce0dd76315d953aa707422b74/_reset.scssc create mode 100644 spec/fixtures/no_config_file/src/ie.scss create mode 100644 spec/fixtures/no_config_file/src/print.scss create mode 100644 spec/fixtures/no_config_file/src/screen.scss create mode 100644 spec/guard/dsl_spec.rb create mode 100644 spec/guard/reporter_spec.rb diff --git a/Guardfile b/Guardfile index 4ff7627..699cbd9 100644 --- a/Guardfile +++ b/Guardfile @@ -1,6 +1,7 @@ guard 'rspec', :version => 2 do require 'growl' rescue nil watch('^spec/(.*)_spec.rb') - watch('^lib/(.*).rb') { |m| "spec/#{m[1]}_spec.rb" } - watch('^spec/spec_helper.rb') { "spec" } + watch('^lib/(.*).rb') { |m| "spec/#{m[1]}_spec.rb" } + watch('^spec/spec_helper.rb') { "spec" } + watch('^spec/fixtures/(.*)') { "spec" } end \ No newline at end of file diff --git a/README.textile b/README.textile index 2113c0c..d49b335 100644 --- a/README.textile +++ b/README.textile @@ -23,6 +23,22 @@ $ guard Your scss(or sass) stylesheets are now guarded. +h2. Configure Guard::Compass plug-in + +The default configuration generated by 'guard init compass' looks like this + +bc. guard 'compass' do + watch('^src/(.*)\.s[ac]ss') +end + +the compass guard accept two options: + + * :workdir: all compass relative path will be computed from there + * :configuration_file: relative or absolute path to your compass configuration file + +By default, the working directory is the folder where you run guard in and +the configuration_file is computed by compass + h2. Roadmap h3. 0.1.0 diff --git a/lib/guard/compass.rb b/lib/guard/compass.rb index 96fac93..15f21e9 100644 --- a/lib/guard/compass.rb +++ b/lib/guard/compass.rb @@ -1,5 +1,6 @@ require 'guard' require 'guard/guard' +require 'guard/reporter' require 'compass' require 'compass/commands' @@ -7,13 +8,15 @@ module Guard class Compass < Guard - attr_reader :updater + attr_reader :updater, :options + attr_accessor :reporter VERSION = '0.0.6' def initialize(watchers = [], options = {}) super - @options[:workdir] = File.expand_path(File.dirname(".")) + @reporter = Reporter.new + @options[:workdir] ||= File.expand_path(File.dirname(".")) end # Guard Interface Implementation @@ -38,19 +41,48 @@ def reload # Compile all the sass|scss stylesheets def run_all - @updater.execute - true + perform end # Compile the changed stylesheets def run_on_change(paths) - @updater.execute - true + perform end private + def perform + if valid_sass_path? + @updater.execute + true + else + false + end + end + def create_updater + if(options[:configuration_file]) + filepath = Pathname.new(options[:configuration_file]) + if(filepath.relative?) + filepath = Pathname.new([options[:workdir], options[:configuration_file]].join("/")) + end + if(filepath.exist?) + ::Compass.add_configuration filepath + options[:configuration_file] = filepath + else + reporter.failure "Cannot find the Compass configuration file: " + filepath + "\nPlease check your configuration." + end + end @updater = ::Compass::Commands::UpdateProject.new(@options[:workdir] , @options) + valid_sass_path? + end + + def valid_sass_path? + unless File.exists? ::Compass.configuration.sass_path + reporter.failure("Sass files src directory not found: #{::Compass.configuration.sass_path}\nPlease check your Compass configuration.") + false + else + true + end end end end \ No newline at end of file diff --git a/lib/guard/compass/templates/Guardfile b/lib/guard/compass/templates/Guardfile index 5a5e433..e98138a 100644 --- a/lib/guard/compass/templates/Guardfile +++ b/lib/guard/compass/templates/Guardfile @@ -1,3 +1,8 @@ guard 'compass' do watch('^src/(.*)\.s[ac]ss') -end \ No newline at end of file +end + +# # Alternative +# guard 'compass', :workdir => 'not_current_dir', :configuration_file => 'path/to/my/compass_config.rb' do +# watch('^src/(.*)\.s[ac]ss') +# end diff --git a/lib/guard/reporter.rb b/lib/guard/reporter.rb new file mode 100644 index 0000000..fd753ea --- /dev/null +++ b/lib/guard/reporter.rb @@ -0,0 +1,19 @@ +module Guard + # Send a report to the Guard UI + # The Reporter is a wrapper arround guard UI because + # it is currently subject to change. + class Reporter + def success(message) + UI.info(message) + end + def failure(message) + UI.error(message) + end + def unstable(message) + UI.info(message) + end + def announce(message) + UI.info(message) + end + end +end \ No newline at end of file diff --git a/spec/fixtures/bad_src_directory/.sass-cache/77242121e92e5208094a0a0f6fbd9eb05d2c3832/_utilities.scssc b/spec/fixtures/bad_src_directory/.sass-cache/77242121e92e5208094a0a0f6fbd9eb05d2c3832/_utilities.scssc new file mode 100644 index 0000000000000000000000000000000000000000..ed96e6af7df7ef3a3081f480c55fe81b27e9c1c8 GIT binary patch literal 12228 zcmeHN>vG%16}B`T*`nk)zQ&2{WX;?pg(N6BzJa~4aqLXm#>v=9dT|pO1ePLf5TF52 zGV8e0%XFp>(3j}n&h#bvRQ=A`#S#EXS+SM=$kbzrBzX2aXU~1l>T;vm*xVGWHv=b0 zM&c%Z``&1+(sVrM+Gg{zccUXebg$mHvEg06as8Uxz0$q9dDU??-7B5WhU-**bS$!8 zzlUYEy%kGo+jpZVy%Tw|VprOMA4-40KHiQ7sUL;O(^u>hLF9Pb11Iez_bb(3T3;qI zPOK>KcYPUKA4l%6FT*skJ|D>NUNnqdY3&T1*sHrye*iXCGLWvNKWq=;hgK51)vqjY zu!6{S0xR%4Ry^#CtR2};tc}KX^+qqLHyazx#ucj@JAJtq#g7uJ6Aa}b_QTXl(orCj zo|I`)efTnv+Xi#n1GaRXRC?Qfe-OpkTb|9<%djyz$;sV&8NlsKvHMGHpCZc=F&k^k zKJ7YgPi~U|$k5e$hhW!60&~|H*sie3?BnvuzzIF+*%f}iWiKV8Fm;~Ti-`*tJTr)+ zfsE79wtC#OPvY@**AHX}b63AP1hI0)vl16BA2x{fal<5j83RnQXy)uzEEAbp+r!ik z{M468gZ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Vf5(Qpe!`^@qpirm(PgbB|Ypeh``4DJ+D>9T%S_XY=8#_U{<=Dt*#EQRqATy)Mbt~V#>sR zQfV&3u+nBUN>s@5#oaSPFR3BF*>FV-`wROu?YGPrQTu&v;x<4Xu?md3hS9RVBru$g z;jj1nSib zT~1)#pxd;L7_i+&d*wRIaI@!}8{JUR-0FC|~=psbZ<|gt~Wodd# z{|@IOM1xUxl)K}|cpT^=BoC3l;n)WxPo^(ICL?X`X%;{$)l+Kpl)3MP`$uUixuT|$ z**Wej+>6oQ(H(0YeR>236cm5;M?~b`IE&F7l0oOcox@>IA3^YUmVExBfx;S=w&~lI z>MP@04_a-%R^;_j6a|X~yxSZ_JeM#jVD8&&3&;UxikiuLdl=H+39(opWSP&Du5^%B zAXhD;Y0v+iggaZl=m8lrwb~)^B(n3>C3S{H8U4<){Wl=HR!W~axN=P0j(>d*^tUYIT~aXP_(|Lt)S;h_)ZQl3^H(!eEM4niTL$>K_JWq5`FPX_2wD0Fwh) zxbGf#fIw{-NmJ>?qY>zy|H4mq|`cN^>rlhH`<=6AOhB z&Srj;Y<)KH+k8}6F1Y1j{MhpnUQ$sp7_5cNh#0mhvFGadSj$t1Uw0q$`_{GXla715 z7oR3Q{9?!9OnsR9>My$ZDvX~mPb7ZTMf=D%yxfDGwP0S-igVFz$^ATtUYq4f1Mvr$ CZ=?$V literal 0 HcmV?d00001 diff --git a/spec/fixtures/bad_src_directory/bad_src/ie.scss b/spec/fixtures/bad_src_directory/bad_src/ie.scss new file mode 100644 index 0000000..5cd5b6c --- /dev/null +++ b/spec/fixtures/bad_src_directory/bad_src/ie.scss @@ -0,0 +1,5 @@ +/* Welcome to Compass. Use this file to write IE specific override styles. + * Import this file using the following HTML or equivalent: + * */ diff --git a/spec/fixtures/bad_src_directory/bad_src/print.scss b/spec/fixtures/bad_src_directory/bad_src/print.scss new file mode 100644 index 0000000..b0e9e45 --- /dev/null +++ b/spec/fixtures/bad_src_directory/bad_src/print.scss @@ -0,0 +1,3 @@ +/* Welcome to Compass. Use this file to define print styles. + * Import this file using the following HTML or equivalent: + * */ diff --git a/spec/fixtures/bad_src_directory/bad_src/screen.scss b/spec/fixtures/bad_src_directory/bad_src/screen.scss new file mode 100644 index 0000000..81de847 --- /dev/null +++ b/spec/fixtures/bad_src_directory/bad_src/screen.scss @@ -0,0 +1,6 @@ +/* Welcome to Compass. + * In this file you should write your main styles. (or centralize your imports) + * Import this file using the following HTML or equivalent: + * */ + +@import "compass/reset"; diff --git a/spec/fixtures/bad_src_directory/config.rb b/spec/fixtures/bad_src_directory/config.rb new file mode 100644 index 0000000..fa78bdd --- /dev/null +++ b/spec/fixtures/bad_src_directory/config.rb @@ -0,0 +1,9 @@ +# Require any additional compass plugins here. +# Set this to the root of your project when deployed: +http_path = "/" +css_dir = "stylesheets" +sass_dir = "src" +images_dir = "images" +javascripts_dir = "javascripts" +# To enable relative paths to assets via compass helper functions. Uncomment: +# relative_assets = true diff --git a/spec/fixtures/custom_config_file/.sass-cache/77242121e92e5208094a0a0f6fbd9eb05d2c3832/_utilities.scssc b/spec/fixtures/custom_config_file/.sass-cache/77242121e92e5208094a0a0f6fbd9eb05d2c3832/_utilities.scssc new file mode 100644 index 0000000000000000000000000000000000000000..ed96e6af7df7ef3a3081f480c55fe81b27e9c1c8 GIT binary patch literal 12228 zcmeHN>vG%16}B`T*`nk)zQ&2{WX;?pg(N6BzJa~4aqLXm#>v=9dT|pO1ePLf5TF52 zGV8e0%XFp>(3j}n&h#bvRQ=A`#S#EXS+SM=$kbzrBzX2aXU~1l>T;vm*xVGWHv=b0 zM&c%Z``&1+(sVrM+Gg{zccUXebg$mHvEg06as8Uxz0$q9dDU??-7B5WhU-**bS$!8 zzlUYEy%kGo+jpZVy%Tw|VprOMA4-40KHiQ7sUL;O(^u>hLF9Pb11Iez_bb(3T3;qI zPOK>KcYPUKA4l%6FT*skJ|D>NUNnqdY3&T1*sHrye*iXCGLWvNKWq=;hgK51)vqjY zu!6{S0xR%4Ry^#CtR2};tc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B5^U=Y((YEe9KfE+i&&VmSR*H3u0vg@PFuCwQ$`t?7JkI;FMXRf*$p?NEW$uG=q z59YVO%I!~N`=j9$-Kk~M)k&c~8w;h~G}kU3E6H@n$ne3Q zYgSd%2)AIdf+oH&D^HAvyyN9+*jrf62EWV8l))QDA(Uum&VeV@bB{sTX0saMvf;MI z;^vy>ESwj4`Zy`=S2=0V8)>sauR22JO2Dtja!skRWxM^xh;*hjkTz;OZU)l@*$RgE zt${hMVf5(Qpe!`^@qpirm(PgbB|Ypeh``4DJ+D>9T%S_XY=8#_U{<=Dt*#EQRqATy)Mbt~V#>sR zQfV&3u+nBUN>s@5#oaSPFR3BF*>FV-`wROu?YGPrQTu&v;x<4Xu?md3hS9RVBru$g z;jj1nSib zT~1)#pxd;L7_i+&d*wRIaI@!}8{JUR-0FC|~=psbZ<|gt~Wodd# z{|@IOM1xUxl)K}|cpT^=BoC3l;n)WxPo^(ICL?X`X%;{$)l+Kpl)3MP`$uUixuT|$ z**Wej+>6oQ(H(0YeR>236cm5;M?~b`IE&F7l0oOcox@>IA3^YUmVExBfx;S=w&~lI z>MP@04_a-%R^;_j6a|X~yxSZ_JeM#jVD8&&3&;UxikiuLdl=H+39(opWSP&Du5^%B zAXhD;Y0v+iggaZl=m8lrwb~)^B(n3>C3S{H8U4<){Wl=HR!W~axN=P0j(>d*^tUYIT~aXP_(|Lt)S;h_)ZQl3^H(!eEM4niTL$>K_JWq5`FPX_2wD0Fwh) zxbGf#fIw{-NmJ>?qY>zy|H4mq|`cN^>rlhH`<=6AOhB z&Srj;Y<)KH+k8}6F1Y1j{MhpnUQ$sp7_5cNh#0mhvFGadSj$t1Uw0q$`_{GXla715 z7oR3Q{9?!9OnsR9>My$ZDvX~mPb7ZTMf=D%yxfDGwP0S-igVFz$^ATtUYq4f1Mvr$ CZ=?$V literal 0 HcmV?d00001 diff --git a/spec/fixtures/custom_config_file/another_config_location/config.rb b/spec/fixtures/custom_config_file/another_config_location/config.rb new file mode 100644 index 0000000..10db72c --- /dev/null +++ b/spec/fixtures/custom_config_file/another_config_location/config.rb @@ -0,0 +1,9 @@ +# Require any additional compass plugins here. +# Set this to the root of your project when deployed: +http_path = "/" +css_dir = "another_stylesheets_location" +sass_dir = "another_src_location" +images_dir = "another_images_location" +javascripts_dir = "another_javascripts_location" +# To enable relative paths to assets via compass helper functions. Uncomment: +# relative_assets = true diff --git a/spec/fixtures/custom_config_file/another_src_location/ie.scss b/spec/fixtures/custom_config_file/another_src_location/ie.scss new file mode 100644 index 0000000..5cd5b6c --- /dev/null +++ b/spec/fixtures/custom_config_file/another_src_location/ie.scss @@ -0,0 +1,5 @@ +/* Welcome to Compass. Use this file to write IE specific override styles. + * Import this file using the following HTML or equivalent: + * */ diff --git a/spec/fixtures/custom_config_file/another_src_location/print.scss b/spec/fixtures/custom_config_file/another_src_location/print.scss new file mode 100644 index 0000000..b0e9e45 --- /dev/null +++ b/spec/fixtures/custom_config_file/another_src_location/print.scss @@ -0,0 +1,3 @@ +/* Welcome to Compass. Use this file to define print styles. + * Import this file using the following HTML or equivalent: + * */ diff --git a/spec/fixtures/custom_config_file/another_src_location/screen.scss b/spec/fixtures/custom_config_file/another_src_location/screen.scss new file mode 100644 index 0000000..81de847 --- /dev/null +++ b/spec/fixtures/custom_config_file/another_src_location/screen.scss @@ -0,0 +1,6 @@ +/* Welcome to Compass. + * In this file you should write your main styles. (or centralize your imports) + * Import this file using the following HTML or equivalent: + * */ + +@import "compass/reset"; diff --git a/spec/fixtures/dsl/simple/Guardfile b/spec/fixtures/dsl/simple/Guardfile new file mode 100644 index 0000000..2d17c39 --- /dev/null +++ b/spec/fixtures/dsl/simple/Guardfile @@ -0,0 +1 @@ +guard 'compass', :workdir => 'test', :configuration_file => 'test_also.rb' \ No newline at end of file diff --git a/spec/fixtures/no_config_file/.sass-cache/77242121e92e5208094a0a0f6fbd9eb05d2c3832/_utilities.scssc b/spec/fixtures/no_config_file/.sass-cache/77242121e92e5208094a0a0f6fbd9eb05d2c3832/_utilities.scssc new file mode 100644 index 0000000000000000000000000000000000000000..ed96e6af7df7ef3a3081f480c55fe81b27e9c1c8 GIT binary patch literal 12228 zcmeHN>vG%16}B`T*`nk)zQ&2{WX;?pg(N6BzJa~4aqLXm#>v=9dT|pO1ePLf5TF52 zGV8e0%XFp>(3j}n&h#bvRQ=A`#S#EXS+SM=$kbzrBzX2aXU~1l>T;vm*xVGWHv=b0 zM&c%Z``&1+(sVrM+Gg{zccUXebg$mHvEg06as8Uxz0$q9dDU??-7B5WhU-**bS$!8 zzlUYEy%kGo+jpZVy%Tw|VprOMA4-40KHiQ7sUL;O(^u>hLF9Pb11Iez_bb(3T3;qI zPOK>KcYPUKA4l%6FT*skJ|D>NUNnqdY3&T1*sHrye*iXCGLWvNKWq=;hgK51)vqjY zu!6{S0xR%4Ry^#CtR2};tc}KX^+qqLHyazx#ucj@JAJtq#g7uJ6Aa}b_QTXl(orCj zo|I`)efTnv+Xi#n1GaRXRC?Qfe-OpkTb|9<%djyz$;sV&8NlsKvHMGHpCZc=F&k^k zKJ7YgPi~U|$k5e$hhW!60&~|H*sie3?BnvuzzIF+*%f}iWiKV8Fm;~Ti-`*tJTr)+ zfsE79wtC#OPvY@**AHX}b63AP1hI0)vl16BA2x{fal<5j83RnQXy)uzEEAbp+r!ik z{M468gZF%@-E)#{x9105EW<7Pm3Auog8&X!owr}LEb)<(NKZtexPL45UGbS5$@u+5 zFxuCvy)+%zmer@Hd$QAj0G0%umG+|HP7mI?*=%03npdpmhLWHjONwFXS!)%*e-cC; zCs1%A9wL4k^!RoZi+&VKLGkK$!I&8)H8D)2NPAMR==)FnFcC1^t`AJn0r(yO2xI+= zKtgzNCrahIEmEfgbdg~Hfe0mtAGk6Il7Zv;;m%L0&FTZ;hm75K;zz?lqta%0vBNS# za41kbtq9Re`$0`~B5za^p1)gzlulR^&R`J8v?ij?L+Rqx=PXg91sgTd+r-ah{CtR? zEBLuu69b^Y>mNNHLPmUyB~d$o>U3iKcH<}<_3_4obrS5pl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jVD8&&3&;UxikiuLdl=H+39(opWSP&Du5^%B zAXhD;Y0v+iggaZl=m8lrwb~)^B(n3>C3S{H8U4<){Wl=HR!W~axN=P0j(>d*^tUYIT~aXP_(|Lt)S;h_)ZQl3^H(!eEM4niTL$>K_JWq5`FPX_2wD0Fwh) zxbGf#fIw{-NmJ>?qY>zy|H4mq|`cN^>rlhH`<=6AOhB z&Srj;Y<)KH+k8}6F1Y1j{MhpnUQ$sp7_5cNh#0mhvFGadSj$t1Uw0q$`_{GXla715 z7oR3Q{9?!9OnsR9>My$ZDvX~mPb7ZTMf=D%yxfDGwP0S-igVFz$^ATtUYq4f1Mvr$ CZ=?$V literal 0 HcmV?d00001 diff --git a/spec/fixtures/no_config_file/src/ie.scss b/spec/fixtures/no_config_file/src/ie.scss new file mode 100644 index 0000000..5cd5b6c --- /dev/null +++ b/spec/fixtures/no_config_file/src/ie.scss @@ -0,0 +1,5 @@ +/* Welcome to Compass. Use this file to write IE specific override styles. + * Import this file using the following HTML or equivalent: + * */ diff --git a/spec/fixtures/no_config_file/src/print.scss b/spec/fixtures/no_config_file/src/print.scss new file mode 100644 index 0000000..b0e9e45 --- /dev/null +++ b/spec/fixtures/no_config_file/src/print.scss @@ -0,0 +1,3 @@ +/* Welcome to Compass. Use this file to define print styles. + * Import this file using the following HTML or equivalent: + * */ diff --git a/spec/fixtures/no_config_file/src/screen.scss b/spec/fixtures/no_config_file/src/screen.scss new file mode 100644 index 0000000..81de847 --- /dev/null +++ b/spec/fixtures/no_config_file/src/screen.scss @@ -0,0 +1,6 @@ +/* Welcome to Compass. + * In this file you should write your main styles. (or centralize your imports) + * Import this file using the following HTML or equivalent: + * */ + +@import "compass/reset"; diff --git a/spec/guard/compass_spec.rb b/spec/guard/compass_spec.rb index 998221d..da6e39f 100644 --- a/spec/guard/compass_spec.rb +++ b/spec/guard/compass_spec.rb @@ -5,70 +5,173 @@ describe Guard::Compass do subject { Guard::Compass.new } - before :each do - @project_path = File.expand_path('./compass_prj') + it "has a reporter" do + subject.reporter.should_not be_nil end - describe "start" do - it "supports creation of the updater instance" do - subject.updater.should be_nil - subject.start.should be_true - subject.updater.should_not be_nil + it "might be initialized with options" do + g = Guard::Compass.new([], :workdir => 'test', :configuration_file => 'test_also') + g.options[:workdir].should == 'test' + g.options[:configuration_file].should == 'test_also' + end + + describe "In a standard project" do + + before :each do + create_fixture(:compass_prj) + end + + after :each do + remove_fixtures end + + describe "start" do + it "supports creation of the updater instance" do + subject.updater.should be_nil + subject.start.should be_true + subject.updater.should_not be_nil + end - it "should not generate anything" do - File.exists?(@project_path + "/stylesheets/screen.css").should be_false + it "should not generate anything" do + File.exists?(@project_path + "/stylesheets/screen.css").should be_false + end end - end - describe "default options" do - it "should have a default path mathching the run location" do - subject.options[:workdir].should == File.expand_path(".") - subject.start.should be_true + describe "default options" do + it "should have a default path mathching the run location" do + subject.options[:workdir].should == @project_path + subject.start.should be_true + end end - end - describe "after start" do + describe "after start" do + + before :each do + subject.start + end + + after :each do + subject.stop + end + + describe "the updater" do + it "should contains an options hashmap with config file values" do + ::Compass.configuration.sass_path.should_not be_nil + ::Compass.configuration.sass_path.should == "#{@project_path}/src" + end + end + + describe "stop" do + it "Stop remove the updater" do + subject.updater.should_not be_nil + subject.stop.should be_true + subject.updater.should be_nil + end + end + + describe "run_on_change" do + it "rebuilds all scss files in compass path" do + File.exists?(@project_path + "/src/screen.scss").should(be_true) + File.exists?(@project_path + "/stylesheets/screen.css").should be_false + subject.run_on_change(@project_path + "/src/screen.scss").should be_true + File.exists?(@project_path + "/stylesheets/screen.css").should be_true + end + end + + describe "run all" do + it "rebuilds all scss files in compass path" do + File.exists?(@project_path + "/src/screen.scss").should(be_true) + File.exists?(@project_path + "/stylesheets/screen.css").should be_false + subject.run_all.should be_true + File.exists?(@project_path + "/stylesheets/screen.css").should be_true + end + end + end + end + + describe "with custom configuration and locations" do before :each do - FileUtils.mkdir(TMP_PATH) if ! File.exists? TMP_PATH - @project_path = TMP_PATH + '/compass_prj' - FileUtils.cp_r FIXTURES_PATH + '/compass_prj', TMP_PATH - subject.options.merge!(:workdir => @project_path) - - subject.start + create_fixture(:custom_config_file) end + after :each do - FileUtils.rm_rf(TMP_PATH) - + remove_fixtures subject.stop end - describe "stop" do - it "Stop remove the updater" do - subject.updater.should_not be_nil - subject.stop.should be_true - subject.updater.should be_nil - end + it "configure Compass correctly with an absolute path" do + subject.options[:configuration_file] = "#{@project_path}/another_config_location/config.rb" + subject.start + Compass.configuration.sass_path.should == "#{@project_path}/another_src_location" + Compass.configuration.sass_path.should == "#{@project_path}/another_src_location" + end + + it "configure Compass correctly with a path relative to the workdir" do + subject.options[:configuration_file] = "another_config_location/config.rb" + subject.start + end + + it "rebuilds all scss files in compass path" do + subject.options[:configuration_file] = "#{@project_path}/another_config_location/config.rb" + subject.start + File.exists?("#{@project_path}/another_src_location/screen.scss").should(be_true) + File.exists?("#{@project_path}/another_stylesheets_location/screen.css").should be_false + subject.run_on_change(@project_path + "/another_src_location/screen.scss").should be_true + File.exists?(@project_path + "/another_stylesheets_location/screen.css").should be_true + end + end + + describe "without config file" do + before :each do + create_fixture(:no_config_file) + subject.start + end + + after :each do + remove_fixtures + subject.stop end describe "run_on_change" do - it "rebuilds all scss files in compass path" do + it "rebuilds all scss files in src by default" do File.exists?(@project_path + "/src/screen.scss").should(be_true) File.exists?(@project_path + "/stylesheets/screen.css").should be_false subject.run_on_change(@project_path + "/src/screen.scss").should be_true File.exists?(@project_path + "/stylesheets/screen.css").should be_true end end - - describe "run all" do - it "rebuilds all scss files in compass path" do - File.exists?(@project_path + "/src/screen.scss").should(be_true) - File.exists?(@project_path + "/stylesheets/screen.css").should be_false - subject.run_all.should be_true - File.exists?(@project_path + "/stylesheets/screen.css").should be_true - end + end + + describe "with a bad directory configuration" do + before :each do + create_fixture(:bad_src_directory) + subject.reporter.stub!(:failure).with("Sass files src directory not found: #{@project_path}/src\nPlease check your Compass configuration.") + subject.start + end + + after :each do + remove_fixtures + subject.stop end + it "rebuilds failed to build sass" do + File.exists?(@project_path + "/bad_src/screen.scss").should(be_true) + File.exists?(@project_path + "/stylesheets/screen.css").should be_false + + subject.run_on_change(@project_path + "/bad_src/screen.scss") + end + end + +private + def create_fixture(name) + FileUtils.mkdir(TMP_PATH) if ! File.exists? TMP_PATH + @project_path = "#{TMP_PATH}/#{name}" + FileUtils.cp_r "#{FIXTURES_PATH}/#{name}", TMP_PATH + subject.options.merge!(:workdir => @project_path) + end + + def remove_fixtures + FileUtils.rm_rf(TMP_PATH) end end diff --git a/spec/guard/dsl_spec.rb b/spec/guard/dsl_spec.rb new file mode 100644 index 0000000..8b48504 --- /dev/null +++ b/spec/guard/dsl_spec.rb @@ -0,0 +1,19 @@ +require 'spec_helper' +require 'guard/dsl' + +describe Guard::Dsl do + subject {Guard::Dsl} + + it "load a guard from the DSL" do + File.exists?("#{FIXTURES_PATH}/dsl/simple").should be_true + File.exists?("#{FIXTURES_PATH}/dsl/simple/Guardfile").should be_true + + ## Hack to make guard look into the correct fixture folder + Dir.stub!(:pwd).and_return("#{FIXTURES_PATH}/dsl/simple") + Dir.pwd.should == "#{FIXTURES_PATH}/dsl/simple" + + ::Guard.stub!(:add_guard) + ::Guard.should_receive(:add_guard).with('compass', [], hash_including(:workdir, :configuration_file)) + subject.evaluate_guardfile + end +end \ No newline at end of file diff --git a/spec/guard/reporter_spec.rb b/spec/guard/reporter_spec.rb new file mode 100644 index 0000000..efedc8d --- /dev/null +++ b/spec/guard/reporter_spec.rb @@ -0,0 +1,19 @@ +require 'spec_helper' +require 'guard/reporter' + +describe Guard::Reporter do + subject {Guard::Reporter.new} + + it "respond_to failure" do + subject.should respond_to :failure + end + it "respond_to success" do + subject.should respond_to :success + end + it "respond_to announce" do + subject.should respond_to :announce + end + it "respond_to unstable" do + subject.should respond_to :unstable + end +end \ No newline at end of file diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 592823d..cf7faee 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,6 +1,7 @@ require 'spec_helper' -FIXTURES_PATH = File.expand_path(File.dirname(__FILE__) + '/fixtures') +FIXTURES_PATH = Pathname.new(File.expand_path('../fixtures/', __FILE__)) +LIB_PATH = Pathname.new(File.expand_path('../../lib/', __FILE__)) TMP_PATH = File.expand_path(File.dirname(__FILE__) + '/tmp_files') RSpec.configure do |config| @@ -10,7 +11,5 @@ config.before(:each) do ENV["GUARD_ENV"] = 'test' - @fixture_path = Pathname.new(File.expand_path('../fixtures/', __FILE__)) - @lib_path = Pathname.new(File.expand_path('../../lib/', __FILE__)) end end