guard-busted 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 4234c6a0bf70c519746dd6060f5ca1801c965f192e4817e3d95a6bfd06e9c5dd
4
+ data.tar.gz: 7dea89565a0f0aca4bb8f0ae10cf76bab974a47e3019103fd1bce0ad0d35abaa
5
+ SHA512:
6
+ metadata.gz: 0fdaa9e522a9b1dbe6d60ea6d76215ceccdc1c58988c41bcd6a29304b1875b8b1f40a19909a559142728cac374f9fadd60932c44fa2c5419bb48a565517a5f6a
7
+ data.tar.gz: 5c4943f8860349b35dbdaeb7a3b3f64be158403185b246139f9c7d856f2cfc080c6c3ac0f85e0b34b689b369730860fa9f88cf5b32f037bcadd43c4a947b4f4d
@@ -0,0 +1,3 @@
1
+ coverage
2
+ .rspec_status
3
+ pkg
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,4 @@
1
+ Layout/LineLength:
2
+ Max: 100
3
+ Metrics/BlockLength:
4
+ IgnoredMethods: ['describe', 'context', 'shared_examples', 'it', 'before', 'namespace']
@@ -0,0 +1,15 @@
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: H5ZtTBqEMULfn1ffM8YA5EQULQzrUa61fGQ5dqWrNNHFSBdqSHVqVl9HUJ2BjVpM8VNuQ0o2m4iB/MZ1VcFNGjxedXmfrDH5pyhcvAWkmtbL80R9GFmnLIxMpvxR1P/P5YXEzlhoCkwsxt2cWKcLclQ4BCrzSbzzNbW0B5bct344qOywOvFMVScl4q6UyHEwC3Ev9MlKuHo/mIFAo2TLm6VkwsCl6hL4GmKYa1DJNuAYh5pcWtdlouUOyLXk4PYYR6Kqr+bc93XXVDc/rwoxpjl6NLp4shz09amugcjLKzfdhhVwlOBINTdMq7frsfaLK6yAKv2KyfYUNslL4+Yt9yecGlNJK3zID6Q4VEoza5s1WIEWauHRkym/l10ien4Tog1KYJMP5ZuVTB6n87tbWZNxlxm/q/e1YUvA8stkrQccP+p/icALs4jda4fKxCx/hsDzGuQlQNvH0Ob0XhJUjtbUGmEgk7vErpta4vWzK2Z+NTA1X1o53TBiDybY5hA7N7Q9PAz2FOp0CgrxKgrjDJTUJ1BVZIgYW/HNrLEM0B/snL7OKmfUNgAbnjxT0Nt8aen+g+Cy/3BtBLbxPxslPfKZDMN7X5zECLH6L3gPd5QmZyfIwKMmteqCM8IITuNACJVcFYOdHC7iSQbzdUsd+8mJLwbLEByWRzHRLO0njV0=
11
+ gem: guard-busted
12
+ on:
13
+ tags: true
14
+ repo: pjezusek/guard-busted
15
+ skip_cleanup: 'true'
@@ -0,0 +1,6 @@
1
+ # Changelog
2
+
3
+ ## v0.1.0
4
+
5
+ * Initial release
6
+
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+ gemspec
@@ -0,0 +1,100 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ guard-busted (0.1.1)
5
+ guard-compat (~> 1.2)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ ast (2.4.1)
11
+ 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)
17
+ formatador (>= 0.2.4)
18
+ listen (>= 2.7, < 4.0)
19
+ lumberjack (>= 1.0.12, < 2.0)
20
+ nenv (~> 0.1)
21
+ notiffany (~> 0.0)
22
+ pry (>= 0.9.12)
23
+ shellany (~> 0.0)
24
+ thor (>= 0.18.1)
25
+ guard-compat (1.2.1)
26
+ guard-rspec (4.7.3)
27
+ guard (~> 2.1)
28
+ guard-compat (~> 1.1)
29
+ rspec (>= 2.99.0, < 4.0)
30
+ listen (3.2.1)
31
+ rb-fsevent (~> 0.10, >= 0.10.3)
32
+ rb-inotify (~> 0.9, >= 0.9.10)
33
+ lumberjack (1.2.7)
34
+ method_source (1.0.0)
35
+ nenv (0.3.0)
36
+ notiffany (0.1.3)
37
+ nenv (~> 0.1)
38
+ shellany (~> 0.0)
39
+ parallel (1.20.1)
40
+ parser (3.0.0.0)
41
+ ast (~> 2.4.1)
42
+ pry (0.13.1)
43
+ coderay (~> 1.1)
44
+ method_source (~> 1.0)
45
+ rainbow (3.0.0)
46
+ rake (12.3.3)
47
+ rb-fsevent (0.10.4)
48
+ rb-inotify (0.10.1)
49
+ 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)
59
+ diff-lcs (>= 1.2.0, < 2.0)
60
+ rspec-support (~> 3.10.0)
61
+ rspec-mocks (3.10.1)
62
+ diff-lcs (>= 1.2.0, < 2.0)
63
+ rspec-support (~> 3.10.0)
64
+ rspec-support (3.10.1)
65
+ rubocop (1.8.1)
66
+ parallel (~> 1.10)
67
+ parser (>= 3.0.0.0)
68
+ rainbow (>= 2.2.2, < 4.0)
69
+ regexp_parser (>= 1.8, < 3.0)
70
+ rexml
71
+ rubocop-ast (>= 1.2.0, < 2.0)
72
+ ruby-progressbar (~> 1.7)
73
+ unicode-display_width (>= 1.4.0, < 3.0)
74
+ rubocop-ast (1.4.0)
75
+ parser (>= 2.7.1.5)
76
+ ruby-progressbar (1.11.0)
77
+ shellany (0.0.1)
78
+ simplecov (0.21.2)
79
+ docile (~> 1.1)
80
+ simplecov-html (~> 0.11)
81
+ simplecov_json_formatter (~> 0.1)
82
+ simplecov-html (0.12.3)
83
+ simplecov_json_formatter (0.1.2)
84
+ thor (1.0.1)
85
+ unicode-display_width (2.0.0)
86
+
87
+ PLATFORMS
88
+ ruby
89
+
90
+ DEPENDENCIES
91
+ guard (~> 2.16)
92
+ guard-busted!
93
+ guard-rspec
94
+ rake (~> 12.0)
95
+ rspec (~> 3.0)
96
+ rubocop (~> 1.8)
97
+ simplecov (~> 0.21)
98
+
99
+ BUNDLED WITH
100
+ 2.1.4
@@ -0,0 +1,14 @@
1
+ guard :rspec, cmd: "bundle exec rspec" do
2
+ require "guard/rspec/dsl"
3
+ dsl = Guard::RSpec::Dsl.new(self)
4
+
5
+ # RSpec files
6
+ rspec = dsl.rspec
7
+ watch(rspec.spec_helper) { rspec.spec_dir }
8
+ watch(rspec.spec_support) { rspec.spec_dir }
9
+ watch(rspec.spec_files)
10
+
11
+ # Ruby files
12
+ ruby = dsl.ruby
13
+ dsl.watch_spec_files_for(ruby.lib_files)
14
+ end
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 Piotr Jezusek
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,41 @@
1
+ # Guard::Busted
2
+ [![Build Status](https://travis-ci.com/pjezusek/guard-busted.svg?branch=master)](https://travis-ci.com/pjezusek/guard-busted)
3
+
4
+ Guard for the unit testing framework named [busted](http://olivinelabs.com/busted/)
5
+
6
+ ## Installation
7
+
8
+ First you need to install busted.
9
+
10
+ ```bash
11
+ luarocks install --local busted
12
+ ```
13
+
14
+ Then install this gem using `gem install` command.
15
+
16
+ ```bash
17
+ gem install guard-busted
18
+ ```
19
+
20
+ ## Usage
21
+
22
+ Just type `guard init busted` in the root of your project.
23
+ This command initializes the Guard file.
24
+
25
+ The provided guard template checks all files with `.lua` extension and starts the corresponding test file.
26
+ It searches test files in `spec` directory with pattern `spec/<relative_path_to_file>/<file_name>_spec.lua`.
27
+
28
+ EXAMPLE: you have file in the project `some_dir/some_file.lua`.
29
+ After some change the guard-busted gem will try to perform tests located in: `spec/some_dir/some_file_spec.lua`.
30
+
31
+ WARNING!: Keep in your mind that it treats `src` dir in the special way.
32
+ It just does not include `src` in the mentioned pattern.
33
+
34
+
35
+ ## Contributing
36
+
37
+ Don't hesistate to open an issue or make a pull request.
38
+
39
+ ## License
40
+
41
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/guard/busted/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'guard-busted'
7
+ spec.version = Guard::BustedVersion::VERSION
8
+ spec.authors = ['Piotr Jezusek']
9
+ spec.email = ['piotr.jezusek@softbeam.pl']
10
+
11
+ spec.summary = 'Guard gem for busted'
12
+ spec.description = 'Guard::Busted automatically run your specs'
13
+ spec.homepage = 'https://github.com/pjezusek/guard-busted.git'
14
+ spec.license = 'MIT'
15
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.5.0')
16
+
17
+ spec.metadata['homepage_uri'] = spec.homepage
18
+ spec.metadata['source_code_uri'] = 'https://github.com/pjezusek/guard-busted.git'
19
+ spec.metadata['changelog_uri'] = 'https://github.com/pjezusek/guard-busted/blob/master/CHANGELOG.md'
20
+
21
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
22
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
23
+ end
24
+
25
+ spec.test_files = spec.files.grep(%r{^spec/})
26
+ spec.require_paths = ['lib']
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'
37
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'guard/compat/plugin'
4
+
5
+ require 'guard/busted/options'
6
+ require 'guard/busted/runner'
7
+ require 'guard/busted/utils'
8
+
9
+ module Guard
10
+ # Plugin for 'guard' which starts 'busted' (lua unit testing framework) if a change is detected.
11
+ class Busted < Plugin
12
+ include BustedUtils
13
+ attr_reader :options, :runner
14
+
15
+ # Initializes a Guard plugin.
16
+ def initialize(options = {})
17
+ super
18
+
19
+ @options = Guard::BustedOptions::DEFAULTS.merge(options)
20
+ @runner = Guard::BustedRunner.new(@options)
21
+ end
22
+
23
+ # Called once when Guard starts.
24
+ def start
25
+ check_if_busted_exist
26
+ run_all if @options[:run_all_on_start]
27
+ end
28
+
29
+ # Called when just `enter` is pressed
30
+ def run_all
31
+ @runner.run_all
32
+ end
33
+
34
+ # Called on file(s) modifications that the Guard plugin watches.
35
+ def run_on_modifications(paths)
36
+ @runner.run(paths)
37
+ end
38
+
39
+ private
40
+
41
+ def check_if_busted_exist
42
+ return if which('busted').nil?
43
+
44
+ puts 'Busted not found. Use :cmd option or ' \
45
+ 'install `busted` via `luarocks install busted --local`'
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Guard
4
+ module BustedOptions
5
+ DEFAULTS = {
6
+ run_all_on_start: false,
7
+ cmd: 'busted',
8
+ cmd_options: [],
9
+ cmd_all: 'busted',
10
+ cmd_all_options: []
11
+ }.freeze
12
+ end
13
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Guard
4
+ # The class responsible for running 'busted' command in the proper context.
5
+ class BustedRunner < Plugin
6
+ attr_accessor :options, :cmd, :cmd_options, :cmd_all, :cmd_all_options
7
+
8
+ def initialize(options)
9
+ super
10
+
11
+ @cmd = options[:cmd]
12
+ @cmd_options = options[:cmd_options]
13
+ @cmd_all = options[:cmd_all]
14
+ @cmd_all_options = options[:cmd_all_options]
15
+ end
16
+
17
+ # Run all tests in the project
18
+ #
19
+ # @raise [:task_has_failed] when run_all has failed
20
+ def run_all
21
+ puts 'Running all tests'
22
+ status = system(command_all)
23
+ throw(:task_has_failed) unless status
24
+ end
25
+
26
+ 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 }
36
+ end
37
+
38
+ private
39
+
40
+ def command
41
+ [options[:cmd], *options[:cmd_options]].join(' ')
42
+ end
43
+
44
+ def command_all
45
+ [options[:cmd_all], *options[:cmd_all_options]].join(' ')
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ guard :busted do
4
+ watch(%r{^spec/.*\.lua$})
5
+ watch(%r{(?!src)^(.*)\.lua$}) { |m| "spec/#{m[1]}_spec.lua" }
6
+ watch(%r{^src/(.*)\.lua$}) { |m| "spec/#{m[1]}_spec.lua" }
7
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Guard
4
+ # General utils for the gem
5
+ module BustedUtils
6
+ # Cross-platform way of finding an executable in the $PATH.
7
+ #
8
+ # which('ruby') #=> /usr/bin/ruby
9
+ # https://stackoverflow.com/a/5471032/4983981
10
+ def which(cmd)
11
+ exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
12
+ ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
13
+ exts.each do |ext|
14
+ exe = File.join(path, "#{cmd}#{ext}")
15
+ return exe if File.executable?(exe) && !File.directory?(exe)
16
+ end
17
+ end
18
+ nil
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Guard
4
+ module BustedVersion
5
+ VERSION = '0.1.1'
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,162 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: guard-busted
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Piotr Jezusek
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-01-28 00:00:00.000000000 Z
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
+ - !ruby/object:Gem::Dependency
28
+ name: guard
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !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
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '0.21'
111
+ description: Guard::Busted automatically run your specs
112
+ email:
113
+ - piotr.jezusek@softbeam.pl
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".gitignore"
119
+ - ".rspec"
120
+ - ".rubocop.yml"
121
+ - ".travis.yml"
122
+ - CHANGELOG.md
123
+ - Gemfile
124
+ - Gemfile.lock
125
+ - Guardfile
126
+ - LICENSE.txt
127
+ - README.md
128
+ - Rakefile
129
+ - guard-busted.gemspec
130
+ - lib/guard/busted.rb
131
+ - lib/guard/busted/options.rb
132
+ - lib/guard/busted/runner.rb
133
+ - lib/guard/busted/templates/Guardfile
134
+ - lib/guard/busted/utils.rb
135
+ - lib/guard/busted/version.rb
136
+ homepage: https://github.com/pjezusek/guard-busted.git
137
+ licenses:
138
+ - MIT
139
+ metadata:
140
+ homepage_uri: https://github.com/pjezusek/guard-busted.git
141
+ source_code_uri: https://github.com/pjezusek/guard-busted.git
142
+ changelog_uri: https://github.com/pjezusek/guard-busted/blob/master/CHANGELOG.md
143
+ post_install_message:
144
+ rdoc_options: []
145
+ require_paths:
146
+ - lib
147
+ required_ruby_version: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - ">="
150
+ - !ruby/object:Gem::Version
151
+ version: 2.5.0
152
+ required_rubygems_version: !ruby/object:Gem::Requirement
153
+ requirements:
154
+ - - ">="
155
+ - !ruby/object:Gem::Version
156
+ version: '0'
157
+ requirements: []
158
+ rubygems_version: 3.1.2
159
+ signing_key:
160
+ specification_version: 4
161
+ summary: Guard gem for busted
162
+ test_files: []