Sha256: f5bc2fa7d282315544e2f279a3f642f76e834886fe41a44d08e48228dc54355c

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

module Siesta
  class TestSuite
    class Group
      include ::Virtus

      attribute :path, String
      attribute :suite, TestSuite

      def name
        @name ||= path.gsub(suite.path, '')

        @name.blank? ? 'global' : @name
      end

      def items
        @items ||= Dir.glob(File.join(path, '*.t.js')).inject([]) do |c, f|
          c << Item.new(path: f, group: self, suite: suite) unless File.directory?(f)
          
          c
        end        
      end
    end

    class Item
      include ::Virtus

      attribute :path, String
      attribute :group, Group
      attribute :suite, TestSuite

      def url
        @url ||= File.join('/assets', path.gsub(suite.path, ''))
      end
    end

    attr_reader :path

    def initialize(path)
      @path = path
    end

    def groups
      @groups ||= Dir.glob(File.join(path, '**', '*')).inject([]) do |c, f|
        c << Group.new(path: f, suite: self) if File.directory?(f)

        c
      end

      @groups << Group.new(path: path, suite: self)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
siesta-0.1.0 lib/siesta/test_suite.rb