You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
sqm-dashboards/spec/views/questions/index.html.erb_spec.rb

39 lines
1.2 KiB

require 'rails_helper'
RSpec.describe "questions/index", type: :view do
before(:each) do
assign(:questions, [
Question.create!(
:text => "Text",
:option1 => "Option1",
:option2 => "Option2",
:option3 => "Option3",
:option4 => "Option4",
:option5 => "Option5",
:category => Category.create(name: "Category 1")
),
Question.create!(
:text => "Text",
:option1 => "Option1",
:option2 => "Option2",
:option3 => "Option3",
:option4 => "Option4",
:option5 => "Option5",
:category => Category.create(name: "Category 2")
)
])
end
it "renders a list of questions" do
render(template: "questions/index.html.haml")
assert_select "tr>td", :text => "Text".to_s, :count => 2
assert_select "tr>td", :text => "Option1".to_s, :count => 2
assert_select "tr>td", :text => "Option2".to_s, :count => 2
assert_select "tr>td", :text => "Option3".to_s, :count => 2
assert_select "tr>td", :text => "Option4".to_s, :count => 2
assert_select "tr>td", :text => "Option5".to_s, :count => 2
assert_select "tr>td", :text => "Category 1", :count => 1
assert_select "tr>td", :text => "Category 2", :count => 1
end
end