Rails integration test

5 views
Skip to first unread message

Alex Chaffee

unread,
Oct 20, 2010, 10:00:42 PM10/20/10
to wron...@googlegroups.com
Brad reported a bug in Rails vs. RSpec vs. Wrong. I fixed it last week but it took me this long to write a failing test. I'll push out a bugfix release in a minute but first I have a developer question.

In order to properly test Rails integration, I need to run a spec using Wrong inside a Rails app. This gives me two options:

A) generate a rails app and check it in to the Wrong github repo

B) write a script that generates a rails app and check the script in to the Wrong repo

(A) seems like the most stable choice but it would lead to all sorts of nonsense like extra Gemfiles and Rakefiles showing up in file autocomplete, so I'm leaning towards (B). But that makes the build more brittle cause if the script doesn't properly generate a rails app on your system it may stop the build or mess up your whole filesystem.

Any advice or preferences from the peanut gallery?

(BTW I already wrote the script in bash.)

Alex Chaffee

unread,
Oct 20, 2010, 10:01:47 PM10/20/10
to wron...@googlegroups.com
Oh yeah, also (B) makes it potentially more robust with future versions of Rails and future tests we may need to write.

Phlip

unread,
Oct 20, 2010, 11:00:55 PM10/20/10
to wron...@googlegroups.com
> In order to properly test Rails integration, I need to run a spec using
> Wrong inside a Rails app. This gives me two options:
> A) generate a rails app and check it in to the Wrong github repo
> B) write a script that generates a rails app and check the script in to the
> Wrong repo

The unit test should just fail if the actual change you need is not
there, and pass if it is there. No need to pull in Rails, right?

--
  Phlip
  http://c2.com/cgi/wiki?ZeekLand

Alex Chaffee

unread,
Oct 20, 2010, 11:15:04 PM10/20/10
to wron...@googlegroups.com
Sorry, but that would be a unit test, not an integration test. There's no guarantee that the trick I used will keep working in future versions of Rails. (In fact, I think it actually breaks something else -- assert_select etc. may have stopped working according to Brad.)

thierry henrio

unread,
Oct 21, 2010, 5:25:56 AM10/21/10
to wron...@googlegroups.com
On Thu, Oct 21, 2010 at 4:00 AM, Alex Chaffee <al...@stinky.com> wrote:
Brad reported a bug in Rails vs. RSpec vs. Wrong. I fixed it last week but it took me this long to write a failing test. 

Where is this bug ?
I did not notice it on pivotal tracker nor github one  ...

I also find out that rspec-rails-2 was not the same beast as mere rspec2 for wrong
I found something that was working for me, but ran away when facing the writing a failing wrong test ...

The requirements I had were
- rails spec in [controllers, helpers, models, routing, views] can use wrong assert {}
- mere spec in [lib] can use wrong assert {}

And I did not stop to write a failing test, had a spike, and continue with what I was doing, then forgot
So bad !
Cheers, Thierry

John Firebaugh

unread,
Oct 21, 2010, 11:57:57 AM10/21/10
to wron...@googlegroups.com
Have you seen what cucumber-rails does for rails integration testing
using cucumber and aruba?

http://github.com/aslakhellesoy/cucumber-rails/blob/master/features/rails2.feature
http://github.com/aslakhellesoy/cucumber-rails/blob/master/features/rails3.feature

Far more readable than most bash scripts. :)

Alex Chaffee

unread,
Oct 21, 2010, 1:09:42 PM10/21/10
to wron...@googlegroups.com
On Thu, Oct 21, 2010 at 2:25 AM, thierry henrio <thierry...@gmail.com> wrote:
On Thu, Oct 21, 2010 at 4:00 AM, Alex Chaffee <al...@stinky.com> wrote:
Brad reported a bug in Rails vs. RSpec vs. Wrong. I fixed it last week but it took me this long to write a failing test. 

Where is this bug ?
I did not notice it on pivotal tracker nor github one  ...

He emailed me and I emailed him back. I'm not in the habit of using the tracker(s). 
 

I also find out that rspec-rails-2 was not the same beast as mere rspec2 for wrong
I found something that was working for me, but ran away when facing the writing a failing wrong test ...

The requirements I had were
- rails spec in [controllers, helpers, models, routing, views] can use wrong assert {}
- mere spec in [lib] can use wrong assert {}

Yeah, that's an unseen complication of Wrong's agenda: everyone thinks they own "assert". Including us :-)

Please see if version 0.4.3 fixes it.
 
And I did not stop to write a failing test, had a spike, and continue with what I was doing, then forgot
So bad !

I know the feeling. It took a lot of self-control to force myself to write this test.

Alex Chaffee

unread,
Oct 21, 2010, 1:11:47 PM10/21/10
to wron...@googlegroups.com
I'd say it's a bit more readable, yes, but still very codey, and I could make the bash script nearly as expressive with comments and well-named bash functions.

Which I will now go do, because it beats working. :-)

thierry henrio

unread,
Oct 21, 2010, 5:14:30 PM10/21/10
to wron...@googlegroups.com
Hello

On Thu, Oct 21, 2010 at 7:09 PM, Alex Chaffee <al...@stinky.com> wrote:
I did not notice it on pivotal tracker nor github one  ...

He emailed me and I emailed him back. I'm not in the habit of using the tracker(s). 
Good
 

Please see if version 0.4.3 fixes it.

It does
my previous spec/support/wrong.rb was

require 'wrong'
require 'rspec/rails/adapters'
RSpec::Rails::TestUnitAssertionAdapter::AssertionDelegate.send(:include, Wrong)
require 'wrong/adapters/rspec'

with 0.4.3 it is
require 'wrong/adapters/rspec'

Cheers, Thierry
Reply all
Reply to author
Forward
0 new messages