Module: Hippo::GuardTasks

Defined in:
lib/hippo/guard_tasks.rb

Defined Under Namespace

Classes: CustomMatchers

Class Method Summary collapse

Class Method Details

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

Yields:

  • (matchers)

22
23
24
25
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
# File 'lib/hippo/guard_tasks.rb', line 22

def self.run(dsl, options, &block)
    matchers = CustomMatchers.new
    yield matchers
    identifier = ::Hippo::Extensions.controlling.identifier
    config = client_config || ::Hippo::Command::Jest.new.configure.config

    jest_options = options.merge(
        logger: Hippo.logger,
        silent: false,
        jest_cmd: './node_modules/.bin/jest',
        config_file: config.directory.join('jest.config.json')
    )
    dsl.guard :jest, jest_options

    rspec_options = {
        all_on_start: false,
        cmd: 'bundle exec rspec'
    }
    dsl.guard :rspec, rspec_options do
        dsl.watch(%r{^spec/server/spec_helper\.rb}) { 'spec' }
        dsl.watch(%r{^spec/server/.*_spec\.rb})
        dsl.watch(%r{^lib/#{identifier}/(.+)\.rb}) { |m| "spec/server/#{m[1]}_spec.rb" }
        dsl.watch(%r{^spec/fixtures/#{identifier}(.+)s\.yml}) { |m| "spec/server/#{m[1]}_spec.rb" }
        matchers.server_matches.call if matchers.server_matches
    end

    dsl.guard :reloadable_sinatra do
        dsl.watch(%r{^lib/.*\.rb})
        dsl.watch(%r{^config/.*})
    end
end