Comments (4)
Hi, @cutalion thanks for the issue
I was looking into and well I have to say I think is not a limitation of the library but more of a limitation of the language.
[].each do |when|
puts when
end
Traceback (most recent call last):
syntax error, unexpected keyword_when, expecting '|'
[].each do |when|
I don't think is the good approach to try working against ruby
On another topic, I was trying to use ranges in the library and end up with a working example.
factories.define(:announcement) do |f|
f.range { ROM::SQL::Postgres::Values::Range.new(3, 9, :'[]') } # range
f.begin { |range| range.lower }
f.end { |range| range.upper }
end
announcement = factories[:announcement]
expect(announcement.begin).to eq 3
expect(announcement.end).to eq 9
I found a little verbose having to type all that code to create a range type, might be interesting to have some method to create ranges or something a little more generic for the users? WDYT? @solnic
from rom-factory.
Hi @GustavoCaso, you're of course right about language limitations.
But I think that the issue is with the way of passing parameters, with API itself.
Consider the following example:
Factory.define(:announcement) do |f|
f.when { 10.hours.since..12.hours.since } # time range
f.start_time { |attrs| attrs[:when].begin.strftime('%H:%M') }
f.end_time { |attrs| attrs[:when].end.strftime('%H:%M') }
end
It wouldn't have such limitations.
from rom-factory.
Btw, I had to deal with the similar issue in dry-validation
.
validate(start_lt_end: [:when]) do |when_|
when_.begin < when_.end
end
Here at least it's possible to pick a name for a variable. In rom-factory
attribute is picked after the local variable name (nice trick).
I know this a very bad name for attribute in ruby, but it's the legacy database and it's first (two) places where it hit me. I've never had such issues in rails/activerecord/fabricator/etc
from rom-factory.
@cutalion I will see what I can do
from rom-factory.
Related Issues (20)
- Argument error could be more informative HOT 1
- Has many association does not seem to work as expected
- 0.7.0 release? HOT 1
- Error with `factories.structs[:relation]` after upgrade to 0.7.0 HOT 4
- Has many association does not allow overrides
- Allow for option to override association factory name HOT 3
- Unexpected behaviour of dependent attributes HOT 1
- Allow usage of relations in dependant attributes HOT 4
- Add documentation HOT 1
- Ruby 2.7 deprecations HOT 3
- Typo in learn/factory guide
- has_many or has_one with 3 or more factories not workig
- overriding factory attributes is causing related field callbacks to fail HOT 5
- Allow for creating multiple instances in one DB call HOT 1
- Overriding attributes doesn't affect dependent attributes HOT 1
- Inconsistent behaviour with default schema values in factories HOT 1
- Trait and dependent attributes conflicting
- Add possibility to use unique-ft of faker HOT 2
- It is not possible to overwrite an association with nil. HOT 1
- Top-Level custom structs are not recognized HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rom-factory.