Module: Spectie::StoryExampleGroupMethods

Included in:
RailsStoryExampleGroup, SeleniumStoryExampleGroup
Defined in:
lib/spectie/story_example_group_methods.rb

Class Method Summary collapse

Class Method Details

.included(mod) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/spectie/story_example_group_methods.rb', line 4

def self.included(mod)
  mod.class_eval do 
    extend Spec::Example::ExampleGroupMethods
    include Spec::Example::ExampleMethods

    class << self

      def scenario_methods; [:Given, :When, :Then, :And] end

      # Creates a scenario example within a feature (see Spectie::Main#Feature).
      def Scenario(description, options={}, backtrace=nil, &implementation)
        example(description, options, backtrace) do
          instance_eval &implementation
        end
      end

      # Disables a scenario.
      def xScenario(description, options={}, &implementation)
        xexample description, options, &implementation
      end

    end

    scenario_methods.each do |scenario_method|
      method = <<-METHOD
      def #{scenario_method}(statement, *args, &block)
        send statement, *args, &block
      end
      METHOD

      class_eval method, __FILE__, __LINE__
    end

  end
end