Class: RSpec::ApiGen::Fixture

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec-apigen/fixture.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(description, &block) ⇒ Fixture

def initialize(description, create_proc, destroy_proc = nil)



8
9
10
11
12
13
# File 'lib/rspec-apigen/fixture.rb', line 8

def initialize(description, &block)
  @description = description && ""

  # initialize this instance
  self.instance_eval &block
end

Instance Attribute Details

#create_procObject (readonly)

Returns the value of attribute create_proc.



4
5
6
# File 'lib/rspec-apigen/fixture.rb', line 4

def create_proc
  @create_proc
end

#descriptionObject (readonly)

Returns the value of attribute description.



3
4
5
# File 'lib/rspec-apigen/fixture.rb', line 3

def description
  @description
end

#destroy_procObject (readonly)

Returns the value of attribute destroy_proc.



5
6
7
# File 'lib/rspec-apigen/fixture.rb', line 5

def destroy_proc
  @destroy_proc
end

Instance Method Details

#create(&block) ⇒ Object



15
16
17
# File 'lib/rspec-apigen/fixture.rb', line 15

def create(&block)
  block.nil? ? @create_proc.call : @create_proc = block
end

#destroy(&block) ⇒ Object



19
20
21
# File 'lib/rspec-apigen/fixture.rb', line 19

def destroy(&block)
  block.nil? ? @destroy_proc.call : @destroy_proc = block
end