Mainly {{_main|core}}
# -*- encoding : utf-8 -*- describe Card::HtmlFormat do describe "views" do it "content" do result = render_card(:content, :name=>'A+B') assert_view_select result, 'div[class="card-slot content-view card-content ALL ALL_PLUS TYPE-basic RIGHT-b TYPE_PLUS_RIGHT-basic-b SELF-a-b"]' end it "inclusions in multi edit" do c = Card.new :name => 'ABook', :type => 'Book' rendered = c.format.render( :edit ) assert_view_select rendered, 'fieldset' do assert_select 'textarea[name=?][class="tinymce-textarea card-content"]', 'card[subcards][+illustrator][content]' end end it "titled" do result = render_card :titled, :name=>'A+B' assert_view_select result, 'div[class~="titled-view"]' do assert_select 'h1' do assert_select 'span' end assert_select 'div[class~="card-body card-content"]', 'AlphaBeta' end end context "full wrapping" do before do @ocslot = Card['A'].format end it "should have the appropriate attributes on open" do assert_view_select @ocslot.render(:open), 'div[class="card-slot open-view card-frame ALL TYPE-basic SELF-a"]' do assert_select 'h1[class="card-header"]' do assert_select 'span[class="card-title"]' end assert_select 'div[class~="card-body"]' end end it "should have the appropriate attributes on closed" do v = @ocslot.render(:closed) assert_view_select v, 'div[class="card-slot closed-view card-frame ALL TYPE-basic SELF-a"]' do assert_select 'h1[class="card-header"]' do assert_select 'span[class="card-title"]' end assert_select 'div[class~="closed-content card-content"]' end end end context "Cards with special views" do end context "Simple page with Default Layout" do before do Card::Auth.as_bot do card = Card['A+B'] @simple_page = card.format.render(:layout) #warn "render sp: #{card.inspect} :: #{@simple_page}" end end it "renders top menu" do #warn "sp #{@simple_page}" assert_view_select @simple_page, 'div[id="menu"]' do assert_select 'a[class="internal-link"][href="/"]', 'Home' assert_select 'a[class="internal-link"][href="/recent"]', 'Recent' assert_select 'form.navbox-form[action="/:search"]' do assert_select 'input[name="_keyword"]' end end end it "renders card header" do # lots of duplication here... assert_view_select @simple_page, 'h1[class="card-header"]' do assert_select 'span[class="card-title"]' end end it "renders card content" do assert_view_select @simple_page, 'div[class="card-body card-content ALL ALL_PLUS TYPE-basic RIGHT-b TYPE_PLUS_RIGHT-basic-b SELF-a-b"]', 'AlphaBeta' end it "renders card credit" do assert_view_select @simple_page, 'div[class~="SELF-Xcredit"]' do#, /Wheeled by/ do assert_select 'img' assert_select 'a', "Wagn v#{Wagn::Version.release}" end end end context "layout" do before do Card::Auth.as_bot do @layout_card = Card.create(:name=>'tmp layout', :type=>'Layout') #warn "layout #{@layout_card.inspect}" end c = Card['*all+*layout'] and c.content = '[[tmp layout]]' @main_card = Card.fetch('Joe User') #warn "lay #{@layout_card.inspect}, #{@main_card.inspect}" end it "should default to core view when in layout mode" do @layout_card.content = "Hi {{A}}" Card::Auth.as_bot { @layout_card.save } expect(@main_card.format.render(:layout)).to match('Hi Alpha') end it "should default to open view for main card" do @layout_card.content='Open up {{_main}}' Card::Auth.as_bot { @layout_card.save } result = @main_card.format.render_layout expect(result).to match(/Open up/) expect(result).to match(/card-header/) expect(result).to match(/Joe User/) end it "should render custom view of main" do @layout_card.content='Hey {{_main|name}}' Card::Auth.as_bot { @layout_card.save } result = @main_card.format.render_layout expect(result).to match(/Hey.*div.*Joe User/) expect(result).not_to match(/card-header/) end it "shouldn't recurse" do @layout_card.content="Mainly {{_main|core}}" Card::Auth.as_bot { @layout_card.save } rendered = expect(@layout_card.format.render(:layout)).to eq( %{Mainly
Mainly {{_main|core}}