class Shaf::Spec::Fixture

Attributes

name[R]

Public Class Methods

define(name, &block) click to toggle source
# File lib/shaf/spec/fixture.rb, line 12
def self.define(name, &block)
  return unless block_given?
  Fixtures.fixture_defined new(name.to_sym, block)
end
new(name, block) click to toggle source
# File lib/shaf/spec/fixture.rb, line 17
def initialize(name, block)
  @name = name
  @block = block
end

Public Instance Methods

add_entry(entry_name, resrc = nil, &block) click to toggle source
# File lib/shaf/spec/fixture.rb, line 27
def add_entry(entry_name, resrc = nil, &block)
  value = block ? instance_exec(&block) : resrc
  fixtures = send(name)
  fixtures[entry_name] = value
end
init() click to toggle source
# File lib/shaf/spec/fixture.rb, line 22
def init
  instance_exec(&@block)
  self
end

Private Instance Methods

method_missing(method, *args, &block) click to toggle source
Calls superclass method
# File lib/shaf/spec/fixture.rb, line 35
def method_missing(method, *args, &block)
  return super unless resource_name?(args.size, block_given?)
  add_entry(method, args.first, &block)
end
nested_fixture?(*args) click to toggle source
# File lib/shaf/spec/fixture.rb, line 44
def nested_fixture?(*args)
  args.size == 1 && args.first.is_a?(Symbol)
end
resource_name?(arg_count, block_given) click to toggle source
# File lib/shaf/spec/fixture.rb, line 48
def resource_name?(arg_count, block_given)
  arg_count += 1 if block_given
  arg_count == 1
end
respond_to_missing?(*) click to toggle source
# File lib/shaf/spec/fixture.rb, line 40
def respond_to_missing?(*)
  true
end