Sha256: 5baee571c84061003342020be075eaaf1aa158e2ebfec8130a7e6591bfcec78e

Contents?: true

Size: 1.56 KB

Versions: 17

Compression:

Stored size: 1.56 KB

Contents

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

module MixinSpec
  
  describe Erector::Mixin do
    describe "#erector" do
      it "renders its block to a string" do
        
        class Thing
          include Erector::Mixin
          def name
            erector do
              span :class => "name" do
                text "Gabriel "
                i "Garcia"
                text " Marquez"
              end
            end
          end
        end
        
        Thing.new.name.should == "<span class=\"name\">Gabriel <i>Garcia</i> Marquez</span>"
      end
      
      it "passes its parameters to to_html" do
        class Thing
          include Erector::Mixin
          def pretty_name
            erector(:prettyprint => true) do
              div :class => "name" do
                ul do
                  li "Gabriel"
                  li "Garcia"
                  li "Marquez"
                end
              end
            end
          end
        end
        
        Thing.new.pretty_name.should == 
        "<div class=\"name\">\n" + 
        "  <ul>\n" + 
        "    <li>Gabriel</li>\n" +
        "    <li>Garcia</li>\n" +
        "    <li>Marquez</li>\n" +
        "  </ul>\n" +
        "</div>\n"
      end

      it "passes its parameters to the widget too" do
        class Thing
          include Erector::Mixin
          def foo
            erector(:foo => "bar") do
              div @foo
            end
          end
        end
        Thing.new.foo.should == "<div>bar</div>"
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 3 rubygems

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