Sha256: e6c3d30dab5e3c6684acd0d6849efd9f51772ced3be116f5e071c41b6e7b98ce

Contents?: true

Size: 1.44 KB

Versions: 1

Compression:

Stored size: 1.44 KB

Contents

module RailsEdgeTest
  module Dsl
    def controller(controller_class, &block)
      controller = RailsEdgeTest::Dsl::Controller.new(controller_class)
      controller.instance_exec(&block)
      Dsl.add(controller)
    end

    class << self
      def reset!
        @controllers = []
      end

      def execute!
        printer = RailsEdgeTest.configuration.printer.new
        printer.begin_suite

        RailsEdgeTest.configuration.wrap_suite_execution do

          @controllers.each do |controller|
            printer.begin_controller(controller)

            controller.__actions.each do |action|
              printer.begin_action(action)

              action.__edges.each do |edge, block|
                printer.begin_edge(edge)

                RailsEdgeTest.configuration.wrap_edge_execution do
                  define_lets(edge, action.__let_handler)
                  edge.instance_exec(&block)
                end

                printer.end_edge
              end

              printer.end_action
            end

            printer.end_controller
          end

        end
        printer.end_suite
      end

      def add(controller)
        @controllers << controller
      end

      private
      def define_lets(edge, lets_handler)
        lets_handler.let_blocks.each do |title, block|
          edge.define_singleton_method(title) do
            @let_cache[title] ||= instance_eval(&block)
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails_edge_test-0.3.0 lib/rails_edge_test/dsl.rb