require 'spec_helper' describe DomFor::Model do context '#dom_for_model' do it 'returns empty div' do expect(helper.dom_for_model(User.new)).to eq '
' end it 'returns div without nested tags' do expect(helper.dom_for_model(User)).to eq '
' end it 'returns div with data-action attribute' do helper.request.stub(:path_parameters).and_return({ action: 'show' }) expect(helper.dom_for_model(User)).to eq '
' end it 'returns div for the new user' do @user = User.new(name: 'test') helper.request.stub(:path_parameters).and_return({ action: 'new' }) expect(helper.dom_for_model(User)).to eq '
' end it 'returns div for the new user without request' do @user = User.new(name: 'test') expect(helper.dom_for_model(User)).to eq '
' end it 'returns div for the saved user' do @user = User.create(name: 'test') helper.request.stub(:path_parameters).and_return({ action: 'show' }) expect(helper.dom_for_model(User)).to eq '
' end it 'returns div with the additional data-attributes' do @user = User.create(name: 'test') helper.request.stub(:path_parameters).and_return({ action: 'show' }) expect(helper.dom_for_model(User, admin: true)).to eq '
' end it 'returns div with nested tags' do @user = User.create(name: 'test') helper.request.stub(:path_parameters).and_return({ action: 'show' }) expect( helper.dom_for_model(User, admin: true) { helper.tag(:span) } ).to eq '
' end end end