Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Database content not on web page when running with @javascript
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  Messages 1 - 25 of 31 - Collapse all  -  Translate all to Translated (View all originals)   Newer >
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Larry  
View profile  
 More options Mar 31 2011, 4:51 pm
From: Larry <i...@stupidtuesday.com>
Date: Thu, 31 Mar 2011 13:51:30 -0700 (PDT)
Local: Thurs, Mar 31 2011 4:51 pm
Subject: Database content not on web page when running with @javascript
Hi,

I just started using Capybara with JavaScript, so hopefully I'm just
making some newbie kind of mistake. (Before I forget: Thanks for great
gem!)

Don't know if this makes a difference, but... Ubuntu 10.10, Ruby
1.9.2, Rails 3.0.5, FireFox 4.0, Cucumber 0.10.2, Capybara 0.4.1.2,
Selenium-Webdriver 0.1.4.
 * I just Bundle>Updated most of the gems today, so they should be the
latest and greatest versions.

At the beginning of the test I populate a database with some items. I
display a handful of them - along with a listbox - on the initial "GET
index" action.  When I change the selection in the listbox I use
JavaScript (jQuery) to populate the page with a different set of
items. Typical vanilla operations.

It all works fine in development mode, and when I run my Cucumber
tests without the @javascript tag everything works fine until I get to
the test for the "new items corresponding to the new listbox
selection" - which makes sense because there are no new items because
the test is not yet using Selenium/JavaScript.

Before I change the listbox selection I test for the presence of the
initial items and that test passes. Also, I do a 'save_and_open_page'
and I can see that the initial list of items is indeed on the web
page, just waiting to be changed according to the new listbox
selection.

This leads me to believe that all of the plumbing is hooked up
correctly.

Now, when I put the @javascript tag before my "Scenario:" statement,
Capybara dutifully fires up the browser, but there are no initial
items on the web page. The listbox is there and it contains the right
choices, but my first "are the initial items on the page" test (that
used to pass) now fails because there's nothing there.

I increased the 'Capybara.default_wait_time' but that didn't make a
difference. Which I guess it shouldn't because I think that's just for
dynamic JavaScript interactions, and this problem is with the initial
page load not containing the initial database elements.

Can someone please help me? I have spent soooo much time on this...

Thanks,
Larry


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jonas Nicklas  
View profile  
 More options Mar 31 2011, 7:28 pm
From: Jonas Nicklas <jonas.nick...@gmail.com>
Date: Fri, 1 Apr 2011 01:28:17 +0200
Local: Thurs, Mar 31 2011 7:28 pm
Subject: Re: [Capybara] Database content not on web page when running with @javascript
Make sure to add the database_cleaner gem to your gemfile.

/Jonas


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Larry  
View profile  
 More options Mar 31 2011, 10:33 pm
From: Larry <i...@stupidtuesday.com>
Date: Thu, 31 Mar 2011 19:33:19 -0700 (PDT)
Local: Thurs, Mar 31 2011 10:33 pm
Subject: Re: Database content not on web page when running with @javascript
Hi Jonas,

Thanks for the reply. I already did that. It's only in my "test"
section (along with capybara and launchy), but that should be the only
place it's needed, right?

It's weird. Basically, I have 5 items in the database and 2 in the
listbox. When the page first loads I should see 3 elements and the
listbox - which I do in development mode and when running cuke tests
without the @javascript tag. (Like I said, I see the 3 elements on the
page when I do a "save_and_open_page", so I know the creation part is
okay.)

But when I run the test with @javascript the browser pops up showing
the listbox... but not the 3 elements. Then it just sits there looking
for the initial 3 elements until it times out, at which point the
browser disappears and the test officially fails.

Any other ideas? (I hope ;-)

Thanks,
Larry

On Mar 31, 7:28 pm, Jonas Nicklas <jonas.nick...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Matt Wynne  
View profile  
 More options Apr 1 2011, 5:04 am
From: Matt Wynne <m...@mattwynne.net>
Date: Fri, 1 Apr 2011 10:04:49 +0100
Local: Fri, Apr 1 2011 5:04 am
Subject: Re: [Capybara] Re: Database content not on web page when running with @javascript
This might be a bug in the latest version of cucumber-rails which bit me recently.

See https://github.com/aslakhellesoy/cucumber-rails/issues#issue/113

On 1 Apr 2011, at 03:33, Larry wrote:

cheers,
Matt

