Sha256: bc4edef3ab9fa9b789c25226f48f5feed096494e1c86937a28041d0e5735a38e

Contents?: true

Size: 1.37 KB

Versions: 45

Compression:

Stored size: 1.37 KB

Contents

module Compass
  module TestCaseHelper
    def absolutize(path)
      if Compass::Util.blank?(path)
        File.expand_path('../../', __FILE__)
      elsif path[0] == ?/
        File.join(File.expand_path('../', __FILE__), path)
      else
        File.join(File.expand_path('../../', __FILE__), path)
      end
    end

    # compile a Sass string in the context of a project in the current working directory.
    def compile_for_project(contents, options = {})
      Compass.add_project_configuration
      options[:syntax] ||= :scss
      Sass::Engine.new(contents, Compass.configuration.to_sass_engine_options.merge(options)).render
    end

    def assert_correct(before, after)
      if before == after
        assert(true)
      else
        assert false, diff_as_string(before.inspect, after.inspect)
      end
    end
    
    module ClassMethods

      def let(method, &block)
        define_method method, &block
      end

      def it(name, &block)
        test(name, &block)
      end

      def test(name, &block)
        define_method "test_#{underscore(name)}".to_sym, &block
      end

      def setup(&block)
        define_method :setup do
          yield
        end
      end

      def after(&block)
        define_method :teardown do
          yield
        end
      end

      private 

      def underscore(string)
        string.gsub(' ', '_')
      end

    end
  end
end

Version data entries

45 entries across 44 versions & 5 rubygems

Version Path
arcabouco-0.2.13 vendor/bundle/gems/compass-1.0.3/test/helpers/test_case.rb
compass-1.0.3 test/helpers/test_case.rb
compass-1.1.0.alpha.3 test/helpers/test_case.rb
compass-1.1.0.alpha.2 test/helpers/test_case.rb
compass-1.1.0.alpha.1 test/helpers/test_case.rb
compass-1.1.0.alpha.0 test/helpers/test_case.rb
compass-1.0.1 test/helpers/test_case.rb
compass-1.0.0 test/helpers/test_case.rb
compass-1.0.0.rc.1 test/helpers/test_case.rb
compass-1.0.0.rc.0 test/helpers/test_case.rb
compass-0.12.7 test/helpers/test_case.rb
compass-1.0.0.alpha.21 test/helpers/test_case.rb
compass-1.0.0.alpha.20 test/helpers/test_case.rb
archetype-0.0.1.pre.12 test/helpers/test_case.rb
archetype-0.0.1.pre.11 test/helpers/test_case.rb
sadui-0.0.4 vendor/bundle/ruby/2.0.0/gems/compass-0.12.3/test/helpers/test_case.rb
sadui-0.0.4 vendor/bundle/ruby/2.1.0/gems/compass-0.12.3/test/helpers/test_case.rb
compass-0.12.6 test/helpers/test_case.rb
compass-0.12.5 test/helpers/test_case.rb
compass-0.12.4 test/helpers/test_case.rb