guard-busted 0.1.2 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: efc40f8d7f888ff2ddc23151dc349fabd17766fcfebd45c2a11a494090791e09
4
- data.tar.gz: 9c8382d3231ade2e55052b8532f9cd7327ce11153a4a71aa51682ac2e1c15329
3
+ metadata.gz: 663da150a36747b5610a573555b51940b380bf2c4867e709ed6dcc2ff27ca46e
4
+ data.tar.gz: 41297046ef2bf6b2987978106db86bb2ebba199cadf940013c7a3988c40b71b6
5
5
  SHA512:
6
- metadata.gz: 4494e45c2456e976b52db00dd99ec04c22521d1c55c8ef13b6ad289bff33782c8d69465a1f74e0ae93d1701eb8d8b297346c6a1ba9e19876ba30b152a1f86b8d
7
- data.tar.gz: 6ea5249644f5e71200416e515bc71241d1d48dc112f2d19b294fb1f4dbef73f64e7eb7993d17c611daaad6a169633c55219a238ecc4325c2f9232a45ab8a1426
6
+ metadata.gz: a062066c49f8a82f5071ebbd4d27ceb58defba8c7628640cee20850190ed9ccd67067227fc82f712ebe9fb7904d8176683e0a7653ae121621a3a8bd14abcc420
7
+ data.tar.gz: 24bc5e26aabeda3bfdf74825034467c30be6aeb458bbeb2c1df4c772899a689c46e3d0c80e114d158992574eadd67bdffbf173fff7a84d9ce168fa9ce36b24b8
@@ -0,0 +1,29 @@
1
+ name: RSpec
2
+
3
+ on:
4
+ push:
5
+ branches: [ master, develop ]
6
+ pull_request:
7
+ branches: [ master, develop ]
8
+
9
+ jobs:
10
+ test:
11
+
12
+ runs-on: ubuntu-latest
13
+ strategy:
14
+ matrix:
15
+ ruby-version: ['2.7', '3.0']
16
+
17
+ steps:
18
+ - uses: actions/checkout@v2
19
+ - name: Set up Ruby
20
+ uses: ruby/setup-ruby@v1
21
+ with:
22
+ ruby-version: ${{ matrix.ruby-version }}
23
+ bundler-cache: true
24
+ - name: Run tests
25
+ run: bundle exec rake
26
+ - name: Send test coverage report
27
+ uses: codecov/codecov-action@v2
28
+ with:
29
+ file: ./coverage/coverage.xml
@@ -0,0 +1,22 @@
1
+ name: Rubocop
2
+
3
+ on:
4
+ push:
5
+ branches: [ master, develop ]
6
+ pull_request:
7
+ branches: [ master, develop ]
8
+
9
+ jobs:
10
+ rubocop:
11
+
12
+ runs-on: ubuntu-latest
13
+
14
+ steps:
15
+ - uses: actions/checkout@v2
16
+ - name: Set up Ruby
17
+ uses: ruby/setup-ruby@v1
18
+ with:
19
+ ruby-version: '3.0'
20
+ bundler-cache: true
21
+ - name: Run rubocop
22
+ run: bundle exec rubocop
@@ -0,0 +1,31 @@
1
+ name: Rubygems
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ jobs:
8
+ build:
9
+ name: Build + Publish
10
+ runs-on: ubuntu-latest
11
+ permissions:
12
+ contents: read
13
+ packages: write
14
+
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+ - uses: ruby/setup-ruby@v1
18
+ with:
19
+ ruby-version: '3.0'
20
+
21
+ - name: Publish to RubyGems
22
+ run: |
23
+ mkdir -p $HOME/.gem
24
+ touch $HOME/.gem/credentials
25
+ chmod 0600 $HOME/.gem/credentials
26
+ printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
27
+ gem build *.gemspec
28
+ gem push *.gem
29
+ env:
30
+ GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
31
+
data/.gitignore CHANGED
@@ -1,3 +1,5 @@
1
1
  coverage
2
2
  .rspec_status
3
3
  pkg
