mardi 27 octobre 2015

Rails 4 Integration Testing - Failing (event Assert True)

Alright, a little embarrassed I asked a very similar question yesterday, but we're stuck again.

We've fixed all of our controller tests, and started writing integration tests. We're encountering errors on all of our integration tests, even the famous assert = true:

site_layout_test.rb

require 'test_helper'

class SiteLayoutTest < ActionDispatch::IntegrationTest


  test "the truth" do
    assert true
  end

#commenting out our real tests for debugging

=begin
  test "top navigation bar links" do
    get 'beta/index'
    assert_template 'beta/index'
    assert_select "a[href=?]", home_path
    assert_select "a[href=?]", how_it_works_path
    to do add map, community, sign up, login paths
    to do: add paths to links on dropdown if user is logged in
  end
=end

end

Terminal Test Results

12:31:32 - INFO - Running: test/integration/site_layout_test.rb
Started with run options --seed 27747

ERROR["test_the_truth", SiteLayoutTest, 2015-10-25 11:36:28 +0800]
 test_the_truth#SiteLayoutTest (1445744188.33s)
NoMethodError:         NoMethodError: undefined method `env' for nil:NilClass


  1/1: [===================================] 100% Time: 00:00:00, Time: 00:00:00

Finished in 0.05380s
1 tests, 0 assertions, 0 failures, 1 errors, 0 skips

test_helper.rb

ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
require "minitest/reporters"
Minitest::Reporters.use!

class ActiveSupport::TestCase
  # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
  fixtures :all

  include Devise::TestHelpers
  # Add more helper methods to be used by all tests here...
  #

  def setup_variables
    @base_title = "TripHappy"
  end
end

Unfortunately, that error message gives us very little clue as to where the error is occurring. I tried reading up on Minitests, but without an idea of where to look I'm fairly lost.

Thank you in advanced!

For reference, we're following M. Harti's Rails Tutorial, which means we're using Guard and Minitest Reporters. We also have a login system via Devise, if that affects anything.

Aucun commentaire:

Enregistrer un commentaire