evilmartians.com

...unintentionally slow down test suites by creating unnecessary or excessive associated data (factory cascades). Understanding Factory-Induced Slowdowns Factories often create additional data (e.g., associated records) that can significantly slow...

...EventProf: Measures the time spent on specific events during tests to identify slow processes. FactoryProf: Tracks and analyzes factory usage to pinpoint inefficiencies such as: Overused factories being invoked repeatedly...

thoughtbot.github.io

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...

...re-use the shared fields by defining a trait outside the other factory definitions: FactoryBot.define do trait :person do email 'foo@bar.de' trait :with_profile do age 18 description 'lorem ipsum...

Cucumber factory supports polymorphic associations out of the box. Just keep in mind that you need to use named associations...

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

I pushed a new version of the Cucumber Factory gem. This new release lets you refer to a previously created...

...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...

github.com

Boolean attributes can now be set by appending "which", "that" or "who" at the end: Given there is a movie...

gem-session.com

I love Cucumber, but I hate writing step definitions. They are ugly, awkward to write and very, very boring: Most...

...screen. When your factory requires unique values for something, prefer numbering fixed strings intead: FactoryBot.define do sequence(:first_name) { |i| "First#{i}" } sequence(:last_name) { |i| "Last#{i}" } sequence(:company...

...tests break because they relied on the data you just changed. Getting to know FactoryBot Our favorite gem for test factories is FactoryBot. We used other gems in the past...

...PRO #158 Factories not Fixtures (revised) for an introduction to factories in general and FactoryBot in particular. Note This is an older video. FactoryGirl has since been renamed to FactoryBot...

...a file upload, please check that your upload form is multipart encoded. Factory Bot FactoryBot.define do factory :user do name { 'Bruce' } email { 'bruce@wayne.us' } avatar { Rack::Test::UploadedFile.new('spec/fixtures/files/avatar.jpg') } end

...an optional field, you want to move the file assignment to an optional trait. FactoryBot.define do factory :user do name { 'Bruce' } email { 'bruce@wayne.us' } trait :with_avatar do avatar { Rack::Test...

Your MovieDB gained traction and is now a popular tool among cineasts. This comes with a downside: You noticed a...

Cucumber up to version 2 had a neat feature called Step Argument Transforms which was dropped in favor of Cucumber...

FactoryBot.define do factory :parent do transient do child_name nil child_allowed_to_drive false end child do association(:child, name: child_name, allowed_to_drive: child_allowed_to_drive...

factory :child do name 'Child' allowed_to_drive false end end # Usage daughter = FactoryBot.create(:parent, child_name: 'Lisa').child daughter.name # => 'Lisa' daughter.allowed_to_drive? # => false son = FactoryBot.create(:parent, child...

Advanced cucumber features Learn about the following cucumber features: Doc Strings ("multiline strings") Tables Tags Before/after hooks Background Scenario outlines...

angular-tips.com

Angular comes with different types of services. Each one with its own use cases. All of these services are singletons...

github.com

FactoryBot allows a :class option to its factory definitions, to set the class to construct. However, this option is not supported for traits. Most often, you can just define a...

...factory :message do trait :reply do initialize_with { Message::Reply.new(attributes) } # ... end end Now FactoryBot.build(:message, :reply) will construct a Message::Reply instead of a Message...

makandra dev
github.com

FactoryBot allows to create traits from Enums since version 6.0.0 The automatic definition of traits for Active Record enum attributes is enabled by default, for non-Active Record enums you...

Note: If you not provide a second argument to traits_for_enum, FactoryBot will attempt to get the values by calling the pluralized attribute_name class method, which...

Given there is a user with the name "Dominik Schöler" and have FactoryGirl assign first and last name automatically? The code below achieves that! Solution factory :user do...

github.com

If you have FactoryGirl traits like this: factory :movie do title 'Sunshine' year 2007 trait :vintage do year 1951 end trait :moody do title 'Interstellar' end end

This guide shows how to create an AngularJS application that consumes more and more memory until, eventually, the browser process...

I encountered a bug in RSpec 1.x where stubbed class methods ("static methods") would not be unstubbed before the...

m.onkey.org

decided to go fixtureless with Shoulda + Factory Girl. All good, except one problem. Slow as fuck tests. So here’s...