4
+ vendor
5
+ .bundle
data/.overcommit.yml ADDED
@@ -0,0 +1,86 @@
1
+ gemfile: '.overcommit_gems.rb'
2
+
3
+ plugin_directory: '.git-hooks'
4
+
5
+ quiet: false
6
+
7
+ concurrency: '%{processors}'
8
+
9
+ verify_signatures: true
10
+
11
+ CommitMsg:
12
+ ALL:
13
+ requires_files: false
14
+ quiet: false
15
+
16
+ CapitalizedSubject:
17
+ enabled: false
18
+
19
+ EmptyMessage:
20
+ enabled: true
21
+ description: 'Check for empty commit message'
22
+
23
+ MessageFormat:
24
+ enabled: true
25
+ description: 'Check commit message matches expected pattern'
26
+ pattern: '\[(((#[0-9]+)(, (#[0-9]+))*)|(v[0-9]+(\.[0-9]+)*))\][ ](.+)(\n\n.+)?'
27
+ expected_pattern_message: '[#<Issue Id>|v<version>] <Commit Message Description>'
28
+ sample_message: '[#403] Fix a bug that crashes the system'
29
+
30
+ SingleLineSubject:
31
+ enabled: true
32
+ description: 'Check subject line'
33
+
34
+ TextWidth:
35
+ enabled: true
36
+ description: 'Check text width'
37
+ max_subject_width: 60
38
+ min_subject_width: 0
39
+ max_body_width: 72
40
+
41
+ TrailingPeriod:
42
+ enabled: true
43
+ description: 'Check for trailing periods in subject'
44
+
45
+ PreCommit:
46
+ ALL:
47
+ problem_on_unmodified_line: report
48
+ requires_files: true
49
+ required: false
50
+ quiet: false
51
+
52
+ RuboCop:
53
+ enabled: true
54
+ on_warn: fail
55
+
56
+ AuthorEmail:
57
+ enabled: true
58
+ description: 'Check author email'
59
+ requires_files: false
60
+ required: true
61
+ pattern: '^[^@]+@.*$'
62
+
63
+ AuthorName:
64
+ enabled: true
65
+ description: 'Check for author name'
66
+ requires_files: false
67
+ required: true
68
+
69
+ BrokenSymlinks:
70
+ enabled: true
71
+ description: 'Check for broken symlinks'
72
+
73
+ CaseConflicts:
74
+ enabled: true
75
+ description: 'Check for case-insensitivity conflicts'
76
+
77
+ FileSize:
78
+ enabled: true
79
+ description: 'Check for oversized files'
80
+ size_limit_bytes: 1_000_000
81
+
82
+ ForbiddenBranches:
83
+ enabled: true
84
+ description: 'Check for commit to forbidden branch'
85
+ quiet: true
86
+ branch_patterns: ['master', 'develop', 'v*']
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gem 'overcommit'
6
+ gem 'rubocop'
7
+ gem 'rubocop-rspec'
@@ -0,0 +1,42 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ ast (2.4.2)
5
+ childprocess (4.1.0)
6
+ iniparse (1.5.0)
7
+ overcommit (0.58.0)
8
+ childprocess (>= 0.6.3, < 5)
9
+ iniparse (~> 1.4)
10
+ rexml (~> 3.2)
11
+ parallel (1.21.0)
12
+ parser (3.1.0.0)
13
+ ast (~> 2.4.1)
14
+ rainbow (3.1.1)
15
+ regexp_parser (2.2.1)
16
+ rexml (3.2.5)
17
+ rubocop (1.25.1)
18
+ parallel (~> 1.10)
19
+ parser (>= 3.1.0.0)
20
+ rainbow (>= 2.2.2, < 4.0)
21
+ regexp_parser (>= 1.8, < 3.0)
22
+ rexml
23
+ rubocop-ast (>= 1.15.1, < 2.0)
24
+ ruby-progressbar (~> 1.7)
25
+ unicode-display_width (>= 1.4.0, < 3.0)
26
+ rubocop-ast (1.15.2)
27
+ parser (>= 3.0.1.1)
28
+ rubocop-rspec (2.8.0)
29
+ rubocop (~> 1.19)
30
+ ruby-progressbar (1.11.0)
31
+ unicode-display_width (2.1.0)
32
+
33
+ PLATFORMS
34
+ x86_64-linux
35
+
36
+ DEPENDENCIES
37
+ overcommit
38
+ rubocop
39
+ rubocop-rspec
40
+
41
+ BUNDLED WITH
42
+ 2.3.4
data/.rubocop.yml CHANGED
@@ -1,4 +1,8 @@
1
+ AllCops:
2
+ NewCops: enable
3
+ Exclude:
4
+ - vendor/bundle/**/*
1
5
  Layout/LineLength:
2
- Max: 100
6
+ Max: 150
3
7
  Metrics/BlockLength:
4
8
  IgnoredMethods: ['describe', 'context', 'shared_examples', 'it', 'before', 'namespace']
data/Gemfile CHANGED
@@ -2,3 +2,14 @@
2
2
 
