FixtureReplacement

FactoryGirlでCarrierWaveのテストデータを作る

Githubのwikiに書いてある。 Attaching a file to a FactoryGirl object is pretty much identical. Factory.define :brand do |f| f.name "My Brand" f.description "Foo" f.logo { Rack::Test::UploadedFile.new(File.join(Rails.root, 'spec', 'support',…

setterがないclassをFactoryGirlで使うとき

FactoryGirlで自分で作ったclassのFactoryを作りたかったんだけど setterがないので普通のやり方ではデータをセットできなかった class #-*- coding: utf-8 -*- class Hoge attr_reader :name def initialize(name) @name = name end end factory #-*- codin…