Forum: RSpec Where are those tables listed for fixtures?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
D597b04d429d6b27a08ff37477b7de55?d=identicon&s=25 Rasmus Rasmussen (crumb)
on 2008-10-17 20:46
I'm sorry if this is posted in wrong forum. I am new to all of this with
rails and rspec.

Something got messed up when I changed a table's name from 'works' to
'work_periods'. Now the fixture:load thing does not work. Obviously the
old table is still in there in some file.

Anyone have any idea on where to find that file? Where does rspec read
all tables when it deletes table-entries?

>
>rake db:fixtures:load
>
>rake aborted!
>Mysql::Error: #42S02Table 'db_development.works' doesn't exist: DELETE FROM works
>
F86901feca747abbb5c6c020362ef2e7?d=identicon&s=25 Zach Dennis (zdennis)
on 2008-10-17 20:58
(Received via mailing list)
Do you still have "works.yml" in your fixtures/ directory? If so
you'll need to rename that to "work_periods.yml".

Zach

On Fri, Oct 17, 2008 at 2:46 PM, Rasmus Rasmussen <lists@ruby-forum.com>
wrote:
>>
> http://rubyforge.org/mailman/listinfo/rspec-users
>



--
Zach Dennis
http://www.continuousthinking.com
http://www.mutuallyhuman.com
D597b04d429d6b27a08ff37477b7de55?d=identicon&s=25 Rasmus Rasmussen (crumb)
on 2008-10-17 21:08
Zach Dennis wrote:
> Do you still have "works.yml" in your fixtures/ directory? If so
> you'll need to rename that to "work_periods.yml".
>
> Zach
>
> On Fri, Oct 17, 2008 at 2:46 PM, Rasmus Rasmussen <lists@ruby-forum.com>
> wrote:
>>>
>> http://rubyforge.org/mailman/listinfo/rspec-users
>>
>
>
>
> --
> Zach Dennis
> http://www.continuousthinking.com
> http://www.mutuallyhuman.com

Nope, but I really wished it was this simple. (it probably is!) I cannot
find any traces from "works" or "Work" anywhere in whole project.

I found the file in rspec that prints the msg:
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.6/lib/active_record/fixtures.rb.
Perhaps there is a clever way to redefine that class to get more
tracing?
49de4cd2f26705785cbef2b15a9df7aa?d=identicon&s=25 Nick Hoffman (Guest)
on 2008-10-17 21:18
(Received via mailing list)
On 2008-10-17, at 14:46, Rasmus Rasmussen wrote:
> all tables when it deletes table-entries?
>
>>
>> rake db:fixtures:load
>>
>> rake aborted!
>> Mysql::Error: #42S02Table 'db_development.works' doesn't exist:
>> DELETE FROM works
>>

Hi Rasmus. Have you grepped through your application for "works", and
looked for all files named "*works*"? Eg:

$ grep -rni 'works' /path/to/app/
$ find /path/to/app/ -iname '*works*'

Hope that helps,
Nick
D597b04d429d6b27a08ff37477b7de55?d=identicon&s=25 Rasmus Rasmussen (crumb)
on 2008-10-17 21:28
Rasmus Rasmussen wrote:
> Zach Dennis wrote:
>> Do you still have "works.yml" in your fixtures/ directory? If so
>> you'll need to rename that to "work_periods.yml".
>>
>>

Zach, you are right, there is another fixture under "test". I only
searched in "spec"-dir.

And I am in the wrong forum :-)

Guess the yaml's are placed under test because i ran generators with
"model" instead of "spec_model"

this feels like a duplication. If I write rspec-tests I should not do
ordinary tests, because then I need to maintain two fixtures. Right?
994e42bda994be2cd1d791f18ee6d561?d=identicon&s=25 Stephen Eley (Guest)
on 2008-10-17 21:43
(Received via mailing list)
On Fri, Oct 17, 2008 at 2:46 PM, Rasmus Rasmussen <lists@ruby-forum.com>
wrote:
>
> Something got messed up when I changed a table's name from 'works' to
> 'work_periods'. Now the fixture:load thing does not work. Obviously the
> old table is still in there in some file.

