I am running Rails 3.2.11 and believe I have minitest spec and capybara installed and working correctly through my gem file and test_helper.rb
I have the following integration test:
describe "Products integration" do
fixtures :users, :businesses
it "shows product's name" do
visit root_path
fill_in "email", :with => users(:fu).email
fill_in "password", :with => "secret"
click_button "Log In"
assert_equal products_path, current_path
end
end
With the browser, once the user is logged in they are redirected to the products_path which displays all of their products.
My sample user fixture does not have any products setup. Therefore in my index.html.erb the line <% if @products.present? %>
should be false and no row data should be attempted to be shown. This is not the case and my test fails with Error: undefined method type_name for nil:NilClass
, as it appears to attempt to write the table data <td><%= product.product_type.type_name %></td>
The action that leads to index.html.erb only contains @products = Product.includes(:product_type)
Why is the test returning true for products.present? and hence fail?