liquid_droppable_spec.rb 711 B

12345678910111213141516171819202122232425262728293031323334
  1. require 'rails_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. expect(five.to_liquid.class).to eq(DroppableTestDrop)
  24. expect(Liquid::Template.parse('{{ x.value | plus:3 }}').render('x' => five)).to eq('8')
  25. expect(Liquid::Template.parse('{{ x }}').render('x' => five)).to eq('[value:5]')
  26. end
  27. end
  28. end