paulelliott / fabrication-site Goto Github PK
View Code? Open in Web Editor NEWThis project has moved to GitLab! Please check there for the latest updates.
Home Page: https://gitlab.com/fabrication-gem/docsite
This project has moved to GitLab! Please check there for the latest updates.
Home Page: https://gitlab.com/fabrication-gem/docsite
It currently refers to a reverted option called inverse_of. It needs to be rewritten to explain how to manually prevent that scenario.
When I use attributes_for for a complex object, the complex object is not converted to a hash. For example:
class Order
attr_accessor productType
attr_accessor quoteRef
attr_accessor allocations
attr_accessor marketPrice
end
class Allocation
attr_accessor account
attr_accessor notionalAmount
end
class MarketPrice
attr_accessor id
attr_accessor prices
end
Fabricator :order do
productType "Product"
quoteRef ""
allocations(count: 1, fabricator: :allocation)
marketPrice(fabricator: :market_price)
end
Fabricator :allocation do
account "10009-1"
notionalAmount 500000.0
end
Fabricator :market_price do |f|
f.id ""
prices [85.7]
end
Fabricator.attributes_for(:order_do, :quoteRef=> 'olalala') = Hash (4 element(s))
productType -> Product
quoteRef -> olalala
allocations = Array(1 element(s))
[0] = {Allocation} #<Allocation:0x1140ecf2>
marketPrice_id' ->
It is a bit annoying. Separately, I cannot use the word 'id' as an attribute, code in definition.rb:127 if value && value.respond_to?(:id)
hardcodes the :id symbol and the object doesn't get parsed any further.
P.S. I am using fabricator 2.5.0, as 2.5.1 doesn't work. manager.rb [](name)
tries to do a name.try(:to_sym)
on a symbol, but name is already a symbol and doesn't have the try method... at least in my jruby 1.7
One of my models has an 'alias' attribute. How would I define that attribute in a fabricator? If I do so with the normal block syntax, ruby gets confused because 'alias' is actually a ruby keyword.
That conveyor is cute and all, but I find it distracting. A pause or stop button would be awesome.
Using Rails 3.1.3 and test/unit the following syntax from the Fabrication site no longer works:
config.generators do |g|
g.fixture_replacement :fabrication, :dir => "test/fabricators"
end
To get things to work properly I'm having to use the following config:
config.generators do |g|
g.test_framework :test_unit, :fixture_replacement => :fabrication
g.fixture_replacement :fabrication, :dir => "test/fabricators"
end
I'm not 100% sure this is exactly the right way to specify the config but it seems to be the only way to get it working in Rails 3.1.3.
Without knowing the exact thinking and idea behind every part of fabrications it's sometimes hard to guess what some of the example code will actually do.
For better/easier/faster understanding I'd suggest to add some sections like "this should return..."
To keep documentation clean they could be hidden by default.
I might write something down if you like the idea.
Hey again.
I guess the fault is on my side but I don't know where else to ask:
Here is the code:
Fabricator(:ad) do
# If I use Fabricate.sequence(:ad) { |i| "test_ad_#{i}" }
# on the rails console it works perfectly.
# Using it in a fabricator like below does not unfortunately.
name { sequence(:ads) { |i| "test_ad_#{i}" } }
end
When using Fabricate(:ad) two times on the console it'll throw an error:
ActiveRecord::RecordInvalid: Database entry invalid: Name is already taken
PS: Are there any other places to ask for help than via Github issues?
This is my Fabricator:
Fabricator(:user_with_specific_time, from: :user) do
transient :time_elapsed
scores { |attrs| {Fabricate.build(:score, user: nil, time_elapsed: attrs[:time_elapsed]) } }
end
Fabricator(:score) do
time_elapsed { rand(400) }
user { Fabricate :user, user_id: nil}
end
u = Fabricate(:user_with_specific_time, time_elapsed: 1)
u.scores
[#<Score id: 23, time_elapsed: nil, user_id: 16, created_at: "2013-09-30 22:12:53", updated_at: "2013-09-30 22:12:53">]
As you can see, time_elapsed keeps nil
How did I get this working?
Sorry for my - maybe stupid - approach
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.