All Downloads are FREE. Search and download functionalities are using the official Maven repository.

gems.sass-3.2.8.test.sass.callbacks_test.rb Maven / Gradle / Ivy

Go to download

Sass makes CSS fun again. Sass is an extension of CSS3, adding nested rules, variables, mixins, selector inheritance, and more. It's translated to well-formatted, standard CSS using the command line tool or a web-framework plugin. This is a repackaged GEM in a JAR format of the sass-lang.gem package. The sass-gems package version follows the sass-lang.gem versions located http://rubyforge.org/frs/?group_id=9702. Simply change the version of this package to download and repackage the same GEM version.

There is a newer version: 3.2.9
Show newest version
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../test_helper'
require 'sass/callbacks'

class CallerBack
  extend Sass::Callbacks
  define_callback :foo
  define_callback :bar

  def do_foo
    run_foo
  end

  def do_bar
    run_bar 12
  end
end

module ClassLevelCallerBack
  extend Sass::Callbacks
  define_callback :foo
  extend self

  def do_foo
    run_foo
  end
end

class SassCallbacksTest < Test::Unit::TestCase
  def test_simple_callback
    cb = CallerBack.new
    there = false
    cb.on_foo {there = true}
    cb.do_foo
    assert there, "Expected callback to be called."
  end

  def test_multiple_callbacks
    cb = CallerBack.new
    str = ""
    cb.on_foo {str += "first"}
    cb.on_foo {str += " second"}
    cb.do_foo
    assert_equal "first second", str
  end

  def test_callback_with_arg
    cb = CallerBack.new
    val = nil
    cb.on_bar {|a| val = a}
    cb.do_bar
    assert_equal 12, val
  end

  def test_class_level_callback
    there = false
    ClassLevelCallerBack.on_foo {there = true}
    ClassLevelCallerBack.do_foo
    assert there, "Expected callback to be called."
  end
end




© 2015 - 2024 Weber Informatics LLC | Privacy Policy