require 'rails_helper'

RSpec.describe "print_settings/index", type: :view do
  before(:each) do
    assign(:print_settings, [
      PrintSetting.create!(
        :name, => "Name,",
        :unique_code, => "Unique Code,",
        :template, => "Template,",
        :db_name, => "Db Name,",
        :db_type, => "Db Type,",
        :db_username, => "Db Username,",
        :db_password, => "Db Password,",
        :printer_name, => "Printer Name,",
        :api_settings, => "Api Settings,",
        :page_width => "",
        :page_height => "",
        :print_copies => 2
      ),
      PrintSetting.create!(
        :name, => "Name,",
        :unique_code, => "Unique Code,",
        :template, => "Template,",
        :db_name, => "Db Name,",
        :db_type, => "Db Type,",
        :db_username, => "Db Username,",
        :db_password, => "Db Password,",
        :printer_name, => "Printer Name,",
        :api_settings, => "Api Settings,",
        :page_width => "",
        :page_height => "",
        :print_copies => 2
      )
    ])
  end

  it "renders a list of print_settings" do
    render
    assert_select "tr>td", :text => "Name,".to_s, :count => 2
    assert_select "tr>td", :text => "Unique Code,".to_s, :count => 2
    assert_select "tr>td", :text => "Template,".to_s, :count => 2
    assert_select "tr>td", :text => "Db Name,".to_s, :count => 2
    assert_select "tr>td", :text => "Db Type,".to_s, :count => 2
    assert_select "tr>td", :text => "Db Username,".to_s, :count => 2
    assert_select "tr>td", :text => "Db Password,".to_s, :count => 2
    assert_select "tr>td", :text => "Printer Name,".to_s, :count => 2
    assert_select "tr>td", :text => "Api Settings,".to_s, :count => 2
    assert_select "tr>td", :text => "".to_s, :count => 2
    assert_select "tr>td", :text => "".to_s, :count => 2
    assert_select "tr>td", :text => 2.to_s, :count => 2
  end
end