3
3
  source 'https://rubygems.org'
4
4
  gemspec
5
+
6
+ gem 'amazing_print'
7
+ gem 'guard'
8
+ gem 'guard-rspec'
9
+ gem 'rake'
10
+ gem 'rspec'
11
+ gem 'rubocop'
12
+ gem 'rubocop-rake'
13
+ gem 'rubocop-rspec'
14
+ gem 'simplecov'
15
+ gem 'simplecov-cobertura'
data/Gemfile.lock CHANGED
@@ -1,25 +1,26 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- guard-busted (0.1.2)
5
- guard-compat (~> 1.2)
4
+ guard-busted (1.0.1)
5
+ guard (~> 2.18)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- ast (2.4.1)
10
+ amazing_print (1.4.0)
11
+ ast (2.4.2)
11
12
  coderay (1.1.3)
12
- diff-lcs (1.4.4)
13
- docile (1.3.4)
14
- ffi (1.13.1)
15
- formatador (0.2.5)
16
- guard (2.16.2)
13
+ diff-lcs (1.5.0)
14
+ docile (1.4.0)
15
+ ffi (1.15.5)
16
+ formatador (1.1.0)
17
+ guard (2.18.0)
17
18
  formatador (>= 0.2.4)
18
19
  listen (>= 2.7, < 4.0)
19
20
  lumberjack (>= 1.0.12, < 2.0)
20
21
  nenv (~> 0.1)
21
22
  notiffany (~> 0.0)
22
- pry (>= 0.9.12)
23
+ pry (>= 0.13.0)
23
24
  shellany (~> 0.0)
24
25
  thor (>= 0.18.1)
25
26
  guard-compat (1.2.1)
@@ -27,74 +28,85 @@ GEM
27
28
  guard (~> 2.1)
28
29
  guard-compat (~> 1.1)
29
30
  rspec (>= 2.99.0, < 4.0)
30
- listen (3.2.1)
31
+ listen (3.7.1)
31
32
  rb-fsevent (~> 0.10, >= 0.10.3)
32
33
  rb-inotify (~> 0.9, >= 0.9.10)
33
- lumberjack (1.2.7)
34
+ lumberjack (1.2.8)
34
35
  method_source (1.0.0)
35
36
  nenv (0.3.0)
36
37
  notiffany (0.1.3)
37
38
  nenv (~> 0.1)
38
39
  shellany (~> 0.0)
39
- parallel (1.20.1)
40
- parser (3.0.0.0)
40
+ parallel (1.21.0)
41
+ parser (3.1.0.0)
41
42
  ast (~> 2.4.1)
42
- pry (0.13.1)
43
+ pry (0.14.1)
43
44
  coderay (~> 1.1)
44
45
  method_source (~> 1.0)
45
- rainbow (3.0.0)
46
- rake (12.3.3)
47
- rb-fsevent (0.10.4)
46
+ rainbow (3.1.1)
47
+ rake (13.0.6)
48
+ rb-fsevent (0.11.1)
48
49
  rb-inotify (0.10.1)
49
50
  ffi (~> 1.0)
50
- regexp_parser (2.0.3)
51
- rexml (3.2.4)
52
- rspec (3.10.0)
53
- rspec-core (~> 3.10.0)
54
- rspec-expectations (~> 3.10.0)
55
- rspec-mocks (~> 3.10.0)
56
- rspec-core (3.10.1)
57
- rspec-support (~> 3.10.0)
58
- rspec-expectations (3.10.1)
51
+ regexp_parser (2.2.1)
52
+ rexml (3.2.5)
53
+ rspec (3.11.0)
54
+ rspec-core (~> 3.11.0)
55
+ rspec-expectations (~> 3.11.0)
56
+ rspec-mocks (~> 3.11.0)
57
+ rspec-core (3.11.0)
58
+ rspec-support (~> 3.11.0)
59
+ rspec-expectations (3.11.0)
59
60
  diff-lcs (>= 1.2.0, < 2.0)
60
- rspec-support (~> 3.10.0)
61
- rspec-mocks (3.10.1)
61
+ rspec-support (~> 3.11.0)
62
+ rspec-mocks (3.11.0)
62
63
  diff-lcs (>= 1.2.0, < 2.0)
63
- rspec-support (~> 3.10.0)
64
- rspec-support (3.10.1)
65
- rubocop (1.8.1)
64
+ rspec-support (~> 3.11.0)
65
+ rspec-support (3.11.0)
66
+ rubocop (1.25.1)
66
67
  parallel (~> 1.10)
