Noob question

Just getting started with cucumber on Mac 10.5.6.

I have the default Ruby install (1.8). I’m not using Rails. I did a
gem update cucumber
and now have cucumber-0.3.1 in my gems.

I also did a
git clone
and have a repo with cucumber 0.3.2.

When I cd into my cucumber (git) directory and do:
cucumber features
I get
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in
gem_original_require': no such file to load -- spec/expectations (LoadError) Failed to load ./cucumber/examples/selenium_webrat/features/support/env.rb from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:27:inpolyglot_original_require’
from /Library/Ruby/Gems/1.8/gems/polyglot-0.2.5/lib/polyglot.rb:54:in
`require’
from ./cucumber/examples/selenium_webrat/features/support/env.rb:1

Looks like I need a bunch more stuff than what the gem installs. Where
can I
find out what to install?

Thanks!

There’s about 3 more gems you need to install. RSpec, RSpec-rails and
WebRat. There’s also a great introductory article I found on-line at
http://blog.rubyyot.com/2009/01/chores-a-test-driven-website/

I’m only half-step ahead of you and feel your pain.
Good luck,
Wayne

On Apr 28, 12:47 pm, “Sophie (itsme213)” [email protected]

Presumably you only need these if you are building cucumber?

If you just want to use cucumber, it should be as simple as “gem
install cucumber”, and it should get all the other dependencies. On
my machine it seemed to install treetop, polyglot, and presumably a
few others - but I don’t have rspec-rails nor webrat.

(On looking back at the original post, maybe I’m confused - presumably
if you are cloning cucumber from git, you mean to build it yourself.
But I’m not sure why someone calling themselves a “noob” would want to
do that! :slight_smile: )

  • Korny

On Wed, Apr 29, 2009 at 7:02 AM, WJSimacek [email protected]
wrote:

Just getting started with cucumber on Mac 10.5.6.
cucumber features
from ./cucumber/examples/selenium_webrat/features/support/env.rb:1
[email protected]://rubyforge.org/mailman/listinfo/rspec-users


rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users


Kornelis Sietsma korny at my surname dot com
“Every jumbled pile of person has a thinking part
that wonders what the part that isn’t thinking
isn’t thinking of”

On Wed, Apr 29, 2009 at 7:42 AM, Korny S. [email protected]
wrote:

Presumably you only need these if you are building cucumber?

If you just want to use cucumber, it should be as simple as “gem
install cucumber”, and it should get all the other dependencies. On
my machine it seemed to install treetop, polyglot, and presumably a
few others - but I don’t have rspec-rails nor webrat.

rspec(-rails) and webrat aren’t actually required by Cucumber – you
can
use it without them, which is why they’re not force-installed. However,
nearly every example you’re going to find of Cucumber run against a
rails
app is going to be using webrat and rspec-rails …

the book The RSpec book has an example where they build an app with
just ruby. (“Describing Application Behaviour with Cucumber”)
You can download some sample chapters.

This has been a big help for me.

also Railscast (http://railscasts.com/) has some screen cast with
cucumber but it is rails related.

John

Support me on my MS 150 ride May 2-3, 2009 Frisco to Fort Worth

training - http://www.dailymile.com/people/john_ivanoff

True, but cucumber is useful for lots of different kinds of projects.
I’m currently using it to build a java webapp, so I don’t need much
beyond cucumber, selenium, and selenium-client.

But agreed, if I was in rails-land (sigh) then I’d want webrat and
rspec-rails.

  • Korny
    p.s. I’m aware webrat works without rails, but when I looked it didn’t
    seem a big boost for our kind of app.

On Wed, Apr 29, 2009 at 10:42 PM, Chris F. [email protected]
wrote:

use it without them, which is why they’re not force-installed. However,
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users


Kornelis Sietsma korny at my surname dot com
“Every jumbled pile of person has a thinking part
that wonders what the part that isn’t thinking
isn’t thinking of”

Korny S. wrote:

True, but cucumber is useful for lots of different kinds of projects.
I’m currently using it to build a java webapp, so I don’t need much
beyond cucumber, selenium, and selenium-client.

I’m curious, with your current setup do you insert data directly into
your database (i.e. in Given steps) or do you always use the selenium to
enter in data. Meaning, if you needed a user to exist so you could have
them log in… do you use ActiveRecord, or something similar, to create
the user or do you use the webforms to create the user? Also, how do
you handle cleaning the database after each scenario? Sorry, for the
questions, but I’m curious how you’ve solved these problems when using
Cucumber to test a non-ruby webapp.

Thanks,
Ben

Cucumber is not built to do rapid BDD … It is an integration and
acceptance specification exercise system. Rspec is for development
… Mocks are an integral part of the BDD process. The idea is to
partition the system component behaviors so that you can focuss on the
implementing the behavior that you are working on. This minimizes the
"Yak Shaving " yak shaving - Wiktionary

You can focus on the task at hand … For example if you are building a
system that connects to a remote system to send a data feed … And get
a confirmation that the transmission was successful. When you are
developing you don’t want to be stalled by the connectivity issues so
you mock the external system’s behavior in respect to your system.
Cucumber’s flow is to expect that the step definitions connect to real
systems and not mocks.

This is how I understand the relation the separation of duties.

Brian Colfer

Korny S. wrote:

And then our scenarios have stuff like “Given a top-level node called
“Foo” exists” - which creates the node via selenium.

However there are some areas where this is just too slow, and we have
created some ‘Given’ steps that use ruby-sequel code that build up
data directly in the database. This does mean duplicating some of our
Java domain in the ruby code, but it seemed to be a pragmatic solution
to the problem.

Have you considered running Cucumber with JRuby so you can leverage your
Java code to insert records into the DB? Just an idea.

Currently we are debating whether to make more ‘Given’ steps directly
push data into the database - there are pros and cons either way;
using the UI gives us more confidence in our app (and less fragility
if our domain changes) and requires less code (we can reuse ‘when’
steps from some scenarios as ‘given’ steps for others) but it’s slower

  • and the accumulated effect of slow builds can be terrible.

As far as the confidence aspect goes, it seems that you should gain
enough confidence by having Cucumber fill out each form once then insert
the data directly the other times. That is at least how I approach
things in webrat world. But you are right about all of the trade-offs
and that is why I am curious on how you are solving them. Thanks for
sharing!

-Ben

We are actively debating this very topic :slight_smile:

For most stuff, we create data through the UI.

We have a “Before” block that prunes the database back to a known
state before each scenario, using the ruby ‘sequel’ library. It’s
pretty fast, but it does mean we have to be careful in our selenium,
that we wait for the database as seen by the app to catch up with the
database session committed by the ruby code.

And then our scenarios have stuff like “Given a top-level node called
“Foo” exists” - which creates the node via selenium.

However there are some areas where this is just too slow, and we have
created some ‘Given’ steps that use ruby-sequel code that build up
data directly in the database. This does mean duplicating some of our
Java domain in the ruby code, but it seemed to be a pragmatic solution
to the problem.

Currently we are debating whether to make more ‘Given’ steps directly
push data into the database - there are pros and cons either way;
using the UI gives us more confidence in our app (and less fragility
if our domain changes) and requires less code (we can reuse ‘when’
steps from some scenarios as ‘given’ steps for others) but it’s slower

  • and the accumulated effect of slow builds can be terrible.

  • Korny

On Thu, Apr 30, 2009 at 9:32 AM, Ben M. [email protected] wrote:

in… do you use ActiveRecord, or something similar, to create the user or do

rspec-rails.

use it without them, which is why they’re not force-installed. However,
rspec-users mailing list
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users


Kornelis Sietsma korny at my surname dot com
“Every jumbled pile of person has a thinking part
that wonders what the part that isn’t thinking
isn’t thinking of”

On Wed, Apr 29, 2009 at 5:47 PM, Colfer, Brian [email protected]
wrote:

Cucumber is not built to do rapid BDD … It is an integration and acceptance specification exercise system. Rspec is for development … Mocks are an integral part of the BDD process. The idea is to partition the system component behaviors so that you can focuss on the implementing the behavior that you are working on. This minimizes the "Yak Shaving " yak shaving - Wiktionary

While many might see Cucumber as a an “integration and acceptance
specification exercise system,” and it certainly is a great tool for
expressing executable acceptance tests, it’s actually also quite
powerful in doing rapid BDD. The term “outside-in” development is
gaining popularity for a process which uses Cucumber (or a similar
tool I guess) and RSpec (or similar) together to do iterative
development using two nested iteration cycles. The process goes
something like:

  1. Pick a story
  2. Write a failing cucumber scenario for the story.
  3. If, as is likely to happen the scenario exposes the need for new
    classes, or new class behavior then:
  4. Use RSpec to design/code the new class(es) and behaviours
    writing failing examples, then making them work.
  5. When the scenario succeeds, consider whether refactoring (in the
    context of the overall system) is desirable in order to manage
    technical debt.
  6. Repeat from 1

Using cucumber scenarios to keep you on the track of doing the next
thing that NEEDS to be done is a very good way to stave off the desire
to shave yaks.


Rick DeNatale

Blog: http://talklikeaduck.denhaven2.com/
Twitter: http://twitter.com/RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale

We did think about using JRuby to write data through the domain -
unfortunately it looked fiddly, especially as there are quite a few
things our ruby code wants to do that the domain doesn’t cover.

For example, mass deleting data - in the domain, almost everything is
soft-deleted, and everything generates audit logs; in our tests, we
want do disable constraints and then delete everything in the
underlying tables, with no auditing.

Mostly, though, we started with really simple stuff that was easier to
do in ruby, and as usual things grew as we went along. Moving to
using the real domain might be something we tackle as a refactoring at
a later date. Also some parts of our database are legacy stuff that
doesn’t really have a good domain layer - it’d be good to add one, but
it’s a big chunk of work

I should throw in a quick plug here - the ruby sequel library (
http://sequel.rubyforge.org/ ) , despite having a sucky name, is
great for this sort of thing - manipulating tables, one-off
migration scripts, and the like. If you need to manipulate data, but
don’t want a full ORM, give it a look.

  • Korny

On Thu, Apr 30, 2009 at 2:22 PM, Ben M. [email protected] wrote:

database session committed by the ruby code.

your
webapp.

  • Korny


rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users


Kornelis Sietsma korny at my surname dot com
“Every jumbled pile of person has a thinking part
that wonders what the part that isn’t thinking
isn’t thinking of”