Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # THIS STUFF IS JUST TO MAKE THE ABOVE WORK.
- require 'acts_as_fu'
- require 'fixjour'
- require 'test/unit'
- ##
- # BEGIN SETUP
- build_model(:users) do
- string :name
- end
- build_model(:articles) do
- string :name
- string :body
- boolean :posted, :default => true
- integer :user_id
- belongs_to :user
- end
- # END SETUP
- ##
- # Need this for "scenario builders"
- Fixjour.allow_redundancy!
- # The sauce (it could be cleaner, but whatevz for now)
- def Fixjour.define(object, options={}, &block)
- if builder = options[:from]
- name = builder.is_a?(Symbol) ? builder : Fixjour.send(:name_for, builder)
- Fixjour.define_builder(options[:from], :as => object) do |klass, overrides|
- # klass is NOT to be used in this case
- instance = send("new_#{name}")
- instance_exec(instance, &block)
- overrides.each { |key, val| instance[key] = val }
- instance
- end
- else
- Fixjour.define_builder(object, options) do |klass, overrides|
- instance = klass.new
- instance_exec(instance, &block)
- overrides.each { |key, val| instance[key] = val }
- instance
- end
- end
- end
Add Comment
Please, Sign In to add comment