Sha256: 75d74d240ab3b806619569d6ec59bb5af61491343e1a5aac637b6745495d3567

Contents?: true

Size: 1.09 KB

Versions: 69

Compression:

Stored size: 1.09 KB

Contents

#!/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 < MiniTest::Test
  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

Version data entries

69 entries across 66 versions & 7 rubygems

Version Path
files.com-1.0.55 docs/vendor/bundle/ruby/2.5.0/gems/sass-3.4.25/test/sass/callbacks_test.rb
brakeman-4.3.1 bundle/ruby/2.5.0/gems/sass-3.4.25/test/sass/callbacks_test.rb
brakeman-4.3.0 bundle/ruby/2.5.0/gems/sass-3.4.25/test/sass/callbacks_test.rb
brakeman-4.2.1 bundle/ruby/2.5.0/gems/sass-3.4.25/test/sass/callbacks_test.rb
brakeman-4.2.0 bundle/ruby/2.3.0/gems/sass-3.4.25/test/sass/callbacks_test.rb
brakeman-4.1.1 bundle/ruby/2.3.0/gems/sass-3.4.25/test/sass/callbacks_test.rb
brakeman-4.1.0 bundle/ruby/2.3.0/gems/sass-3.4.25/test/sass/callbacks_test.rb
brakeman-4.0.1 bundle/ruby/2.3.0/gems/sass-3.4.25/test/sass/callbacks_test.rb
brakeman-4.0.1.pre1 bundle/ruby/2.3.0/gems/sass-3.4.25/test/sass/callbacks_test.rb
brakeman-4.0.0 bundle/ruby/2.3.0/gems/sass-3.4.25/test/sass/callbacks_test.rb
brakeman-3.7.2 bundle/ruby/2.3.0/gems/sass-3.4.25/test/sass/callbacks_test.rb
brakeman-3.7.1 bundle/ruby/2.3.0/gems/sass-3.4.25/test/sass/callbacks_test.rb
sass-3.4.25 test/sass/callbacks_test.rb
brakeman-3.7.0 bundle/ruby/2.3.0/gems/sass-3.4.24/test/sass/callbacks_test.rb
brakeman-3.6.2 bundle/ruby/2.3.0/gems/sass-3.4.24/test/sass/callbacks_test.rb
sass-3.4.24 test/sass/callbacks_test.rb
brakeman-3.6.1 bundle/ruby/2.3.0/gems/sass-3.4.23/test/sass/callbacks_test.rb
brakeman-3.6.0 bundle/ruby/2.3.0/gems/sass-3.4.23/test/sass/callbacks_test.rb
brakeman-3.5.0 bundle/ruby/2.3.0/gems/sass-3.4.23/test/sass/callbacks_test.rb
arcabouco-0.2.13 vendor/bundle/gems/sass-3.4.22/test/sass/callbacks_test.rb