Sha256: 72bf90f4ded9b617d3f71142952e26b464a0bfe0daeecfa5da86bae356c8ae43

Contents?: true

Size: 1.46 KB

Versions: 4

Compression:

Stored size: 1.46 KB

Contents

module RailsEdgeTest
  class Configuration
    attr_accessor :elm_path, :edge_root_path, :printer

    def initialize
      self.elm_path = Rails.root.join('spec')
      self.edge_root_path = Rails.root.join('spec', 'edge')
      self.printer = Printers::Boring
      @before_suite_blocks = []
      @before_each_blocks = []
      @after_each_blocks = []
    end

    # Provide any Module here with methods you would like to be able to
    # access from within an `edge` block.
    # @param [Module] mod - a module to be included into all `edge` blocks
    def include(mod)
      Dsl::Controller.include(mod)
      Dsl::Edge.include(mod)
    end

    # Provide a block to be executed once before running any `edge` blocks
    def before_suite(&block)
      @before_suite_blocks << block
    end

    # Provide a block to be executed before running each `edge` block
    def before_each(&block)
      @before_each_blocks << block
    end

    # Provide a block to be executed after running each `edge` block
    def after_each(&block)
      @after_each_blocks << block
    end

    def wrap_suite_execution(&block)
      @before_suite_blocks.each do |before_suit_block|
        before_suit_block.call
      end

      block.call
    end

    def wrap_edge_execution(&edge)
      @before_each_blocks.each do |before_each_block|
        before_each_block.call
      end

      edge.call

      @after_each_blocks.each do |after_each_block|
        after_each_block.call
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rails_edge_test-2.1.0 lib/rails_edge_test/configuration.rb
rails_edge_test-2.0.0 lib/rails_edge_test/configuration.rb
rails_edge_test-1.2.3 lib/rails_edge_test/configuration.rb
rails_edge_test-1.2.2 lib/rails_edge_test/configuration.rb