Class: Spec::Story::Story

Inherits:
Object show all
Defined in:
lib/gems/rspec-1.1.12/lib/spec/story/story.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title, narrative, params = {}, &body) ⇒ Story

Returns a new instance of Story.



6
7
8
9
10
11
# File 'lib/gems/rspec-1.1.12/lib/spec/story/story.rb', line 6

def initialize(title, narrative, params = {}, &body)
  @body = body
  @title = title
  @narrative = narrative
  @params = params
end

Instance Attribute Details

#narrativeObject (readonly)

Returns the value of attribute narrative.



4
5
6
# File 'lib/gems/rspec-1.1.12/lib/spec/story/story.rb', line 4

def narrative
  @narrative
end

#titleObject (readonly)

Returns the value of attribute title.



4
5
6
# File 'lib/gems/rspec-1.1.12/lib/spec/story/story.rb', line 4

def title
  @title
end

Instance Method Details

#[](key) ⇒ Object



13
14
15
# File 'lib/gems/rspec-1.1.12/lib/spec/story/story.rb', line 13

def [](key)
  @params[key]
end

#assign_steps_to(assignee) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/gems/rspec-1.1.12/lib/spec/story/story.rb', line 21

def assign_steps_to(assignee)
  if steps=@params[:steps_for]
    steps = [steps] unless steps.is_a?(Array)
    steps.each do |step|
      if step.is_a?(StepGroup)
        assignee.use(step)
      else
        assignee.use(steps_for(step))
      end
    end
  end
end

#run_in(obj) ⇒ Object



17
18
19
# File 'lib/gems/rspec-1.1.12/lib/spec/story/story.rb', line 17

def run_in(obj)
  obj.instance_eval(&@body)
end

#steps_for(key) ⇒ Object



34
35
36
# File 'lib/gems/rspec-1.1.12/lib/spec/story/story.rb', line 34

def steps_for(key)
  $rspec_story_steps[key]
end