Sha256: e98d80f4b09dfbef440a82cec9dbaea0e912bd95549819e73b5eba922019b8ec

Contents?: true

Size: 1.05 KB

Versions: 2

Compression:

Stored size: 1.05 KB

Contents

module Spectie

  module StoryExampleGroupMethods
    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
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
spectie-0.0.4 lib/spectie/story_example_group_methods.rb
spectie-0.0.3 lib/spectie/story_example_group_methods.rb