Comments (3)
I've isolated this issue to the inclusion of Rake. make - require 'rake' - make-one-more demonstrates that in the first call, the associated object is created, and in the second call, it is not. This also happens if another gem in, for example, the Gemfile, requires 'rake'
require 'spec/mocks'
require 'spec/blue_prints'
puts Drive::FileShare.make.file_id.inspect
require 'rake'
puts Drive::FileShare.make.file_id.inspect
results in:
2633
nil
from machinist.
Ouch, this is painful. The problem turns out to be different, but perhaps closely related: the blueprints for Drive::FileShare include an attribute called 'file'. However, requiring 'rake' introduces a globally-available method 'file' into your code. Therefore, the attribute in the blueprint-DSL is not seen as attribute, but as a call to Object#file:
Drive::FileShare.blueprint do
file
end
Possibly, a similar error exists in the OP's codebase - either the method last_user might already exist, or some other problem with namespace pollution might exist.
from machinist.
Yep, global methods suck.
You can work around this in the blueprint by doing:
bc. Drive::FileShare.blueprint do
self.file
end
from machinist.
Related Issues (20)
- More of a feature request: switchable associations HOT 3
- Incompatible with presence validation on associated record HOT 3
- Machinist2 and dirty tracking HOT 1
- Allow "make" to take a block
- rspec issue: no master blueprint defined HOT 3
- Update Machinist Wiki
- 1.0 Maintenance: Object#type Deprecation warning
- Blueprint file not found when using Capybara and spec HOT 3
- calling `make` or `make!` on an association does not set the new object's association to the calling object HOT 4
- Role Model printing: #<Machinist::ActiveRecord::Lathe: HOT 2
- sn method does not work
- When the association being passed to make!, machinist should not instantiate it HOT 1
- Problem with models that use FriendlyID HOT 1
- Association named 'test' raise the error "wrong number of arguments (given 0, expected 2..3)"
- Allow me to push to Machinist on Rubygems
- Feature request: post processing after object is initialized HOT 1
- Installation problem HOT 1
- Blueprint for has_one associations HOT 7
- Admin::User.blueprint doesn't work HOT 3
- Machinist make! generate a model that raise ActiveRecord::RecordNotFound on reload HOT 1
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 machinist.