Sha256: e6c04d53bbd65cc3031c4aef8a6dd6da797a89142b5fbea897919024a38ef6bf

Contents?: true

Size: 1.14 KB

Versions: 17

Compression:

Stored size: 1.14 KB

Contents

require File.expand_path("#{File.dirname(__FILE__)}/../spec_helper")

describe Erector::JQuery do
  include Erector::Mixin

  describe "#jquery" do
    def expected(event, *args)

      "<script #{'id="foo" ' if args.include? :id}type=\"text/javascript\">\n" +
              "// <![CDATA[\n\n" +
              "jQuery(document).#{event}(function($){\n" +
              "alert('hello');\n});\n// ]]>\n</script>\n"
    end

    it "outputs a 'jquery ready' script block by default" do
      erector { jquery "alert('hello');" }.should == expected("ready")
    end

    it "outputs attributes" do
      erector { jquery "alert('hello');", :id => 'foo' }.should == expected("ready", :id)
    end

    it "outputs a 'jquery ready' script block when passed a symbol for the first arg" do
      erector { jquery :ready, "alert('hello');" }.should == expected("ready")
    end

    it "outputs a 'jquery load' script block" do
      erector { jquery :load, "alert('hello');" }.should == expected("load")
    end

    it "combines event, text, and attributes" do
      erector { jquery :load, "alert('hello');", :id => "foo" }.should == expected("load", :id)
    end
  end
end

Version data entries

17 entries across 17 versions & 3 rubygems

Version Path
erector-0.10.0 spec/erector/jquery_spec.rb
erector-rails4-0.1.1 spec/erector/jquery_spec.rb
erector-rails4-0.1.0 spec/erector/jquery_spec.rb
erector-rails4-0.0.7 spec/erector/jquery_spec.rb
erector-rails4-0.0.6 spec/erector/jquery_spec.rb
erector-rails4-0.0.5 spec/erector/jquery_spec.rb
erector-rails4-0.0.4 spec/erector/jquery_spec.rb
erector-rails4-0.0.3 spec/erector/jquery_spec.rb
erector-rails4-0.0.2 spec/erector/jquery_spec.rb
erector-rails4-0.0.1 spec/erector/jquery_spec.rb
erector-0.9.0 spec/erector/jquery_spec.rb
erector-0.9.0.pre1 spec/erector/jquery_spec.rb
erector-0.8.3 spec/erector/jquery_spec.rb
erector-0.8.2 spec/erector/jquery_spec.rb
honkster-erector-0.8.1 spec/erector/jquery_spec.rb
erector-0.8.1 spec/erector/jquery_spec.rb
erector-0.8.0 spec/erector/jquery_spec.rb