# \[Cucumber\] factor out non-user steps

**URL:** <https://www.ruby-forum.com/t/cucumber-factor-out-non-user-steps/155761>\
**Category:** RSpec\
**Created:** [December 16, 2008, 12:52pm UTC](https://www.ruby-forum.com/t/cucumber-factor-out-non-user-steps/155761 "2008-12-16T12:52:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![aidy\_lewis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/439d5e/32.png) [@aidy\_lewis](https://www.ruby-forum.com/u/aidy_lewis)\
**Post date:** [December 16, 2008, 12:52pm UTC](https://www.ruby-forum.com/t/cucumber-factor-out-non-user-steps/155761/1 "2008-12-16T12:52:31Z")

</div>

Hi,

I have a step that has been defined by the user

Given /a logged in user/ {}

Now in that step I have my own step (not defined by the business) of

Given “all projects have been deleted”

The second step needs to be included in the first

Given /a logged in user/ do  
Given(“all projects have been deleted”)  
end

I am thinking that “all projects have been deleted” should be hidden  
in the report.

Is there a way to prevent the sub step from being reported or should I  
factor that step  
off to a standard method in the features/support folder?

Aidy

---

<div class="post-metadata">

**Author:** ![aidy\_lewis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/439d5e/32.png) [@aidy\_lewis](https://www.ruby-forum.com/u/aidy_lewis)\
**Post date:** [December 16, 2008, 4:42pm UTC](https://www.ruby-forum.com/t/cucumber-factor-out-non-user-steps/155761/2 "2008-12-16T16:42:13Z")

</div>

aidy lewis wrote:

> Hi,
> 
> I have a step that has been defined by the user
> 
> Given /a logged in user/ {}
> 
> Now in that step I have my own step (not defined by the business) of
> 
> Given “all projects have been deleted”

This sounds like something that might be better suited to a Before /  
After.

Before do  
Projects.delete\_all  
end

> factor that step  
> off to a standard method in the features/support folder?

Which type of report are you using? In my experience the pretty and html  
formatter when rending output do not display sub-steps.

Could you perhaps give an example of a report you are having problems  
with?

There is currently no support for excluding steps from documentation.  
Its an interesting idea but the example application of hiding steps from  
the user feels wrong to me. I think that if you need to hide it from the  
user then it does not really belong in the steps domain.

What do people think?

–  
Joseph W.

> **[Joseph Wilk](http://blog.josephwilk.net)**
>
> Exploring patterns as a means of documenting Clojure functions to aid recall and understanding. Whats the difference in Clojure between:
> partition …

---

<div class="post-metadata">

**Author:** ![aidy\_lewis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/439d5e/32.png) [@aidy\_lewis](https://www.ruby-forum.com/u/aidy_lewis)\
**Post date:** [December 16, 2008, 5:43pm UTC](https://www.ruby-forum.com/t/cucumber-factor-out-non-user-steps/155761/3 "2008-12-16T17:43:17Z")

</div>

On Dec 16, 2008, at 6:50 AM, aidy lewis wrote:

> The second step needs to be included in the first  
> off to a standard method in the features/support folder?
> 
> Aidy
> 
> * * *
> 
> rspec-users mailing list  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [http://rubyforge.org/mailman/listinfo/rspec-users](http://rubyforge.org/mailman/listinfo/rspec-users)

or I would start with a step like

Given a site with no projects

---

<div class="post-metadata">

**Author:** ![aidy\_lewis](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/439d5e/32.png) [@aidy\_lewis](https://www.ruby-forum.com/u/aidy_lewis)\
**Post date:** [December 16, 2008, 10:02pm UTC](https://www.ruby-forum.com/t/cucumber-factor-out-non-user-steps/155761/4 "2008-12-16T22:02:51Z")

</div>

Jonathan L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

> > Given “all projects have been deleted”  
> > Is there a way to prevent the sub step from being reported or should I  
> > or I would start with a step like
> 
> Given a site with no projects
> 
> * * *
> 
> rspec-users mailing list  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [http://rubyforge.org/mailman/listinfo/rspec-users](http://rubyforge.org/mailman/listinfo/rspec-users)

And that step would be blank, because your database should already be  
empty, or it’s a precondition checking step like

Project.count.should == 0

Pat
