Class: Xing::Tasks::Spec

Inherits:
Tasklib
  • Object
show all
Defined in:
lib/xing/tasks/spec.rb

Instance Method Summary collapse

Methods inherited from Tasklib

#edict_task

Instance Method Details

#defineObject



10
11
12
13
14
15
16
17
18
19
20
21
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/xing/tasks/spec.rb', line 10

def define
  in_namespace do
    edict_task :grunt_ci_test, Edicts::CleanRun do |gct|
      gct.dir = "frontend"
      gct.env_hash = {'CUSTOM_CONFIG_DIR' => config_dir}
      gct.shell_cmd = %w{bundle exec node_modules/.bin/grunt ci-test}
    end
    task :grunt_ci_test => ['build:frontend:all' ]

    namespace :links do
      %w{index.html assets fonts}.each do |thing|
        edict_task thing, Edict::Command do |l|
          l.command = ["ln", "-sfn", "../../frontend/bin/#{thing}", "backend/public/#{thing}"]
        end
      end
    end

    edict_task :prepare_db, Edicts::CleanRun do |pd|
      pd.dir = "backend"
      pd.shell_cmd = %w{bundle exec rake db:test:prepare}
    end

    full_spec_edict = Edicts::CleanRun.new do |eddie|
      copy_settings_to(eddie)
      eddie.dir = "backend"
      eddie.shell_cmd = %w{bundle exec rspec}
    end
    task :full, [:spec_files] => [:check_dependencies, 'frontend:code_structure', :grunt_ci_test, 'backend:setup', :prepare_db] do |_task, args|
      if args[:spec_files]
        full_spec_edict.shell_cmd.push(args[:spec_files])
      end
      full_spec_edict.enact
    end

    desc "Run all feature specs, repeating with each browser width as default"
    responsivity_edict = Edicts::CleanRun.new do |eddie|
      copy_settings_to(eddie)
      eddie.dir = "backend"
    end
    task :responsivity, [:spec_files] => ['backend:setup', :prepare_db] do |_task, args|
      %w{mobile small medium desktop}.each do |size|
        responsivity_edict.shell_cmd = ["bundle", "exec", "rspec", "-o", "tmp/rspec_#{size}.txt"]
        responsivity_edict.env_hash = {'BROWSER_SIZE' => size}
        if args[:spec_files]
          responsivity_edict.shell_cmd.push(args[:spec_files])
        else
          responsivity_edict.shell_cmd.push('spec/features')
        end
        responsivity_edict.enact rescue true
      end
    end

    fast_edict = Edicts::CleanRun.new do |eddie|
      copy_settings_to(eddie)
      eddie.dir = "backend"
      eddie.shell_cmd = %w{bundle exec rspec}
    end
    task :fast, [:spec_files] => ['backend:setup', :prepare_db] do |_task, args|
      if args[:spec_files]
        fast_edict.shell_cmd.push(args[:spec_files])
      else
        fast_edict.shell_cmd.push("--tag").push("~type:feature")
      end
      fast_edict.enact
    end
  end
end