Home Rails testing framework gives errors unrelated to test
Reply: 0

Rails testing framework gives errors unrelated to test

Joe Scherping
1#
Joe Scherping Published in 2018-01-12 15:04:05Z

The rails testing framework keeps giving me errors unrelated to my test files or my test_helper file, and I'm not sure why. It seems like it's running code from other parts of the project, and I'm trying to find out how it gets there.

$ rake test
Run options: --seed 42237

# Running:

EEE

Finished in 0.692285s, 4.3335 runs/s, 0.0000 assertions/s.


...


  3) Error:
UserTest#test_the_truth:
ActiveRecord::StatementInvalid: Mysql2::Error: Field 'created_at' doesn't have a default value: INSERT INTO `balancesheets` (`Company_ID`, `Balancesheet_date`) VALUES (1, '2015-05-12')

I tried to write tests for my User model, but even if change the test to just "assert true", it still gets the strange output. Here is my test/models/user_test.rb

require 'test_helper'

class UserTest < ActiveSupport::TestCase
  test "the truth" do
    assert true
  end
end

And here is my test/test_helper.rb

ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'

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

  # Add more helper methods to be used by all tests here...
end

I'm new to rails, and so both files are still basically their defaults when you start a new project. Why do I see test output relating to a mysql INSERT? If you could point me in the right direction, that would be great. Also, let me know if I need to add more context. Thanks!

EDIT: Here is the file in db/migrate/ where I create balancesheets

class CreateBalancesheets < ActiveRecord::Migration
  def change
    create_table :balancesheets do |t|
      t.integer :Company_ID
      t.date :Balancesheet_date

      t.timestamps null: false
    end
  end
end
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.305049 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO