A Factory library that's about as barebones as you can get.
# "forge" was taken -_- gem "forge-factories" $ bundle install # or gem install forge-factories
Forge.define(:user, User) do |u| u.name = "Spike Spiegel" u.location = "Mars" end
Defining Factories That Use Other Factories
Forge.define(:ship, Ship) do |s| s.name = "Bebop" end Forge.define(:user, User) do |u| u.name = "Spike Spiegel" u.ship = Forge.build(:ship) end
Building Objects and Overriding Attributes
Forge.build(:user, name: "Jet")
You can drop the
Forge part of the methods if you include
RSpec.configure do |config| config.include Forge::DSL end it "..." do build(:user).should be_awesome end
Raised when you try to define two factories using the same name.
Raised when you try to build a factory that has not been defined.