require 'spec_helper' require 'rack/csrf' describe Locomotive::Steam::Liquid::Tags::ModelForm do before do allow(Rack::Csrf).to receive(:field).and_return('token') allow(Rack::Csrf).to receive(:token).and_return(42) end let(:request) { instance_double('Request', env: {}) } let(:source) { "{% model_form 'newsletter_addresses' %}Newsletter Form{% endmodel_form %}" } let(:services) { Locomotive::Steam::Services.build_instance(request) } let(:context) { ::Liquid::Context.new({ path: '' }, {}, { services: services }) } subject { render_template(source, context) } it { is_expected.to eq %(
Newsletter Form
) } describe 'with a different dom id and css class' do let(:source) { "{% model_form 'newsletter_addresses', id: 'my-form', class: 'col-md-12' %}Newsletter Form{% endmodel_form %}" } it { is_expected.to eq %(
Newsletter Form
) } end describe 'using callbacks' do let(:source) { "{% model_form 'newsletter_addresses', success: '/success', error: '/error' %}Newsletter Form{% endmodel_form %}" } it { is_expected.to include %() } it { is_expected.to include %() } end describe 'json enabled' do let(:source) { "{% model_form 'newsletter_addresses', json: true %}Newsletter Form{% endmodel_form %}" } it { is_expected.to eq %(
Newsletter Form
) } end end