m...@mattwynne.net
07974 430184


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Larry  
View profile  
 More options Apr 1 2011, 8:14 am
From: Larry <i...@stupidtuesday.com>
Date: Fri, 1 Apr 2011 05:14:53 -0700 (PDT)
Local: Fri, Apr 1 2011 8:14 am
Subject: Re: Database content not on web page when running with @javascript
Hey Matt,

Thanks for the heads-up on this issue. I can really relate to the
misery expressed in some of those comments ;-). When I woke up
yesterday morning I thought I'd have the cucumber tests I wanted to
write done in a couple of hours and then I'd be able to move on to
something else. Late last night I was still working on this issue...
sigh. The only thing that makes me feel good about this is that I know
we all go through these things on a fairly regular basis. (And that
there might be a fix forthcoming :-)

Guess I'll monitor that issue and wait for a fix.

In the meantime, thanks to you and Jonas for your help, and to the
Capybara team for providing this great gem!

-- Larry

P.S. Okay, instead of waiting I decided to do what they suggested:
take the provided code patch and stick it in my env.rb file. That
didn't solve the problem. Did you try the fix, and if so, did it work
for you?

On Apr 1, 5:04 am, Matt Wynne <m...@mattwynne.net> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Matt Wynne  
View profile  
 More options Apr 1 2011, 9:03 am
From: Matt Wynne <m...@mattwynne.net>
Date: Fri, 1 Apr 2011 14:03:18 +0100
Local: Fri, Apr 1 2011 9:03 am
Subject: Re: [Capybara] Re: Database content not on web page when running with @javascript

On 1 Apr 2011, at 13:14, Larry wrote:

> P.S. Okay, instead of waiting I decided to do what they suggested:
> take the provided code patch and stick it in my env.rb file. That
> didn't solve the problem. Did you try the fix, and if so, did it work
> for you?

As I said in the comment, I can't vouch for the monkey patch. Try @markus' fork of cucumber-rails instead, that's working for me.

cheers,
Matt

m...@mattwynne.net
07974 430184


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Larry  
View profile  
 More options Apr 1 2011, 3:49 pm
From: Larry <i...@stupidtuesday.com>
Date: Fri, 1 Apr 2011 12:49:22 -0700 (PDT)
Local: Fri, Apr 1 2011 3:49 pm
Subject: Re: Database content not on web page when running with @javascript
Hi,

Matt's suggestions (Thanks, Matt!) didn't solve the problem. If
interested, you can find out more information here:
https://github.com/aslakhellesoy/cucumber-rails/issues#issue/113

My problem still remains, and I hope someone can shed some light on it
because I'm dead in the water.

I have a simple setup and gem configuration, i.e. nothing too complex
or crazy. I have several records that I'd like to display in an
"index" action. Again, simple stuff. When I run my Cucumber test
without @javascript/selenium it works fine. In fact, when I do a
"save_and_open_page" I can see the records on the page.

However, when I add the @javascript tag, selenium fires up the
browser, but the page is empty. And there's no way I can do any
javascript/selenium testing without any database content.

Print statements verify the records are being successfully created,
but nothing is retrieved from the database. I found a recent RailsCast
where Ryan talked about a similar issue, but with RSpec instead of
Cucumber. Here is what the corresponding AsciiCast said (http://
asciicasts.com/episodes/257-request-specs-and-capybara):

=======================================================================
This time the first spec fails as the content “paint fence” is missing
from the page. The database record that is created isn’t available to
the Selenium tests and this is because our specs are using database
transactions which aren’t compatible with Selenium. To fix this we can
set the config.use_transactional_fixtures setting in the spec_helper
file to false.

This will get the tests passing again but it will mean that the
database records are carried over between specs which we don’t want.
To solve this problem we can use a gem called database_cleaner to
clean the database between specs.
=======================================================================

That seems to be what's happening to me, except I'm using Cucumber
instead of RSpec. Any help anyone can provide on this subject will be
greatly appreciated.

Thanks,
Larry

On Apr 1, 9:03 am, Matt Wynne <m...@mattwynne.net> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jonas Nicklas  
View profile  
 More options Apr 1 2011, 4:34 pm
From: Jonas Nicklas <jonas.nick...@gmail.com>
Date: Fri, 1 Apr 2011 22:34:01 +0200
Local: Fri, Apr 1 2011 4:34 pm
Subject: Re: [Capybara] Re: Database content not on web page when running with @javascript
You need to debug this somehow. I'd suggest removing the cucumber
Database cleaner stuff entirely (iirc you need to remove the line that
requires somthing like cucumber/active_record) and get your own setup
going. The cucumber way, is very convoluted and error prone, imo.

