Forum: RSpec [rspec]spec_server: already initialized constant MyTestClass

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.
Cdf378de2284d8acf137122e541caa28?d=identicon&s=25 Matt Wynne (mattwynne)
on 2009-05-01 18:33
(Received via mailing list)
I'm creating a class in my spec file to test out a module, but when I
run the spec a second time in spec_server, I get the error above.

I presume this is because rails is un-loading the class, and it's not
getting re-loaded properly as it doesn't have its own file in the
conventional place.

Does anyone have a nice workaround for this?

cheers,
Matt Wynne
http://beta.songkick.com
http://blog.mattwynne.net
5d38ab152e1e3e219512a9859fcd93af?d=identicon&s=25 David Chelimsky (Guest)
on 2009-05-27 10:30
(Received via mailing list)
On Fri, May 1, 2009 at 12:26 PM, Matt Wynne <matt@mattwynne.net> wrote:
> I'm creating a class in my spec file to test out a module, but when I run
> the spec a second time in spec_server, I get the error above.
>
> I presume this is because rails is un-loading the class, and it's not
> getting re-loaded properly as it doesn't have its own file in the
> conventional place.
>
> Does anyone have a nice workaround for this?

Judging from the silence, I think the answer is no.

There is some interesting stuff going on in other threads about spork.
Don't know if it solves this for you, but you may want to give it a
whirl.
Cdf378de2284d8acf137122e541caa28?d=identicon&s=25 Matt Wynne (mattwynne)
on 2009-05-27 14:45
(Received via mailing list)
On 27 May 2009, at 09:26, David Chelimsky wrote:

>> Does anyone have a nice workaround for this?
>
> Judging from the silence, I think the answer is no.
>
> There is some interesting stuff going on in other threads about spork.
> Don't know if it solves this for you, but you may want to give it a
> whirl.

Actually you told me (some time ago) to upgrade to the latest version
of RSpec, as there is some bug-fix with spec_server. I still haven't
got around to doing that, but I'll feed back when I have.

Matt Wynne
http://blog.mattwynne.net
http://www.songkick.com
369b9fd2a0d9e7cdbc60907a2a056ad9?d=identicon&s=25 Scott Taylor (Guest)
on 2009-05-27 15:45
(Received via mailing list)
David Chelimsky wrote:
>>
>
>

Have you tried manually loading the file in the spec itself?

Scott
Cdf378de2284d8acf137122e541caa28?d=identicon&s=25 Matt Wynne (mattwynne)
on 2009-05-27 23:02
(Received via mailing list)
On 27 May 2009, at 14:36, Scott Taylor wrote:

>>> getting re-loaded properly as it doesn't have its own file in the
>>> conventional place.
>>>
>>> Does anyone have a nice workaround for this?
>>>
>>
>>
>
> Have you tried manually loading the file in the spec itself?
>
> Scott

erm.... I create the class *in the spec* itself so not sure how I'd do
that. I think I might be better off using an anonymous type instead.


>>> cheers,
>> rspec-users mailing list
>> rspec-users@rubyforge.org
>> http://rubyforge.org/mailman/listinfo/rspec-users
>>
>
> _______________________________________________
> rspec-users mailing list
> rspec-users@rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users

Matt Wynne
http://blog.mattwynne.net
http://www.songkick.com
369b9fd2a0d9e7cdbc60907a2a056ad9?d=identicon&s=25 Scott Taylor (Guest)
on 2009-05-27 23:24
(Received via mailing list)
On May 27, 2009, at 4:59 PM, Matt Wynne wrote:

>>>>
>> Have you tried manually loading the file in the spec itself?
>>
>> Scott
>
> erm.... I create the class *in the spec* itself so not sure how I'd
> do that. I think I might be better off using an anonymous type
> instead.

Is it some sort of class only used for testing behaviour inherited
from AR::Base?

Scott
Cdf378de2284d8acf137122e541caa28?d=identicon&s=25 Matt Wynne (mattwynne)
on 2009-05-27 23:36
(Received via mailing list)
On 27 May 2009, at 22:03, Scott Taylor wrote:

>>>>> I'm creating a class in my spec file to test out a module, but
>>>>
> Is it some sort of class only used for testing behaviour inherited
> from AR::Base?
>
> Scott

Doesn't inherit from AR::Base I don't think - why?

Matt Wynne
http://blog.mattwynne.net
http://www.songkick.com
This topic is locked and can not be replied to.