Sha256: f81174ef53ab0b81817c8729e043601cad6a0f97d82ae62bd623b82c397de230

Contents?: true

Size: 1.12 KB

Versions: 1

Compression:

Stored size: 1.12 KB

Contents

# RSpec's story parser needs to be constructed with a Mediator. The mediator defined in the class
# below simply collects stories and exposes the collection as StoryCapturingMediator#stories.
module PDF
  module Storycards

    class StoryCapturingMediator
  
      def initialize
          @stories = []
      end

      attr_reader :stories
          
      def create_story(title, narrative)
        @stories << Story.new(title, narrative)
      end
  
      def create_scenario(title)
        current_story.add_scenario Scenario.new(title)
      end
  
      def create_given(name)
        current_scenario.add_step Step.new('Given', name)
      end
  
      def create_given_scenario(name)
        current_scenario.add_step Step.new('GivenScenario', name)
      end
  
      def create_when(name)
        current_scenario.add_step Step.new('When', name)
      end
  
      def create_then(name)
        current_scenario.add_step Step.new('Then', name)
      end
  
      private
      def current_story
        @stories.last
      end
  
      def current_scenario
        current_story.current_scenario
      end
    end
  end      
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pdf-storycards-0.1.0 lib/pdf/storycards/story_capturing_mediator.rb