Personally I just drop this in my projects http://pastie.org/1745020.
It's a hack suggested originally by Jose Valim which forces
ActiveRecord to always use the same connection, which will make
transactions work with Capybara. Not only is it significantly faster,
you also never have to deal with junk in the database, and you don't
need DatabaseCleaner at all. It's a win-win, imho. Give it a shot!

/Jonas


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Matt Wynne  
View profile  
 More options Apr 1 2011, 4:47 pm
From: Matt Wynne <m...@mattwynne.net>
Date: Fri, 1 Apr 2011 21:47:20 +0100
Local: Fri, Apr 1 2011 4:47 pm
Subject: Re: [Capybara] Re: Database content not on web page when running with @javascript
Also, for debugging, watch your logs/test.log file very closely during a simple test-case and see if you can decipher anything from that.

On 1 Apr 2011, at 21:34, Jonas Nicklas wrote:

cheers,
Matt

m...@mattwynne.net
07974 430184


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Larry  
View profile  
 More options Apr 4 2011, 10:16 am
From: Larry <i...@stupidtuesday.com>
Date: Mon, 4 Apr 2011 07:16:21 -0700 (PDT)
Local: Mon, Apr 4 2011 10:16 am
Subject: Re: Database content not on web page when running with @javascript
YES!!!

First things first: Matt and Jonas - thanks a LOT for helping me (and
hopefully others) with this issue. I know you must be busy and it
would've been easier for you to simply wash your hands of this and
wish me good luck. But you didn't, and I really appreciate that. (Yet
another thing I love about the Ruby and Rails community!)

I'll detail what I did for those of you playing along at home (and
then ask a final question at the end, just to keep you guys on your
toes ;-)

1) I removed the 'gem database_cleaner' statement from my Gemfile, and
the gem itself from its RVM-managed directory.
2) I couldn't find a 'require cucumber/active_record' statement, but I
did find and comment out the following line:
<gem-directory>/cucumber-rails-0.4.0/lib/cucumber/rails/hooks.rb :
'require 'cucumber/rails/hooks/database_cleaner'
3) I created /features/support/local_env.rb and inserted the code
Jonas pointed me to at http://pastie.org/1745020

What the heck, it's short, so here it is in case that link ever gets
hosed or removed:

==========================================
class ActiveRecord::Base
  mattr_accessor :shared_connection
  @@shared_connection = nil

  def self.connection
    @@shared_connection || retrieve_connection
  end
end

# Forces all threads to share the same connection. This works on
# Capybara because it starts the web server in a thread.
ActiveRecord::Base.shared_connection = ActiveRecord::Base.connection
==========================================

And it worked like a charm! Again, thanks a lot, and here's your
rewards-bonus question! ;-)

This fixed my Cucumber/Capybara/Selenium problem, but could it ever
cause problems in development or (more importantly) production mode?
Do you think it would be a good idea to slap an "if Rails.env.test?"
statement around the fix?

Thanks again,
Larry

On Apr 1, 4:47 pm, Matt Wynne <m...@mattwynne.net> wrote:

...

read more »


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jonas Nicklas  
View profile  
 More options Apr 4 2011, 10:24 am
From: Jonas Nicklas <jonas.nick...@gmail.com>
Date: Mon, 4 Apr 2011 16:24:22 +0200
Local: Mon, Apr 4 2011 10:24 am
Subject: Re: [Capybara] Re: Database content not on web page when running with @javascript
Yes, you should definitely not be loading that code in production. In
most cases it won't make a difference, but if you ever move to a
threaded environment, you'll be in a world of pain with a tricky to
debug issue. Save yourself the trouble and only load it in the test
env (I usually put it in features/support/shared_connection.rb or
something)

/Jonas

...

read more »


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Larry  
View profile  
 More options Apr 4 2011, 10:29 am
From: Larry <i...@stupidtuesday.com>
Date: Mon, 4 Apr 2011 07:29:45 -0700 (PDT)
Local: Mon, Apr 4 2011 10:29 am
Subject: Re: Database content not on web page when running with @javascript
Got it. Thanks!

On Apr 4, 10:24 am, Jonas Nicklas <jonas.nick...@gmail.com> wrote:

...

read more »


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Larry  
View profile  
 More options Apr 4 2011, 10:58 am
