Sha256: b58b742f2429bbf1cafce088c8ea42b7ecf39d9d2a0696202c7c469082e5a658
Contents?: true
Size: 975 Bytes
Versions: 1
Compression:
Stored size: 975 Bytes
Contents
module Fixtures def self.fixture(name, &block) iv_name = :"@#{name}" define_method(name) do |*args| instance_variable_set(iv_name, instance_exec(*args, &block)) unless instance_variable_defined?(iv_name) instance_variable_get(iv_name) end end def create_env(klass) klass.new.tap do |object| object.extend(BlueprintsBoy::Helper) object.instance_variable_set(:@_blueprint_data, {}) end end def create_blueprint(name, &block) BlueprintsBoy::Blueprint.new(empty_context, name, &block) end fixture :env do create_env(Object) end [1, 2, 3].each do |n| fixture("mock#{n}") { "mock#{n}" } fixture "blueprint#{n}" do |result| result ||= send("mock#{n}") create_blueprint("blueprint#{n}") { result } end end fixture :manager do BlueprintsBoy::Manager.new end fixture :empty_context do BlueprintsBoy::Context.new(ROOT.join('spec/support/empty_file.rb').to_s) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
blueprints_boy-1.0.0 | spec/support/fixtures.rb |