Cucumber factory 1.10.0 released
I've pushed an update to Cucumber factory that simplifies working with FactoryGirl
factories.
Say you define a factory with the class:
option:
factory :admin, class: User
email
admin true
end
In the past, you had to write
Given there is a user (admin)
Now you can simply write
Given there is an admin
The class is inferred from the factory.
Related cards:
FactoryBot: How to get the class from a factory name
When you want to look up a class for a given factory, do it like this:
>> FactoryBot.factories.find('admin').build_class
=> User
In older versions, you could do:
>> FactoryBot.factory_by_name('admin').build_class
=> User
factory_bot: Re-use partial factory definitions
Let's say you have two factories that share some attributes and traits:
FactoryBot.define do
factory :user do
screen_name 'john'
email 'foo@bar.de'
trait :with_profile do
age 18
description 'lorem ipsum'
end...
How to change the class in FactoryBot traits
FactoryBot allows a :class
option to its factory
definitions, to set the class to construct. However, this option is not supported for trait
s.
Most often, you can just define a nested factory instead of a trait, and use the :class
option ...
cucumber_factory: How to keep using Cucumber 2 Transforms in Cucumber 3
Cucumber up to version 2 had a neat feature called Step Argument Transforms which was dropped in favor of Cucumber 3 [ParameterTypes](https://cucumber.io/blog/upgrading-to-cucum...
CucumberFactory 1.11 lets you use FactoryGirl traits
If you have FactoryGirl traits like this:
factory :movie do
title 'Sunshine'
year 2007
trait :vintage do
year 1951
end
trait :moody do
...
Never write a Cucumber step definition again with Cucumber Factory - Gem Session: gem
I love Cucumber, but I hate writing step definitions. They are ugly, awkward to write and very, very boring: Most step defintions merely create objects for a scenario to chew on.
Boolean attributes and pretty enumerations in Cucumber Factory 1.7
Boolean attributes can now be set by appending "which", "that" or "who" at the end:
Given there is a movie which is awesome
And there is a movie with the name "Sunshine" that is not a comedy
And there is a director who is popular
Ins...
New Cucumber Factory makes it easier to associate records
I pushed a new version of the Cucumber Factory gem. This new release lets you refer to a previously created record by any string attribute:
Given there is a movie with the title "Before Sunris...
Cucumber Factory: How to assign polymorphic associations
Cucumber factory supports polymorphic associations out of the box. Just keep in mind that you need to use named associations for this purpose.
class Person < ApplicationModel
has_many :bu...
Upgrading a Rails app to Cucumber 3
Upgrade gems
You need to update a lof gems. Make sure you don't have any version constraints in your Gemfile
or your bundle update
won't do anything!
Upgrade cucumber_priority
:
bundle update cucumber_priority
Upgr...