From: Larry <i...@stupidtuesday.com>
Date: Mon, 4 Apr 2011 07:58:32 -0700 (PDT)
Local: Mon, Apr 4 2011 10:58 am
Subject: Re: Database content not on web page when running with @javascript
Oops. Seems like you still need database_cleaner, so ignore steps #1
and #2.

-- Larry

On Apr 4, 10:16 am, Larry <i...@stupidtuesday.com> wrote:

...

read more »


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Larry  
View profile  
 More options Apr 4 2011, 11:05 am
From: Larry <i...@stupidtuesday.com>
Date: Mon, 4 Apr 2011 08:05:05 -0700 (PDT)
Local: Mon, Apr 4 2011 11:05 am
Subject: Re: Database content not on web page when running with @javascript
Hi Jonas,

I ran some more tests and noticed that my database wasn't getting
cleaned out between runs. I was under the impression that transactions
were being used, which meant your fix allowed access to the data
because it used the same connection.

But, like I said, data remained in the database. When I hooked all of
the database-cleaner plumbing back up everything worked.

Does this make sense to you?

Sorry to keep this issue alive. If it makes sense and a quick
explanation suffices, fine. If not, I'm perfectly willing to just
accept the fact that it works and move on - something I think we all
do in this DSL and automagical world of Ruby and Rails.

-- Larry

On Apr 4, 10:24 am, Jonas Nicklas <jonas.nick...@gmail.com> wrote:

...

read more »


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jo Liss  
View profile  
 More options Apr 4 2011, 11:07 am
From: Jo Liss <jolis...@gmail.com>
Date: Mon, 4 Apr 2011 17:07:34 +0200
Local: Mon, Apr 4 2011 11:07 am
Subject: Re: [Capybara] Re: Database content not on web page when running with @javascript

On Mon, Apr 4, 2011 at 4:16 PM, Larry <i...@stupidtuesday.com> wrote:
> 3) I created /features/support/local_env.rb and inserted the code
> Jonas pointed me to at http://pastie.org/1745020

If I understand the purpose of that code correctly, you could also use
database_cleaner's truncation mode, right?  (Though it might be a
little slower, depending on the size of your test DB.)

> This fixed my Cucumber/Capybara/Selenium problem, but could it ever
> cause problems in development or (more importantly) production mode?
> Do you think it would be a good idea to slap an "if Rails.env.test?"
> statement around the fix?

As Jonas said, you shouldn't be doing this in production, but since
it's under features/support, it's only ever loaded by Cucumber, so
there's no need to check Rails.env.test?.

Jo

--
Jo Liss
http://opinionated-programmer.com/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Larry  
View profile  
 More options Apr 4 2011, 11:25 am
From: Larry <i...@stupidtuesday.com>
Date: Mon, 4 Apr 2011 08:25:16 -0700 (PDT)
Local: Mon, Apr 4 2011 11:25 am
Subject: Re: Database content not on web page when running with @javascript
Hi Jo,

Thanks for chiming in. I wanted to test your theory and you are right:
When I removed the fix Jonas supplied and changed the
"DatabaseCleaner.strategy" from ":transaction" to ":truncation" in
"features/support/env.rb" everything worked.

I still don't fully understand all of this stuff, but I now have 2
solutions which will hopefully be helpful to others.

Thanks!

-- Larry

On Apr 4, 11:07 am, Jo Liss <jolis...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jo Liss  
View profile  
 More options Apr 4 2011, 11:38 am
From: Jo Liss <jolis...@gmail.com>
Date: Mon, 4 Apr 2011 17:38:44 +0200
Local: Mon, Apr 4 2011 11:38 am
Subject: Re: [Capybara] Re: Database content not on web page when running with @javascript

On Fri, Apr 1, 2011 at 10:34 PM, Jonas Nicklas <jonas.nick...@gmail.com> wrote:
> Personally I just drop this in my projects http://pastie.org/1745020.
> It's a hack suggested originally by Jose Valim which forces
> ActiveRecord to always use the same connection, which will make
> transactions work with Capybara. Not only is it significantly faster,
> you also never have to deal with junk in the database, and you don't
> need DatabaseCleaner at all.

Other than that hack, I'd be curious, do you think that Jen-Mei's
assessment at http://opinionated-programmer.com/2011/02/capybara-and-selenium-with-...
is correct, in that

- you can use transactions use Rack::Test, but
- you cannot use them with any "external" tester (like Selenium or
HtmlUnit), so you have to use DatabaseCleaner with the truncation
method?