Dumb question, but did you clone or re-migrate your test database
after you made this change?

This trips me up all the time.  I'll do something clever with the
database, run db:migrate, and totally forget that that doesn't update
the test environment, just development.  Then my specs fail and I
freak out.


--
Have Fun,
   Steve Eley (sfeley@gmail.com)
   ESCAPE POD - The Science Fiction Podcast Magazine
   http://www.escapepod.org
F86901feca747abbb5c6c020362ef2e7?d=identicon&s=25 Zach Dennis (zdennis)
on 2008-10-17 21:51
(Received via mailing list)
On Fri, Oct 17, 2008 at 3:42 PM, Stephen Eley <sfeley@gmail.com> wrote:
> database, run db:migrate, and totally forget that that doesn't update
> the test environment, just development.  Then my specs fail and I
> freak out.

I use this command line alias after I write a migration:

   alias tmig='rake db:migrate && rake db:rollback && rake db:migrate
&& rake db:test:prepare'

It makes sure that I can migrate up and down for the migration I just
wrote, and it will make sure the test database is prepared.

Zach

> http://rubyforge.org/mailman/listinfo/rspec-users
>



--
Zach Dennis
http://www.continuousthinking.com
http://www.mutuallyhuman.com
48641c4be1fbe167929fb16c9fd94990?d=identicon&s=25 Mark Wilden (Guest)
on 2008-10-17 22:26
(Received via mailing list)
On Fri, Oct 17, 2008 at 12:51 PM, Zach Dennis <zach.dennis@gmail.com>
wrote:

>   alias tmig='rake db:migrate && rake db:rollback && rake db:migrate
> && rake db:test:prepare'
>

Sounds good. Nice to see someone paying attention to their downs as well
as
their ups.

rake db:migrate:redo will do the rollback + the re-migration in one
step,
saving some time.

///ar
994e42bda994be2cd1d791f18ee6d561?d=identicon&s=25 Stephen Eley (Guest)
on 2008-10-17 22:57
(Received via mailing list)
On Fri, Oct 17, 2008 at 3:28 PM, Rasmus Rasmussen <lists@ruby-forum.com>
wrote:
>
> this feels like a duplication. If I write rspec-tests I should not do
> ordinary tests, because then I need to maintain two fixtures. Right?

Correct.  You don't need it.  But the standard Rails generator doesn't
know that you're sneaking around on it with RSpec, so it keeps putting
boxes of chocolates in your /test directory hoping you'll pay more
attention to it and never knowing why you don't come home.  It's quite
touching, really.  Maybe even a little poignant.


--
Have Fun,
   Steve Eley (sfeley@gmail.com)
   ESCAPE POD - The Science Fiction Podcast Magazine
   http://www.escapepod.org
D597b04d429d6b27a08ff37477b7de55?d=identicon&s=25 Rasmus Rasmussen (crumb)
on 2008-10-18 20:40
Stephen Eley wrote:
> On Fri, Oct 17, 2008 at 3:28 PM, Rasmus Rasmussen <lists@ruby-forum.com>
> wrote:
>>
>> this feels like a duplication. If I write rspec-tests I should not do
>> ordinary tests, because then I need to maintain two fixtures. Right?
>
> Correct.  You don't need it.  But the standard Rails generator doesn't
> know that you're sneaking around on it with RSpec, so it keeps putting
> boxes of chocolates in your /test directory hoping you'll pay more
> attention to it and never knowing why you don't come home.  It's quite
> touching, really.  Maybe even a little poignant.
>
>
> --
> Have Fun,
>    Steve Eley (sfeley@gmail.com)
>    ESCAPE POD - The Science Fiction Podcast Magazine
>    http://www.escapepod.org

That is a very nice way of putting it. Guess I still got some pending
feelings for rails. Those scripts are evil! :-) Also, they are no good
when practicing TDD IMO. Again, only rookie impressions...
This topic is locked and can not be replied to.