67
- parser (>= 3.0.0.0)
68
+ parser (>= 3.1.0.0)
68
69
  rainbow (>= 2.2.2, < 4.0)
69
70
  regexp_parser (>= 1.8, < 3.0)
70
71
  rexml
71
- rubocop-ast (>= 1.2.0, < 2.0)
72
+ rubocop-ast (>= 1.15.1, < 2.0)
72
73
  ruby-progressbar (~> 1.7)
73
74
  unicode-display_width (>= 1.4.0, < 3.0)
74
- rubocop-ast (1.4.0)
75
- parser (>= 2.7.1.5)
75
+ rubocop-ast (1.15.2)
76
+ parser (>= 3.0.1.1)
77
+ rubocop-rake (0.6.0)
78
+ rubocop (~> 1.0)
79
+ rubocop-rspec (2.8.0)
80
+ rubocop (~> 1.19)
76
81
  ruby-progressbar (1.11.0)
77
82
  shellany (0.0.1)
78
83
  simplecov (0.21.2)
79
84
  docile (~> 1.1)
80
85
  simplecov-html (~> 0.11)
81
86
  simplecov_json_formatter (~> 0.1)
87
+ simplecov-cobertura (2.1.0)
88
+ rexml
89
+ simplecov (~> 0.19)
82
90
  simplecov-html (0.12.3)
83
- simplecov_json_formatter (0.1.2)
84
- thor (1.0.1)
85
- unicode-display_width (2.0.0)
91
+ simplecov_json_formatter (0.1.3)
92
+ thor (1.2.1)
93
+ unicode-display_width (2.1.0)
86
94
 
87
95
  PLATFORMS
88
- ruby
96
+ x86_64-linux
89
97
 
90
98
  DEPENDENCIES
91
- guard (~> 2.16)
99
+ amazing_print
100
+ guard
92
101
  guard-busted!
93
102
  guard-rspec
94
- rake (~> 12.0)
95
- rspec (~> 3.0)
96
- rubocop (~> 1.8)
97
- simplecov (~> 0.21)
103
+ rake
104
+ rspec
105
+ rubocop
106
+ rubocop-rake
107
+ rubocop-rspec
108
+ simplecov
109
+ simplecov-cobertura
98
110
 
99
111
  BUNDLED WITH
100
- 2.1.4
112
+ 2.3.4
data/Guardfile CHANGED
@@ -1,5 +1,7 @@
1
- guard :rspec, cmd: "bundle exec rspec" do
2
- require "guard/rspec/dsl"
1
+ # frozen_string_literal: true
2
+
3
+ guard :rspec, cmd: 'bundle exec rspec' do
4
+ require 'guard/rspec/dsl'
3
5
  dsl = Guard::RSpec::Dsl.new(self)
4
6
 
5
7
  # RSpec files
data/README.md CHANGED
@@ -1,6 +1,9 @@
1
1
  # Guard::Busted