(I'm using DatabaseCleaner with :truncation as well to stop my
Selenium tests from breaking, but I'm not sure if that problem is
universal.)

Jo

--
Jo Liss
http://opinionated-programmer.com/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Larry  
View profile  
 More options Apr 4 2011, 1:56 pm
From: Larry <i...@stupidtuesday.com>
Date: Mon, 4 Apr 2011 10:56:12 -0700 (PDT)
Local: Mon, Apr 4 2011 1:56 pm
Subject: Re: Database content not on web page when running with @javascript
Hi Jo,

Yes, I would agree with Jen-Mei's assessment and your summary because
that's exactly what happened to me. (So I guess you have to figure out
how much trust you want to put in a Sample Size of 2 :-)

-- Larry

On Apr 4, 11:38 am, Jo Liss <jolis...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jonas Nicklas  
View profile  
 More options Apr 4 2011, 6:15 pm
From: Jonas Nicklas <jonas.nick...@gmail.com>
Date: Tue, 5 Apr 2011 00:15:39 +0200
Local: Mon, Apr 4 2011 6:15 pm
Subject: Re: [Capybara] Re: Database content not on web page when running with @javascript
Just to clear this up a bit and explain the how an why a bit.

When Capybara runs under rack-test, everything happens in the same
thread of the same process. Capybara runs your stuff directly agains
your Rails app. What this means is that if you open a transaction in
cucumber, that same transaction is used within your Rails app, so if
you create a database record in Cucumber, it will show up in your
Rails app.

What happens under Selenium is this: Capybara starts up your Rails app
using a webserver (usually webrick or thin) in a *separate thread* of
the *same process*. ActiveRecord assumes that different threads are
used to handle concurrent requests, so it uses separate connections,
and thus separate transactions for each thread. What this means is
that if a record is created in Cucumber, that record is created in a
different transaction than the Rails app is running under, which means
it *won't* show up in the app.

Makes sense?

This leaves us with three possible solutions:

1. Switch off transactions entirely, truncate (empty out) the database
after each test
2. Switch off transactions only for those tests that use Selenium,
truncate the DB after those.
3. Make sure transactions are switched *on* and force Rails to use the
same transaction for all threads

If you just set up DatabaseCleaner with :truncation mode, number 1
will happen. This should do the job, but it's pretty slow. Also
transactions are nice, since there's less risk of crap data remaining
in your DB. Number 2 is what cucumber does out of the box. It works,
but it's kind of convoluted, and has a tendency to break every now and
then.

Number 3 is what José's hack is all about. The consequence of this, is
that if you use 3, transactions need to be switched *on*. You do not
need DatabaseCleaner for that, just set:

Cucumber::Rails::World.use_transactional_fixtures = true

Hope that clear up some confusion.

/Jonas


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Larry  
View profile  
 More options Apr 5 2011, 7:11 am
From: Larry <i...@stupidtuesday.com>
Date: Tue, 5 Apr 2011 04:11:31 -0700 (PDT)
Local: Tues, Apr 5 2011 7:11 am
Subject: Re: Database content not on web page when running with @javascript
It certainly does clear up the confusion, Jonas. And thanks for taking
the time to write that excellent synopsis. It always helps to know
what's going on underneath the covers, and the scenarios and reasons
you described are usually not explained in whatever Rails book you're
reading at the time; they usually just say that transactions are run
under the scope of a connection and leave it at that. Which is fine,
if you know what that actually *means*, and not so fine if you don't.

And now I - and others who will read this - do! :-)

Thanks again,
Larry

On Apr 4, 6:15 pm, Jonas Nicklas <jonas.nick...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Larry  
View profile  
 More options Apr 5 2011, 2:02 pm
From: Larry <i...@stupidtuesday.com>
Date: Tue, 5 Apr 2011 11:02:19 -0700 (PDT)
Local: Tues, Apr 5 2011 2:02 pm
Subject: Re: Database content not on web page when running with @javascript
Awww, man... sorry to be a pain, but what you suggested didn't work
(at least for me).

The last post by Jonas made a lot of sense, and it seemed that option
#3 was the best choice. So I removed my database-cleaner code and put
the patch code (to force using the same connection) back in my
features/support/local_env.rb - along with the following statement:
Cucumber::Rails::World.use_transactional_fixtures = true

But records remain in the database after the tests have run. And
(obviously) they keep building up with each run.

