require 'rails_helper'

RSpec.feature 'Presenters' do
  scenario 'render a presenter' do
    visit user_path(view: 'model_with_presenter', id: '1')

    within 'div#user_1' do
      expect(page).to have_content 'Test 1 : test1@example.com : custom'
    end
  end


  scenario 'render a collection of presenters' do
    visit user_path(view: 'list_with_presenter', id: '1')

    within 'tr#user_1' do
      expect(page).to have_content 'Test 1 : test1@example.com : custom'
    end

    within 'tr#user_2' do
      expect(page).to have_content 'Test 2 : test2@example.com : custom'
    end
  end


  context 'when .delegate_conversions is used' do
    scenario 'delegates the ActiveModel::Conversion methods to the model' do
      visit user_path(view: 'presenter_with_conversions', id: '1')

      expect(page).to have_css 'div#param_Test1_1'
    end
  end
end
