Discussion:
[Rails-core] [Feature Request] Force test schema to be up to date when running tests
Ryan Jones
2016-06-28 18:26:43 UTC
Permalink
Every so often I'll run a test suite and it will have a large number of
failures. After debugging it's normally something as simple as the test
schema being out of date. I then run bin/rake db:test:prepare and
everything is fine.

If I run my development environment and my schema is out of date, it throws
an error and forces me to run bin/rake db:migrate. Should we be doing the
same thing when we're running tests? Or at the very least maybe throwing a
warning that the test schema is 'out of date'?

On one of the first apps I was building (a few years ago) I remember
spending a few hours tracking down why my test was failing. I was new to
'TDD' and I thought it was something I was doing wrong. I called a friend
and he asked 'did you run db:test:prepare?' and that solved my problem. I
don't run into this issue as much anymore, but I think it might prevent
some frustration by new rails users.

I'm trying to think of why we wouldn't be doing this and my mind is coming
up blank. Let me know your thoughts!

Thanks,
Ryan
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+***@googlegroups.com.
To post to this group, send email to rubyonrails-***@googlegroups.com.
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.
Chad Woolley
2016-06-28 20:32:01 UTC
Permalink
+1, this is one of a few things that doesn't "work out of the box" for
databases in real-world usage. I always end up having some version of a
custom "db:prepare" which does extra necessary things for my apps.

FYI, this thread is somewhat related, in that it's also about confusion
about the behavior of the 'test' environment (and also unaddressed):
https://groups.google.com/forum/#!searchin/rubyonrails-core/environment$20agnostic/rubyonrails-core/kqKoJHcQu9U/xx9J2BLOBgAJ

-- Chad
Post by Ryan Jones
Every so often I'll run a test suite and it will have a large number of
failures. After debugging it's normally something as simple as the test
schema being out of date. I then run bin/rake db:test:prepare and
everything is fine.
If I run my development environment and my schema is out of date, it
throws an error and forces me to run bin/rake db:migrate. Should we be
doing the same thing when we're running tests? Or at the very least maybe
throwing a warning that the test schema is 'out of date'?
On one of the first apps I was building (a few years ago) I remember
spending a few hours tracking down why my test was failing. I was new to
'TDD' and I thought it was something I was doing wrong. I called a friend
and he asked 'did you run db:test:prepare?' and that solved my problem. I
don't run into this issue as much anymore, but I think it might prevent
some frustration by new rails users.
I'm trying to think of why we wouldn't be doing this and my mind is coming
up blank. Let me know your thoughts!
Thanks,
Ryan
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+***@googlegroups.com.
To post to this group, send email to rubyonrails-***@googlegroups.com.
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.
Rafael Mendonça França
2016-06-28 20:52:35 UTC
Permalink
Automatic test schema maintainance is a feature of Rails since 4.1
http://guides.rubyonrails.org/4_1_release_notes.html#railties-notable-changes
Post by Chad Woolley
+1, this is one of a few things that doesn't "work out of the box" for
databases in real-world usage. I always end up having some version of a
custom "db:prepare" which does extra necessary things for my apps.
FYI, this thread is somewhat related, in that it's also about confusion
https://groups.google.com/forum/#!searchin/rubyonrails-core/environment$20agnostic/rubyonrails-core/kqKoJHcQu9U/xx9J2BLOBgAJ
-- Chad
Post by Ryan Jones
Every so often I'll run a test suite and it will have a large number of
failures. After debugging it's normally something as simple as the test
schema being out of date. I then run bin/rake db:test:prepare and
everything is fine.
If I run my development environment and my schema is out of date, it
throws an error and forces me to run bin/rake db:migrate. Should we be
doing the same thing when we're running tests? Or at the very least maybe
throwing a warning that the test schema is 'out of date'?
On one of the first apps I was building (a few years ago) I remember
spending a few hours tracking down why my test was failing. I was new to
'TDD' and I thought it was something I was doing wrong. I called a friend
and he asked 'did you run db:test:prepare?' and that solved my problem. I
don't run into this issue as much anymore, but I think it might prevent
some frustration by new rails users.
I'm trying to think of why we wouldn't be doing this and my mind is
coming up blank. Let me know your thoughts!
Thanks,
Ryan
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+***@googlegroups.com.
To post to this group, send email to rubyonrails-***@googlegroups.com.
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.
Chad Woolley
2016-06-29 18:52:04 UTC
Permalink
Ah. My problems may be that I don't generate that test helper by default,
and thus the call never makes it into my rspec setup.

Is this your issue Ryan? If so maybe you can confirm that the rspec
generator properly adds this support, and if not, add it.

-- Chad

El martes, 28 de junio de 2016, Rafael Mendonça França <
Post by Rafael Mendonça França
Automatic test schema maintainance is a feature of Rails since 4.1
http://guides.rubyonrails.org/4_1_release_notes.html#railties-notable-changes
Post by Chad Woolley
+1, this is one of a few things that doesn't "work out of the box" for
databases in real-world usage. I always end up having some version of a
custom "db:prepare" which does extra necessary things for my apps.
FYI, this thread is somewhat related, in that it's also about confusion
https://groups.google.com/forum/#!searchin/rubyonrails-core/environment$20agnostic/rubyonrails-core/kqKoJHcQu9U/xx9J2BLOBgAJ
-- Chad
On Tue, Jun 28, 2016 at 11:26 AM, Ryan Jones <
Post by Ryan Jones
Every so often I'll run a test suite and it will have a large number of
failures. After debugging it's normally something as simple as the test
schema being out of date. I then run bin/rake db:test:prepare and
everything is fine.
If I run my development environment and my schema is out of date, it
throws an error and forces me to run bin/rake db:migrate. Should we be
doing the same thing when we're running tests? Or at the very least maybe
throwing a warning that the test schema is 'out of date'?
On one of the first apps I was building (a few years ago) I remember
spending a few hours tracking down why my test was failing. I was new to
'TDD' and I thought it was something I was doing wrong. I called a friend
and he asked 'did you run db:test:prepare?' and that solved my problem. I
don't run into this issue as much anymore, but I think it might prevent
some frustration by new rails users.
I'm trying to think of why we wouldn't be doing this and my mind is
coming up blank. Let me know your thoughts!
Thanks,
Ryan
--
You received this message because you are subscribed to the Google
Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send
.
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an
.
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an
.
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+***@googlegroups.com.
To post to this group, send email to rubyonrails-***@googlegroups.com.
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.
Loading...