require 'rails_helper'

RSpec.describe "items/index", type: :view do
  before(:each) do
    assign(:items, [
      Item.create!(
        :name => "Name",
        :description => "MyText",
        :car_model_id => 1,
        :length => "Length",
        :height => "Height",
        :width => "Width",
        :weight => "Weight",
        :color => "Color",
        :volume => "Volume"
      ),
      Item.create!(
        :name => "Name",
        :description => "MyText",
        :car_model_id => 1,
        :length => "Length",
        :height => "Height",
        :width => "Width",
        :weight => "Weight",
        :color => "Color",
        :volume => "Volume"
      )
    ])
  end

  it "renders a list of items" do
    render
    assert_select "tr>td", :text => "Name".to_s, :count => 2
    assert_select "tr>td", :text => "MyText".to_s, :count => 2
    assert_select "tr>td", :text => 1.to_s, :count => 2
    assert_select "tr>td", :text => "Length".to_s, :count => 2
    assert_select "tr>td", :text => "Height".to_s, :count => 2
    assert_select "tr>td", :text => "Width".to_s, :count => 2
    assert_select "tr>td", :text => "Weight".to_s, :count => 2
    assert_select "tr>td", :text => "Color".to_s, :count => 2
    assert_select "tr>td", :text => "Volume".to_s, :count => 2
  end
end
