Sha256: c14f1e79b19aab7d2e04c8b0429ab43b25809dc3619e7f1b554c34db8ac26038
Contents?: true
Size: 1.69 KB
Versions: 1
Compression:
Stored size: 1.69 KB
Contents
require 'rodakase/view' RSpec.describe 'Rodakase View' do let(:view_class) do klass = Class.new(Rodakase::View::Layout) klass.configure do |config| config.renderer = renderer config.engine = :slim config.name = 'app' config.template = 'users' end klass end let(:renderer) do Rodakase::View::Renderer.new(SPEC_ROOT.join('fixtures/templates'), engine: :slim) end let(:scope) do Struct.new(:title).new('Rodakase Rocks!') end it 'renders within a layout using provided scope' do view = view_class.new users = [ { name: 'Jane', email: 'jane@doe.org' }, { name: 'Joe', email: 'joe@doe.org' } ] expect(view.(scope: scope, locals: { users: users })).to eql( '<!DOCTYPE html><html><head><title>Rodakase Rocks!</title></head><body><div class="users"><table><tbody><tr><td>Jane</td><td>jane@doe.org</td></tr><tr><td>Joe</td><td>joe@doe.org</td></tr></tbody></table></div></body></html>' ) end describe 'inheritance' do let(:parent_view) do klass = Class.new(Rodakase::View::Layout) klass.setting :renderer, renderer klass.setting :engine, :slim klass.setting :name, 'app' klass end let(:child_view) do Class.new(parent_view) do configure do |config| config.template = 'tasks' end end end it 'renders within a parent class layout using provided scope' do view = child_view.new expect(view.(scope: scope, locals: { tasks: [{ title: 'one' }, { title: 'two' }] })).to eql( '<!DOCTYPE html><html><head><title>Rodakase Rocks!</title></head><body><ol><li>one</li><li>two</li></ol></body></html>' ) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rodakase-0.0.1 | spec/integration/view_spec.rb |