1
0

liquid_droppable_spec.rb 695 B

12345678910111213141516171819202122232425262728293031323334
  1. require 'spec_helper'
  2. describe LiquidDroppable do
  3. before do
  4. class DroppableTest
  5. include LiquidDroppable
  6. def initialize(value)
  7. @value = value
  8. end
  9. attr_reader :value
  10. def to_s
  11. "[value:#{value}]"
  12. end
  13. end
  14. class DroppableTestDrop
  15. def value
  16. @object.value
  17. end
  18. end
  19. end
  20. describe 'test class' do
  21. it 'should be droppable' do
  22. five = DroppableTest.new(5)
  23. five.to_liquid.class.should == DroppableTestDrop
  24. Liquid::Template.parse('{{ x.value | plus:3 }}').render('x' => five).should == '8'
  25. Liquid::Template.parse('{{ x }}').render('x' => five).should == '[value:5]'
  26. end
  27. end
  28. end