When to use Cucumber vs RSpec

Background:

In The RSpec Book, the Cucumber examples for step_definitions call
objects and methods directly. For example:

When /^I start a new game$/ do
  game = Codebreaker::Game.new(output)
  game.start('1234')
end

The example step when generating a new GLI app uses Aruba and calls the
app/command directly:

When /^I get help for "([^"]*)"$/ do |app_name|
  @app_name = app_name
  step %(I run `#{app_name} help`)
end

If Cucumber is supposed to test application behavior, it seems like most
of the time it should run the app directly the way the GLI examples
does. Then, direct interactions with objects and methods should be
relegated to RSpec. Is that the case?

Alan S. wrote in post #1141766:

Background:

In The RSpec Book, the Cucumber examples for step_definitions call
objects and methods directly. For example:

When /^I start a new game$/ do
  game = Codebreaker::Game.new(output)
  game.start('1234')
end

The example step when generating a new GLI app uses Aruba and calls the
app/command directly:

When /^I get help for "([^"]*)"$/ do |app_name|
  @app_name = app_name
  step %(I run `#{app_name} help`)
end

I don’t see any difference between this code example and the one above
in the context you are describing, rather a complete example would be
more helpful to get a hint.

v.

To bring it to a higher level (which is really what I’m after), in the
first example, Cucumber interacts directly with the objects (e.g. making
a new one and then calling a method directly). The second one uses
backticks to actually run the app.

If Cucumber is for testing the app behavior (of a command line app in
this case), it seems like each of its tests should be made with the
backticks running the app directly. One the same lines, all the cases
where the test is making its own instance of the object and calling
methods on it should be RSpec.

I realize that both Cucumber and RSpec are capable of doing the opposite
job. I’m just trying to figure out the best practice for where to split
the behavior and the unit tests.

I will recommend you: first, learn, read the Cucumber official book from
pragmmatic programmers. Then read the RSpec book you are reading. That’s
the path I took and the easiest to understand the interaction between.
Second: try this gem: cocot | RubyGems.org | your community gem host , here’s the
documentation of what it does: GitHub - damian-m-g/cocot: Skeleton builder of a new proyect wich will be developed with BDD. . I
made it a while ago after read both books.

Thanks Damián. I’ll go through the Cucumber book for a better
understanding.