require 'rails_helper'

RSpec.describe "emails/index", :type => :view do
  before(:each) do
    assign(:emails, [
      Email.create!(
        :from => "From",
        :to => "To",
        :subject => "Subject",
        :body => "MyText",
        :mailed_by => "Mailed By"
      ),
      Email.create!(
        :from => "From",
        :to => "To",
        :subject => "Subject",
        :body => "MyText",
        :mailed_by => "Mailed By"
      )
    ])
  end

  it "renders a list of emails" do
    render
    assert_select "tr>td", :text => "From".to_s, :count => 2
    assert_select "tr>td", :text => "To".to_s, :count => 2
    assert_select "tr>td", :text => "Subject".to_s, :count => 2
    assert_select "tr>td", :text => "MyText".to_s, :count => 2
    assert_select "tr>td", :text => "Mailed By".to_s, :count => 2
  end
end
