Module: Lanes::GuardTasks

Defined in:
lib/lanes/guard_tasks.rb

Defined Under Namespace

Classes: CustomMatchers

Class Method Summary collapse

Class Method Details

.run(dsl, options) {|matchers| ... } ⇒ Object

Yields:

  • (matchers)


26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/lanes/guard_tasks.rb', line 26

def self.run(dsl, options, &block)
    app_name = options[:name] || Pathname.getwd.basename.to_s
    matchers = CustomMatchers.new
    yield matchers

    jasmine_options = options.merge({
       port: 8888, server_mount: '/spec',
       server_env: 'development',
       server: :puma, spec_dir: "spec/#{app_name}",
       console: :always, debug: false
    })


    minitest_options = {
      all_on_start: true, test_folders: 'spec/server'
    }
    coffee_files = %r{^client/(.+?)\.(js|coffee|cjsx)$}

    dsl.guard :hot_reload, port: jasmine_options[:port] do
        dsl.watch(coffee_files)
        dsl.watch(%r{\.scss$})
        matchers.hot_reload.call if matchers.hot_reload
    end

    dsl.guard :jasmine, jasmine_options do
        dsl.watch(coffee_files){ |m| "spec/#{m[0]}Spec.#{m[2]}" }
        dsl.watch(%r{^spec/.*(?:_s|S)pec\.(?:js|coffee|cjsx)$}){|m| p m; m}
        matchers.client_matches.call if matchers.client_matches
    end

    dsl.guard :minitest, minitest_options do
        dsl.watch(%r{^spec/server/spec_helper\.rb}) { 'test' }
        dsl.watch(%r{^spec/server/.*_spec\.rb})
        dsl.watch(%r{^spec/fixtures/#{app_name}/(.+)s\.yml})   { |m| "spec/server/#{m[1]}_spec.rb" }
        dsl.watch(%r{^lib/#{app_name}/(.+)\.rb})               { |m| "spec/server/#{m[1]}_spec.rb" }
        matchers.server_matches.call if matchers.server_matches
    end

end