require 'rails_helper'

RSpec.describe "commands/index", type: :view do
  before(:each) do
    assign(:commands, [
      Command.create!(
        name: "Name",
        trigger: "Trigger",
        body: "MyText"
      ),
      Command.create!(
        name: "Name",
        trigger: "Trigger",
        body: "MyText"
      )
    ])
  end

  it "renders a list of commands" do
    render
    cell_selector = Rails::VERSION::STRING >= '7' ? 'div>p' : 'tr>td'
    assert_select cell_selector, text: Regexp.new("Name".to_s), count: 2
    assert_select cell_selector, text: Regexp.new("Trigger".to_s), count: 2
    assert_select cell_selector, text: Regexp.new("MyText".to_s), count: 2
  end
end