2
- [![Build Status](https://travis-ci.com/pjezusek/guard-busted.svg?branch=master)](https://travis-ci.com/pjezusek/guard-busted)
3
- [![Gem Version](https://badge.fury.io/rb/guard-busted.svg)](https://badge.fury.io/rb/guard-busted)
2
+
3
+ [![Rubocop](https://github.com/pjezusek/guard-busted/actions/workflows/rubocop.yml/badge.svg)](https://github.com/pjezusek/guard-busted/actions/workflows/rubocop.yml)
4
+ [![RSpec](https://github.com/pjezusek/guard-busted/actions/workflows/rspec.yml/badge.svg)](https://github.com/pjezusek/guard-busted/actions/workflows/rspec.yml)
5
+ [![codecov](https://codecov.io/gh/pjezusek/guard-busted/branch/master/graph/badge.svg?token=OZYC63B26Y)](https://codecov.io/gh/pjezusek/guard-busted)
6
+ [![Gem Version](https://badge.fury.io/rb/guard-busted.svg)](https://rubygems.org/gems/guard-busted)
4
7
 
5
8
  Guard for the unit testing framework named [busted](http://olivinelabs.com/busted/)
6
9
 
@@ -26,12 +29,15 @@ This command initializes the Guard file.
26
29
  The provided guard template checks all files with `.lua` extension and starts the corresponding test file.
27
30
  It searches test files in `spec` directory with the pattern `spec/<relative_path_to_file>/<file_name>_spec.lua`.
28
31
 
29
- EXAMPLE: lets assume that you have a file in the project `some_dir/some_file.lua`.
32
+ _EXAMPLE:_<br />
33
+ There is some file in the project `some_dir/some_file.lua`.
30
34
  After some change on this file the guard-busted gem will try to perform tests located in: `spec/some_dir/some_file_spec.lua`.
31
35
 
32
- WARNING!: Keep in your mind that it treats `src` dir in the special way.
36
+ _WARNING!:_<br />
37
+ Keep in your mind that it treats `src` dir in the special way.
33
38
  It just does not include `src` in the mentioned pattern.
34
39
 
40
+ The gem also supports desktop notifications.
35
41
 
36
42
  ## Contributing
37
43
 
data/bin/dev ADDED
@@ -0,0 +1,69 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'thor'
5
+ require 'tty-prompt'
6
+ require 'pry'
7
+ require_relative '../lib/guard/busted'
8
+
9
+ $stdout.sync = true
10
+
11
+ # path to the application root
12
+ APP_ROOT = File.expand_path('../', __dir__)
13
+ PROMPT = TTY::Prompt.new
14
+
15
+ # Bunch of commands that are usefull during development
16
+ class Dev < Thor
17
+ def self.exit_on_failure?
18
+ true
19
+ end
20
+
21
+ desc 'autofix', 'Run rubocop autofix'
22
+ def autofix
23
+ Dir.chdir APP_ROOT do
24
+ PROMPT.say 'Running autofix', color: :blue
25
+ system("rubocop -A #{APP_ROOT}", out: $stdout, err: :out)
26
+ end
27
+ end
28
+
29
+ desc 'console', 'Start console'
30
+ def console
31
+ Dir.chdir APP_ROOT do
32
+ Pry.start
33
+ end
34
+ end
35
+
36
+ desc 'guard', 'Start guard'
37
+ def guard
38
+ Dir.chdir APP_ROOT do
39
+ PROMPT.say 'Starting guard', color: :blue
40
+ system('bundle exec guard', out: $stdout, err: :out)
41
+ end
42
+ end
43
+
44
+ desc 'rubocop', 'Run rubocop'
45
+ def rubocop
46
+ Dir.chdir APP_ROOT do
47
+ PROMPT.say 'Running rubocop', color: :blue
48
+ system('rubocop', out: $stdout, err: :out)
49
+ end
50
+ end
51
+
52
+ desc 'rspec', 'Run rspec'
53
+ def rspec
54
+ Dir.chdir APP_ROOT do
55
+ PROMPT.say 'Starting rspec', color: :blue
56
+ system('rspec', out: $stdout, err: :out)
57
+ end
58
+ end
59
+
60
+ desc 'yard', 'Serve configuration via server'
61
+ def yard
62
+ Dir.chdir APP_ROOT do
63
+ PROMPT.say 'Starting yard server', color: :blue
64
+ system('yard server --reload', out: $stdout, err: :out)
65
+ end
66
+ end
67
+ end
68
+
69
+ Dev.start
data/bin/setup ADDED
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ # Go to project root dir
7
+ cd $(git rev-parse --show-toplevel 2>/dev/null)
8
+
9
+ # Install development dependencies
10
+ bundle install
11
+
12
+ # Instal overcommit dependencies
13
+ bundle install --gemfile=.overcommit_gems.rb
14
+
15
+ # Install git hooks
16
+ overcommit --install
17
+
18
+ # Sign git hooks
19
+ overcommit --sign
data/guard-busted.gemspec CHANGED
@@ -17,21 +17,13 @@ Gem::Specification.new do |spec|
17
17
  spec.metadata['homepage_uri'] = spec.homepage
18
18
  spec.metadata['source_code_uri'] = 'https://github.com/pjezusek/guard-busted.git'
19
19
  spec.metadata['changelog_uri'] = 'https://github.com/pjezusek/guard-busted/blob/master/CHANGELOG.md'
20
+ spec.metadata['rubygems_mfa_required'] = 'true'
20
21
 
21
22
  spec.files = Dir.chdir(File.expand_path(__dir__)) do
22
23
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
23
24
  end
24
25
 
25
- spec.test_files = spec.files.grep(%r{^spec/})
26
26
  spec.require_paths = ['lib']
27
27
 
28
- spec.add_dependency 'guard-compat', '~> 1.2'
29
-
30
-
31
- spec.add_development_dependency 'guard', '~> 2.16'
32
- spec.add_development_dependency 'guard-rspec'
33
- spec.add_development_dependency 'rake', '~> 12.0'
34
- spec.add_development_dependency 'rspec', '~> 3.0'
35
- spec.add_development_dependency 'rubocop', '~> 1.8'
36
- spec.add_development_dependency 'simplecov', '~> 0.21'
28
+ spec.add_dependency 'guard', '~> 2.18'
37
29
  end
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'guard/notifier'
4
+
5
+ module Guard
6
+ # Wrapper for Guard::Notifier to make system notifications
7
+ class BustedNotifier
8
+ attr_accessor :raw_message, :status
9
+
10
+ FAILURE_TITLE = 'Busted - Failure'
11
+ SUCCESS_TITLE = 'Busted - Success'
12
+
13
+ # Initialize BustedNotifier
14
+ #
15
+ # @param message [String] message to parse, output from busted command
16
+ # @param status [Boolean] status of busted command
17
+ def initialize(message, status)
18
+ @raw_message = message
19
+ @status = status
20
+ end
21
+
22
+ # Send notification to the system
23
+ #
24
+ # The type of the notification depends on the status of busted command.
25
+ def notify
26
+ if status
27
+ notify_success
28
+ else
29
+ notify_failure
30
+ end
31
+ end
32
+
33
+ private
34
+
35
+ # Parse +raw_message+ to extract summary for a notification
36
+ # For now it only supports utfTerminal output
37
+ #
38
+ # @return [String]
39
+ def summary
40
+ @raw_message.match(/^.*success.*$/)
41
+ .to_s
42
+ .gsub(/[[:cntrl:]]/, '')
43
+ .gsub(/\[[0-9]+m/, '')
44
+ .gsub(/ : [0-9]+\.[0-9]+ seconds/, '')
45
+ end
46
+
47
+ # Notify with failure
48
+ def notify_failure
49
+ Guard::Notifier.notify(
50
+ summary,
51
+ title: FAILURE_TITLE,
52
+ image: :failed,
53
+ priority: 2
54
+ )
55
+ end
56
+
57
+ # Notify with success
58
+ def notify_success
59
+ Guard::Notifier.notify(
60
+ summary,
61
+ title: SUCCESS_TITLE,
62
+ image: :success,
63
+ priority: -2
64
+ )
65
+ end
66
+ end
67
+ end
@@ -5,9 +5,9 @@ module Guard
5
5
  DEFAULTS = {
6
6
  run_all_on_start: false,
7
7
  cmd: 'busted',
8
- cmd_options: [],
8
+ cmd_options: ['-o', 'utfTerminal', '--Xoutput', '--color'],
9
9
  cmd_all: 'busted',
10
- cmd_all_options: []
10
+ cmd_all_options: ['-o', 'utfTerminal', '--Xoutput', '--color']
11
11
  }.freeze
12
12
  end
13
13
  end
@@ -1,48 +1,78 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'guard/ui'
4
+
5
+ require_relative 'notifier'
6
+
3
7
  module Guard
4
8
  # The class responsible for running 'busted' command in the proper context.
5
9
  class BustedRunner < Plugin
6
- attr_accessor :options, :cmd, :cmd_options, :cmd_all, :cmd_all_options
10
+ attr_accessor :cmd, :cmd_options, :cmd_all, :cmd_all_options
7
11
 
12
+ # Initialize BustedRunner
13
+ # It accepts following options:
14
+ # - cmd - command to perform for specific spec files,
15
+ # - cmd_options [Array<String>] - options for cmd command,
16
+ # - cmd_all - command to perform for all spec files
17
+ # - cmd_all_options [Array<String>] - options for cmd_all command.
18
+ #
19
+ # @param options [Hash<Symbol, String>] options for runner
8
20
  def initialize(options)
9
21
  super
10
22
 
11
23
  @cmd = options[:cmd]
12
- @cmd_options = options[:cmd_options]
24
+ @cmd_options = Array(options[:cmd_options])
13
25
  @cmd_all = options[:cmd_all]
14
- @cmd_all_options = options[:cmd_all_options]
26
+ @cmd_all_options = Array(options[:cmd_all_options])
15
27
  end
16
28
 
17
29
  # Run all tests in the project
18
30
  #
19
31
  # @raise [:task_has_failed] when run_all has failed
20
32
  def run_all
21
- puts 'Running all tests'
22
- status = system(command_all)
33
+ UI.info 'Running all tests'
34
+ status, stdout = perform_command([@cmd_all] + @cmd_all_options)
35
+ Guard::BustedNotifier.new(stdout, status).notify
23
36
  throw(:task_has_failed) unless status
24
37
  end
25
38
 
39
+ # Run tests for the given paths
40
+ #
41
+ # @param paths [Array<String>] array of spec files
42
+ #
43
+ # @raise [:task_has_failed] when tests failed
26
44
  def run(paths)
27
- puts "Running #{paths.join(', ')}"
28
- results = paths.map do |path|
29
- if Pathname.new(path).exist?
30
- system([command, path].join(' '))
31
- else
32
- true
33
- end
34
- end
35
- throw(:task_has_failed) if results.any? { |x| x == false }
45
+ existing_paths = paths.select { |p| Pathname.new(p).exist? }
46
+
47
+ return if existing_paths.empty?
48
+
49
+ UI.info "Running #{existing_paths.join(', ')}"
50
+ status, stdout = perform_command([@cmd] + @cmd_options + existing_paths)
51
+ Guard::BustedNotifier.new(stdout, status).notify
52
+ throw(:task_has_failed) unless status
36
53
  end
37
54
 
38
55
  private
39
56
 
40
- def command
41
- [options[:cmd], *options[:cmd_options]].join(' ')
42
- end
57
+ # Performs command and print stdout and stderr to the console
58
+ #
59
+ # @param cmd [Array<String>] command to perform
60
+ #
61
+ # @return [Array<Boolean, String>]
62
+ def perform_command(cmd)
63
+ message = ''
64
+ status = 0
65
+ Open3.popen2e(*cmd) do |_, stdout_and_stderr, wait_thr|
66
+ # :nocov:
67
+ while (line = stdout_and_stderr.gets)
68
+ message += line
69
+ puts line
70
+ end
71
+ status = wait_thr.value.success?
72
+ # :nocov:
73
+ end
43
74
 
44
- def command_all
45
- [options[:cmd_all], *options[:cmd_all_options]].join(' ')
75
+ [status, message]
46
76
  end
47
77
  end
48
78
  end
@@ -3,5 +3,5 @@
3
3
  guard :busted do
4
4
  watch(%r{^spec/.*\.lua$})
5
5
  watch(%r{^src/(.*)\.lua$}) { |m| "spec/#{m[1]}_spec.lua" }
6
- watch(%r{^(?!src)(.*)\.lua$}) { |m| "spec/#{m[1]}_spec.lua" }
6
+ watch(/^(?!src)(.*)\.lua$/) { |m| "spec/#{m[1]}_spec.lua" }
7
7
  end
@@ -1,7 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # :nocov:
3
4
  module Guard
4
5
  module BustedVersion
5
- VERSION = '0.1.2'
6
+ VERSION = '1.0.1'
6
7
  end
7
8
  end
9
+ # :nocov:
data/lib/guard/busted.rb CHANGED
@@ -1,10 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'guard/compat/plugin'
3
+ require 'guard/plugin'
4
+ require 'guard/ui'
4
5
 
5
- require 'guard/busted/options'
6
- require 'guard/busted/runner'
7
- require 'guard/busted/utils'
6
+ require_relative 'busted/options'
7
+ require_relative 'busted/runner'
8
+ require_relative 'busted/utils'
8
9
 
9
10
  module Guard
10
11
  # Plugin for 'guard' which starts 'busted' (lua unit testing framework) if a change is detected.
@@ -39,10 +40,13 @@ module Guard
39
40
  private
40
41
 
41
42
  def check_if_busted_exist
43
+ # :nocov:
42
44
  return unless which('busted').nil?
43
45
 
44
- puts 'Busted not found. Use :cmd option or ' \
45
- 'install `busted` via `luarocks install busted --local`'
46
+ # :nocov:
47
+
48
+ UI.error 'Busted not found. Use :cmd option or ' \
49
+ 'install `busted` via `luarocks install busted --local`'
46
50
  end
47
51
  end
48
52
  end
metadata CHANGED
@@ -1,113 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard-busted
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Jezusek
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-07 00:00:00.000000000 Z
11
+ date: 2024-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: guard-compat
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.2'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.2'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: guard
29
15
  requirement: !ruby/object:Gem::Requirement
30
16
  requirements:
31
17
  - - "~>"
32
18
  - !ruby/object:Gem::Version
33
- version: '2.16'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '2.16'
41
- - !ruby/object:Gem::Dependency
42
- name: guard-rspec
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: rake
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '12.0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '12.0'
69
- - !ruby/object:Gem::Dependency
70
- name: rspec
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '3.0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '3.0'
83
- - !ruby/object:Gem::Dependency
84
- name: rubocop
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: '1.8'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: '1.8'
97
- - !ruby/object:Gem::Dependency
98
- name: simplecov
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - "~>"
102
- - !ruby/object:Gem::Version
103
- version: '0.21'
104
- type: :development
19
+ version: '2.18'
20
+ type: :runtime
105
21
  prerelease: false
106
22
  version_requirements: !ruby/object:Gem::Requirement
107
23
  requirements:
108
24
  - - "~>"
109
25
  - !ruby/object:Gem::Version
110
- version: '0.21'
26
+ version: '2.18'
111
27
  description: Guard::Busted automatically run your specs
112
28
  email:
113
29
  - piotr.jezusek@softbeam.pl
@@ -115,10 +31,15 @@ executables: []
115
31
  extensions: []
116
32
  extra_rdoc_files: []
117
33
  files:
34
+ - ".github/workflows/rspec.yml"
35
+ - ".github/workflows/rubocop.yml"
36
+ - ".github/workflows/rubygems.yml"
118
37
  - ".gitignore"
38
+ - ".overcommit.yml"
39
+ - ".overcommit_gems.rb"
40
+ - ".overcommit_gems.rb.lock"
119
41
  - ".rspec"
120
42
  - ".rubocop.yml"
121
- - ".travis.yml"
122
43
  - CHANGELOG.md
123
44
  - Gemfile
124
45
  - Gemfile.lock
@@ -126,8 +47,11 @@ files:
126
47
  - LICENSE.txt
127
48
  - README.md
128
49
  - Rakefile
50
+ - bin/dev
51
+ - bin/setup
129
52
  - guard-busted.gemspec
130
53
  - lib/guard/busted.rb
54
+ - lib/guard/busted/notifier.rb
131
55
  - lib/guard/busted/options.rb
132
56
  - lib/guard/busted/runner.rb
133
57
  - lib/guard/busted/templates/Guardfile
@@ -140,6 +64,7 @@ metadata:
140
64
  homepage_uri: https://github.com/pjezusek/guard-busted.git
141
65
  source_code_uri: https://github.com/pjezusek/guard-busted.git
142
66
  changelog_uri: https://github.com/pjezusek/guard-busted/blob/master/CHANGELOG.md
67
+ rubygems_mfa_required: 'true'
143
68
  post_install_message:
144
69
  rdoc_options: []
145
70
  require_paths:
@@ -155,7 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
155
80
  - !ruby/object:Gem::Version
156
81
  version: '0'
157
82
  requirements: []
158
- rubygems_version: 3.0.8
83
+ rubygems_version: 3.2.33
159
84
  signing_key:
160
85
  specification_version: 4
161
86
  summary: Guard gem for busted
data/.travis.yml DELETED
@@ -1,15 +0,0 @@
1
- language: ruby
2
- cache: bundler
3
- rvm:
4
- - 2.7.0
5
- before_install: gem install bundler -v 2.1.4
6
- script: bundle exec rake spec
7
- deploy:
8
- provider: rubygems
9
- api_key:
10
- secure: tWkmZxm7D6fQGK3Shnccss9kXbGvAPFk4xr8fozhcX8xFut9P4+xs6U3iOa/JWWVb04YH5XHSI/i1B5cRMrK5v/xbY4jyJzRHHq9pcrYmnrnazDvpvDk6bb73PSOUZfBiSHxTu2EWk7wWuFIeFt81gQuX1k1tskAgKjXTsuPHCHJILlWP1HKpvIIoERffhWBAy8cDvURG64C8gaykTEj5rfHfdluA+PFZjum30vmkm8G48LuxprlmjYUDBIViXL/YZD+2AkRFeWSQOD7IB/34vFwnrZtw6mel42kU2zxdPOvW8JSLGNXExQyIr0krFsvgPq4TUkBqpkpHMOdDX4curSAEc+b2FROtYLwTY9MCnanQ4/KAbLxFiEuZlffPNm1g4EsfYA9B8e1xGkjJm9sLkIkKv+uztEq4p+x8DAe99y6lm+kTb36/IBFaeucCi5JjUWsGlGdQE2VrVfNcNTDhMXmUC8FEwiM1oOJYSDkjB0tpkU9VCIgLbrpFK8Nk8ByxO+5V2myvPfpWyN4sG3d1BIgKMJdOGlqI9ECHa9S64TLexGa9HZcBaYHXeYrUEMmPVcVNAdkU1WwcqvBAKq7so31zwAKoASMdKYV7xp8gZj+VIefwO74NaA7D2j31OuzMZUrl1QEZxsYXLsUWOTbrSFW+sMBaL8vtKK6Q2u+jNQ=
11
- gem: guard-busted
12
- on:
13
- tags: true
14
- repo: pjezusek/guard-busted
15
- skip_cleanup: 'true'