Re: RailsExampleGroup

Well, I use this for driving selenium RC. So the approach I am using
is to setup some data, and then invoke selenium to interact with a
test server. Apparently the test server uses another connection. Would
you suggest a better way to handle this? It will be the same for doing
functional testing on web services. What’s the “standard way” of doing
it?

Yi

On 23 May 2008, at 19:53, Yi Wen wrote:

It’s not in the database. It looks to me the data is not actually
inserted into the DB at all, just somehow buffered somewhere.

It’s stored in a transaction, so the only place you can see the data
is from the same connection. Make another connection (by
reconnecting) and you are protected from seeing that data.

Why do you want to see this intermediate state of the database from
another connection anyway? It’s an unusual thing to want to do.

Ashley

On 23 May 2008, at 21:35, Yi Wen wrote:

Well, I use this for driving selenium RC. So the approach I am using
is to setup some data, and then invoke selenium to interact with a
test server. Apparently the test server uses another connection. Would
you suggest a better way to handle this? It will be the same for doing
functional testing on web services. What’s the “standard way” of doing
it?

Ah ok, I get you now. I did the same thing and it stumped me too, I
was completely baffled for a whole day. What you’ve got with selenium-
rc is not this:

±-ruby-process–+
| |
| rails |
| ^ |
| | |----->(database)
| rspec |
| |
±---------------+

but this:

±-ruby-process–+
| |
| rails |--------
| |
±---------------+ |
^ |
| |
±-native-proc—+ |
| | |
| browser | |
| | |
±---------------+ V
^ (database)
| ^
±-java-process–+ |
| | |
| selenium-rc | |
| | |
±---------------+ |
^ |
| |
±-ruby-process–+ |
| | |
| rspec |--------/
| |
±---------------+

Nothing like a bit of ascii art to liven up a mailing list :slight_smile:

My solution was to create a custom story listener, which is a class
that looks like this (copied from a post I made in April):

class MyStoryListener
def run_started(number_of_scenarios); end
def story_started(story, narrative); end
def story_ended(story, narrative); end
def scenario_started(story, scenario); end
def scenario_succeeded(story, scenario); end
def scenario_pending(story, scenario, error); end
def scenario_failed(story, scenario, error); end
def run_ended; end

method_missing allows you to remove hooks you don’t need

def method_missing(*args); end
end

Spec::Story::Runner.register_listener(MyStoryListener.new)

What I did was to have the run_started hook delete all non-static data
out of the database.

There’s other things you can do to make the process more useful for
development. I’ve wanted for ages to package some code for this
together. I’ve got a Merb app I want to start soon, and this will be
an essential pre-requisite. So hopefully I’ll get that done soon and
I’ll post back here. (However my pet projects usually get
sidetracked…)

Hope this helps for now anyway.

Ashley


http://www.patchspace.co.uk/