I put print statements in 'local_env.rb' to make sure that
"use_transactional_fixtures" was being set to true and that the patch
code was being run - which was verified. I also put print statements
in my tests to make sure that "use_transactional_fixtures" wasn't
somehow getting set back to false - it wasn't.

So everything seems to be in order. I also figure the patch must be
working because if it wasn't I wouldn't be seeing any data on my web
page. But I am, so I assume the same connection/transaction is being
used.

But the data remains in the database.

Any ideas?

Thanks,
Larry

On Apr 5, 7:11 am, Larry <i...@stupidtuesday.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Matt Wynne  
View profile  
 More options Apr 5 2011, 4:00 pm
From: Matt Wynne <m...@mattwynne.net>
Date: Tue, 5 Apr 2011 21:00:02 +0100
Local: Tues, Apr 5 2011 4:00 pm
Subject: Re: [Capybara] Re: Database content not on web page when running with @javascript

On 5 Apr 2011, at 19:02, Larry wrote:

No more ideas, but I have some advice.

Take a break and come back to it fresh. You have all the information you need to solve the problem now. Give your brain a chance to process it all :)

cheers,
Matt

m...@mattwynne.net
07974 430184


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Larry  
View profile  
 More options Apr 6 2011, 2:32 pm
From: Larry <i...@stupidtuesday.com>
Date: Wed, 6 Apr 2011 11:32:54 -0700 (PDT)
Local: Wed, Apr 6 2011 2:32 pm
Subject: Re: Database content not on web page when running with @javascript
Hi Matt,

Thanks for the pep-post ;-)

When I read it first thing this morning I realized you were right and
recognized the importance of your advice not just for this issue, but
any vexing problem you're having at the time. (It also made me feel
better :-)

To make matters worse, I was wrestling with another issue at the same
time, and found my brain mixing and mashing together all of the
different aspects of both problems - thus compounding the confusion.

Anyway, I separated the two and planned on attacking them one at a
time. This one was first and it turned out to be pretty easy - but
only because the Cucumber folks released a new version of the cucumber-
rails gem. I installed that and re-ran the generator and lo and
behold... it worked!

So many thanks to you guys and the Cucumber folks (if they are
following this) - all of your great work and help is much appreciated!

-- Larry

On Apr 5, 4:00 pm, Matt Wynne <m...@mattwynne.net> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
nruth  
View profile  
 More options Jul 7 2011, 11:46 am
From: nruth <nick.rutherf...@gmail.com>
Date: Thu, 7 Jul 2011 08:46:24 -0700 (PDT)
Local: Thurs, Jul 7 2011 11:46 am
Subject: Re: [Capybara] Re: Database content not on web page when running with @javascript

Which gem versions do you get this trick to work with cucumber and selenium?
For me it works with rspec/capybara, but not for cucumber (in the same
project).

From the logs it appears that it isn't enabling transactional features with
cucumber. If I put database_cleaner back in the tests pass.
Has the config attribute to turn them on/off been removed? Or is it still
working for you?

Cucumber::Rails::World.use_transactional_fixtures = true

I tried putting it in my support file & in the cucumber env.rb (with
database_cleaner removed) but neither seems to work.

I have:    
cucumber (1.0.0)
cucumber-rails (1.0.2)
capybara (1.0.0)
rails (3.0.9)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Larry  
View profile  
 More options Jul 7 2011, 1:26 pm
From: Larry <i...@stupidtuesday.com>
Date: Thu, 7 Jul 2011 10:26:32 -0700 (PDT)
Local: Thurs, Jul 7 2011 1:26 pm
Subject: Re: Database content not on web page when running with @javascript
Hi,

I have:

cucumber (1.0.0)
cucumber-rails (1.0.0)
capybara (1.0.0)
rails (3.0.8)

so we're pretty close on that. (Although one point-release here or
there can make a world of difference ;-)

I also have database_cleaner (0.6.7)

Here's where we do differ, though, so maybe this will solve your
problem:

In my support/env.rb I have the following (which I believe is what you
get when you run the cucumber:install generator after installing a new
version of the cucumber gem):

begin
    DatabaseCleaner.strategy = :transaction
rescue NameError
    raise "You need to add database_cleaner to your Gemfile (in
the :test group) if you wish to use it."
end

Hope this helps,
Larry

On Jul 7, 11:46 am, nruth <nick.rutherf...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Messages 1 - 25 of 31   Newer >
« Back to Discussions « Newer topic     Older topic »