Sha256: 465fd706dd998415c8486d91c67a0aac5e470f5a82bf812d9d9bbae3511d09f5

Contents?: true

Size: 1.48 KB

Versions: 16

Compression:

Stored size: 1.48 KB

Contents

describe "Fortitude method precedence", :type => :system do
  it "should have widget methods > need methods > helper methods > tag methods" do
    helpers_class = Class.new do
      def foo
        "helper_foo"
      end

      def bar
        "helper_bar"
      end

      def baz
        "helper_baz"
      end

      def quux
        "helper_quux"
      end
    end

    helpers_object = helpers_class.new

    wc = widget_class do
      tag :foo
      tag :bar
      tag :baz
      tag :quux

      helper :foo, :bar, :baz

      needs :foo => 'need_foo', :bar => 'need_bar'

      def foo
        "method foo"
      end

      def content
        text "foo: #{foo}, "
        text "bar: #{bar}, "
        text "baz: #{baz}, "
        quux
      end
    end

    expect(render(wc, :rendering_context => rc(
      :helpers_object => helpers_object))).to eq("foo: method foo, bar: need_bar, baz: helper_baz, <quux></quux>")
  end

  it "should let you override 'needs' methods in superclasses, and have them still apply in subclasses" do
    wc_parent = widget_class do
      needs :foo, :bar => 'default_bar'

      def foo
        "pre#{super}post"
      end

      def content
        text "parent: foo: #{foo}, bar: #{bar}"
      end
    end

    wc_child = widget_class(:superclass => wc_parent) do
      def content
        text "child: foo: #{foo}, bar: #{bar}"
      end
    end

    expect(render(wc_child.new(:foo => 'supplied_foo'))).to eq("child: foo: presupplied_foopost, bar: default_bar")
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
fortitude-0.9.6-java spec/system/method_precedence_system_spec.rb
fortitude-0.9.6 spec/system/method_precedence_system_spec.rb
fortitude-0.9.5-java spec/system/method_precedence_system_spec.rb
fortitude-0.9.5 spec/system/method_precedence_system_spec.rb
fortitude-0.9.4-java spec/system/method_precedence_system_spec.rb
fortitude-0.9.4 spec/system/method_precedence_system_spec.rb
fortitude-0.9.3-java spec/system/method_precedence_system_spec.rb
fortitude-0.9.3 spec/system/method_precedence_system_spec.rb
fortitude-0.9.2-java spec/system/method_precedence_system_spec.rb
fortitude-0.9.2 spec/system/method_precedence_system_spec.rb
fortitude-0.9.1-java spec/system/method_precedence_system_spec.rb
fortitude-0.9.1 spec/system/method_precedence_system_spec.rb
fortitude-0.9.0-java spec/system/method_precedence_system_spec.rb
fortitude-0.9.0 spec/system/method_precedence_system_spec.rb
fortitude-0.0.10-java spec/system/method_precedence_system_spec.rb
fortitude-0.0.10 spec/system/method_precedence_system_spec.rb