Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7849995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T18:42:36+00:00 2026-06-02T18:42:36+00:00

I’ve got a greenfield Rails 3.2 app that I cannot get the first step-def

  • 0

I’ve got a greenfield Rails 3.2 app that I cannot get the first step-def to work. My cucumber-rails is (1.3.0), factory_girl_rails (3.1.0). They are both in the test environment. As per good cucumber practices, this app has NO model, generator or views written yet. I’m waiting for the nudge from the testing to drive what needs to be done.

Here is the first feature:

Background: 
   Given a School "Murfree High School" exists

Here’s the step definition.rb

 Given /^a School "([^"]*)" exists$/ do 
    #Factory(:school)  #fails
    school = FactoryGirl.create(:school)
 end

Here is my spec/factories.rb

 require 'factory_girl'
 FactoryGirl.define do
   factory :school do
     name "Murfree High School"
   end
 end

So I get a mismatch error because I want to make that step definition a general step so I can swap in any name of a school. BUT the point of a factory I thought is to nail down a record generation so that I can reuse that factory in other definitions, and perhaps grow it as the number of fields grow. Normally my step def would be Given /^a School “([^”]*)” exists$/ do |name| but there is no where to put that argument when I have a factory ready to go generate that test record. If I remove the quotes around the name of the high school in the feature so that this definition is “tied” to that factory, I get a yellow response from cucumber. Which begs the question: since I don’t have a model to generate into, why didn’t I receive a red error msg?

What am I overlooking in reconciling factoryGirl and a generic step definition in cucumber?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T18:42:38+00:00Added an answer on June 2, 2026 at 6:42 pm

    FactoryGirl includes a set of step definitions, one of which will automatically create a step called a school exists with a name of "([^"]+)". See http://robots.thoughtbot.com/post/284805810/gimme-three-steps for the original announcement.

    PS: I also created a copy of the FG step definition module which does exactly the same thing, only also creates instance variables based on the name of the factory being generated. In your case, the instance variable @school would be created.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I am using Paperclip to handle profile photo uploads in my app. They upload
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
i got an object with contents of html markup in it, for example: string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.