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 6592607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:34:36+00:00 2026-05-25T17:34:36+00:00

I am using the cucumber step definitons provided by factory girl and I can

  • 0

I am using the cucumber step definitons provided by factory girl and I can not get something to work here.

First of all, here are the involved factories:

Factory.define :user do |u|
  u.name {|n| "User#{n}" }
  u.first_name {|n| "FirstName#{n}"}
  u.last_name {|n| "LastName#{n}"}
  u.password 'please'
  u.password_confirmation 'please'
end

Factory.define :lecture do |l|
  l.name {|n| "Lecture#{n}"}
  l.abbreviation {|n| "lec#{n}"}
  l.association :admin, factory: :user
end

Here is the step I am trying to execute:

And the following Lecture exists:                                        
      | Name                                           | Abbreviation |
      | Informatik A - Algorithmen und Datenstrukturen | ainf         |

I am getting this error message and have absolutely NO idea where it comes from:

User(#42819220) expected, got User(#43753000) (ActiveRecord::AssociationTypeMismatch)
      features/lectures/ui.feature:11:in `And the following Lecture exists:'

And here are my model definitions:

    class User < ActiveRecord::Base
  # Include default devise modules. Others available are:
  # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
  devise :database_authenticatable, :rememberable, :trackable

      # Setup accessible (or protected) attributes for your model
  attr_accessible :name, :password, :password_confirmation, :remember_me, :first_name, :last_name

  validates_uniqueness_of :name

  has_many :administrated_lectures, class_name: "Lecture", foreign_key: "admin_id", dependent: :nullify
end

class Lecture < ActiveRecord::Base
  validates_uniqueness_of :name
  validates_uniqueness_of :abbreviation

  scope :ordered, order("name")

  belongs_to :admin, class_name: "User"
end

I am using this with spork btw.

Kind regards,

Nils

  • 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-05-25T17:34:36+00:00Added an answer on May 25, 2026 at 5:34 pm

    Oh, damn. Got it. I set cache_classes to false somewhere in the past because proper class reloading did not work for some reason. Just made it true again, and now it works. :/

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

Sidebar

Related Questions

https://stackoverflow.com/questions/5282437/cucumber-pickle-factory-girl-given-a-returning-undefined-step - this post didn't help me a lot. Gemfile: gem 'rails' # 3.0.5
I'm trying to get cookie values in the Cucumber step: Step definitions When /^I
I'm using cucumber with RoR (with either webrat or capybara) How can I write
What is the difference between using the two following statements in a cucumber step
I'm using cucumber and selenium for integration testing and have defined a cucumber step
Using: factory_girl-2.6.4 cucumber-1.2.1 ruby 1.8.7 (2012-02-08 patchlevel 358) [x86_64-linux] Rails 3.0.15 FactoryGirl.define do factory
I'd like to get opinions from others with more experience on writing Cucumber step
Im using Cucumber + Capybara. This is how one of my step definitions looks
I'm using cucumber with my rails 3 app. My step definition works like so:
Starting out a tiny app with my first time using Cucumber 1.1.4 and it's

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.