hexx-suit 1.2.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -5
- data/CHANGELOG.md +15 -0
- data/Gemfile +0 -13
- data/README.md +18 -29
- data/ext/mkrf_conf.rb +25 -0
- data/hexx-suit.gemspec +27 -22
- data/lib/hexx/suit/install/Rakefile +8 -3
- data/lib/hexx/suit/version.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- data/spec/support/prepare_settings.rb +14 -0
- data/spec/support/{config/tasks.rb → tasks.rb} +0 -0
- data/spec/tests/bin/install_spec.rb +1 -1
- data/spec/tests/lib/install_spec.rb +1 -1
- data/spec/tests/lib/metrics/metric_fu/cane_spec.rb +1 -1
- data/spec/tests/lib/metrics/metric_fu/churn_spec.rb +1 -1
- data/spec/tests/lib/metrics/metric_fu/flay_spec.rb +1 -1
- data/spec/tests/lib/metrics/metric_fu/reek_spec.rb +1 -1
- data/spec/tests/lib/metrics/metric_fu/roodi_spec.rb +1 -1
- data/spec/tests/lib/metrics/metric_fu/saikuro_spec.rb +1 -1
- data/spec/tests/lib/metrics/metric_fu_spec.rb +1 -1
- data/spec/tests/lib/metrics/rubocop_spec.rb +1 -1
- data/spec/tests/lib/metrics/yardstick_spec.rb +1 -1
- data/spec/tests/tasks/check/display_spec.rb +1 -1
- data/spec/tests/tasks/check/fu/display_spec.rb +1 -1
- data/spec/tests/tasks/check/fu/run_spec.rb +1 -1
- data/spec/tests/tasks/check/fu_spec.rb +1 -1
- data/spec/tests/tasks/check/inch_spec.rb +1 -1
- data/spec/tests/tasks/check/rubocop/display_spec.rb +1 -1
- data/spec/tests/tasks/check/rubocop/run_spec.rb +1 -1
- data/spec/tests/tasks/check/rubocop_spec.rb +1 -1
- data/spec/tests/tasks/check/run_spec.rb +1 -1
- data/spec/tests/tasks/check/yardstick/display_spec.rb +1 -1
- data/spec/tests/tasks/check/yardstick/run_spec.rb +1 -1
- data/spec/tests/tasks/check/yardstick_spec.rb +1 -1
- data/spec/tests/tasks/check_spec.rb +1 -1
- data/spec/tests/tasks/debug_spec.rb +1 -1
- metadata +66 -11
- data/spec/support/config/sandbox.rb +0 -16
- data/spec/support/sandbox/helpers.rb +0 -62
- data/spec/support/sandbox/matchers.rb +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 481491a7c12046b37eacaee45a92e6324595bbaf
|
4
|
+
data.tar.gz: 2930151d97db4fe4013120114b10b4aec75bb151
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5540521b3400b7552438b014e80c7856b4620f4acf52893b8728fe18d74758c059353f9482c9ac1ea19e7387bc342eb08c0a003ebc605b3ac66c6508f48648a1
|
7
|
+
data.tar.gz: b0a4df9e7a6472194f50e1749a55fa1c4305e88ae8659f0490f83dd2a517990ec4cbd370c02464880b7366aca6a6965f6ecfbdc6e9ca9c860b33f728e87298ec
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
Latest Changes
|
2
|
+
==============
|
3
|
+
|
4
|
+
# v2.0.0
|
5
|
+
|
6
|
+
* A support for non-MRI rubies is cancelled.
|
7
|
+
* Dependencies from pry-byebug/pry-debugger are added back again.
|
8
|
+
* Temlates, generated by the `install` CLI task, are updated.
|
9
|
+
|
10
|
+
# v1.0.0
|
11
|
+
|
12
|
+
* Pippi metric removed as incompatible to rubies 1.9.3
|
13
|
+
* 'hexx-rspec' module extracted to separate gem.
|
14
|
+
|
15
|
+
It is now possible using 'hexx-suit' with the `require: false` key.
|
data/Gemfile
CHANGED
@@ -1,16 +1,3 @@
|
|
1
1
|
source "https://rubygems.org"
|
2
2
|
|
3
3
|
gemspec
|
4
|
-
|
5
|
-
platforms :ruby do
|
6
|
-
gem "pry-rescue", "~> 1.4", require: true
|
7
|
-
gem "pry-stack_explorer", "~> 0.4", require: true
|
8
|
-
end
|
9
|
-
|
10
|
-
platforms :mri_19 do
|
11
|
-
gem "pry-debugger", "~> 0.2", require: true
|
12
|
-
end
|
13
|
-
|
14
|
-
platforms :mri_20, :mri_21 do
|
15
|
-
gem "pry-byebug", "~> 3.0", require: true
|
16
|
-
end
|
data/README.md
CHANGED
@@ -18,13 +18,11 @@ It also defines a set of Rake tasks.
|
|
18
18
|
|
19
19
|
## Installation
|
20
20
|
|
21
|
-
Add this
|
21
|
+
Add this lines to your application's Gemfile:
|
22
22
|
|
23
23
|
```ruby
|
24
|
-
group
|
25
|
-
|
26
|
-
gem "hexx-suit", require: false
|
27
|
-
end
|
24
|
+
gem "hexx-rspec", group: %w(test development)
|
25
|
+
gem "hexx-suit", group: :metrics, if RUBY_VERSION == "ruby"
|
28
26
|
```
|
29
27
|
|
30
28
|
Then execute:
|
@@ -39,19 +37,15 @@ And run the task from the application root:
|
|
39
37
|
hexx-suit install
|
40
38
|
```
|
41
39
|
|
42
|
-
|
43
|
-
|
44
|
-
```ruby
|
45
|
-
# spec/spec_helper.rb
|
46
|
-
require "hexx-rspec"
|
40
|
+
You can configure all metrics separately in a corresponding yml files, that are created at `config/metrics` directory. The directory also contains default STYLEGUIDE. Feel free to adapt it to your needs.
|
47
41
|
|
48
|
-
|
49
|
-
Hexx::RSpec.load_metrics_for(self)
|
42
|
+
In a [`.travis.yml`][Travis] it is recommended to exclude metrics from the build with option:
|
50
43
|
|
51
|
-
|
44
|
+
```yaml
|
45
|
+
bundler_args: --without metrics
|
52
46
|
```
|
53
47
|
|
54
|
-
|
48
|
+
[Travis]: http://docs.travis-ci.com/user/languages/ruby/#Dependency-Management
|
55
49
|
|
56
50
|
## Usage
|
57
51
|
|
@@ -71,6 +65,12 @@ This is a simple shortcut for longer syntaxes:
|
|
71
65
|
bundle exec rspec spec
|
72
66
|
```
|
73
67
|
|
68
|
+
You can also check test coverage:
|
69
|
+
|
70
|
+
```
|
71
|
+
rake test:coverage
|
72
|
+
```
|
73
|
+
|
74
74
|
### Debug
|
75
75
|
|
76
76
|
The tasks runs specs wrapped to pry `rescue` command.
|
@@ -121,9 +121,10 @@ The gem loads dependencies from the projects below.
|
|
121
121
|
### Tools for Debugging
|
122
122
|
|
123
123
|
* [pry](https://github.com/pry/pry/wiki) - a Ruby development console and debugging tool.
|
124
|
-
* [pry-byebug](https://github.com/deivid-rodriguez/pry-byebug)
|
125
124
|
* [pry-rescue](https://github.com/ConradIrwin/pry-rescue)
|
126
125
|
* [pry-stack-explorer](https://github.com/pry/pry-stack_explorer)
|
126
|
+
* [pry-byebug](https://github.com/deivid-rodriguez/pry-byebug) for MRI 2.0+
|
127
|
+
* [pry-debugger](https://github.com/nixme/pry-debugger) for MRI 1.9.3
|
127
128
|
|
128
129
|
### Tools for Tasks Authomation
|
129
130
|
|
@@ -133,6 +134,7 @@ The gem loads dependencies from the projects below.
|
|
133
134
|
|
134
135
|
* [rubocop](https://github.com/bbatsov/rubocop) - a Ruby static code analyzer
|
135
136
|
* [metric_fu](https://github.com/metricfu/metric_fu/) - a collection of Ruby code analyzers.
|
137
|
+
* [fasterer](https://github.com/DamirSvrtan/fasterer) - a static code analyzer for suboptimal code.
|
136
138
|
|
137
139
|
### Documentation Tools
|
138
140
|
|
@@ -142,25 +144,12 @@ The gem loads dependencies from the projects below.
|
|
142
144
|
|
143
145
|
## Compatibility
|
144
146
|
|
145
|
-
Tested under
|
146
|
-
|
147
|
-
* MRI 1.9.3+
|
148
|
-
* Rubinius 2+ (1.9 and 2.0 modes)
|
149
|
-
* JRuby 1.7+ (1.9 and 2.0+ modes)
|
147
|
+
Tested under MRI 1.9.3+:
|
150
148
|
|
151
149
|
RSpec 3.0+ used for testing via [hexx-rspec] suit.
|
152
150
|
|
153
151
|
[hexx-rspec]: https://github.com/nepalez/hexx-rspec
|
154
152
|
|
155
|
-
## Latest Changes
|
156
|
-
|
157
|
-
### v1.0.0
|
158
|
-
|
159
|
-
* Pippi metric removed as incompatible to rubies 1.9.3
|
160
|
-
* 'hexx-rspec' module extracted to separate gem.
|
161
|
-
|
162
|
-
It is now possible using 'hexx-suit' with the `require: false` key.
|
163
|
-
|
164
153
|
## Contributing
|
165
154
|
|
166
155
|
* Fork the project.
|
data/ext/mkrf_conf.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "rubygems/command.rb"
|
3
|
+
require "rubygems/dependency_installer.rb"
|
4
|
+
|
5
|
+
begin
|
6
|
+
Gem::Command.build_args = ARGV
|
7
|
+
rescue NoMethodError
|
8
|
+
end
|
9
|
+
|
10
|
+
inst = Gem::DependencyInstaller.new
|
11
|
+
|
12
|
+
begin
|
13
|
+
|
14
|
+
if RUBY_VERSION < "2.0"
|
15
|
+
inst.install "pry-debugger", "~> 0.2"
|
16
|
+
else
|
17
|
+
inst.install "pry-byebug", "~> 3.0"
|
18
|
+
end
|
19
|
+
|
20
|
+
rescue
|
21
|
+
exit(1)
|
22
|
+
end
|
23
|
+
|
24
|
+
filename = File.join(File.dirname(__FILE__), "Rakefile")
|
25
|
+
File.write filename, "task :default\n"
|
data/hexx-suit.gemspec
CHANGED
@@ -1,30 +1,35 @@
|
|
1
1
|
$:.push File.expand_path("../lib", __FILE__)
|
2
2
|
require "hexx/suit/version"
|
3
3
|
|
4
|
-
Gem::Specification.new do |
|
4
|
+
Gem::Specification.new do |gem|
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
6
|
+
gem.name = "hexx-suit"
|
7
|
+
gem.version = Hexx::Suit::VERSION.dup
|
8
|
+
gem.author = "Andrew Kozin"
|
9
|
+
gem.email = "andrew.kozin@gmail.com"
|
10
|
+
gem.homepage = "https://github.com/nepalez/hexx-suit"
|
11
|
+
gem.summary = "Test/development suit."
|
12
|
+
gem.description = "The module collects gems used for development and testing."
|
13
|
+
gem.license = "MIT"
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
15
|
+
gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
16
|
+
gem.executables = ["hexx-suit"]
|
17
|
+
gem.test_files = Dir["spec/**/*", "Rakefile", "Guardfile"]
|
18
|
+
gem.extra_rdoc_files = Dir["LICENSE", "README.md", ".yardopts"]
|
19
|
+
gem.extensions = "ext/mkrf_conf.rb"
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
21
|
+
gem.required_ruby_version = ">= 1.9.3"
|
22
|
+
gem.add_runtime_dependency "fasterer", "~> 0.1"
|
23
|
+
gem.add_runtime_dependency "guard-rspec", "~> 4.3"
|
24
|
+
gem.add_runtime_dependency "hexx-rspec", "~> 0.1"
|
25
|
+
gem.add_runtime_dependency "inch", "~> 0.5"
|
26
|
+
gem.add_runtime_dependency "metric_fu", "~> 4.11"
|
27
|
+
gem.add_runtime_dependency "mutant-rspec", "~> 0.7"
|
28
|
+
gem.add_runtime_dependency "pry-byebug", "~> 3.0" unless RUBY_VERSION < "2.0"
|
29
|
+
gem.add_runtime_dependency "pry-debugger", "~> 0.2" if RUBY_VERSION < "2.0"
|
30
|
+
gem.add_runtime_dependency "pry-rescue", "~> 1.4"
|
31
|
+
gem.add_runtime_dependency "pry-stack_explorer", "~> 0.4"
|
32
|
+
gem.add_runtime_dependency "rubocop", "~> 0.23"
|
33
|
+
gem.add_runtime_dependency "yardstick", "~> 0.9"
|
29
34
|
|
30
35
|
end
|
@@ -10,8 +10,13 @@ end
|
|
10
10
|
Bundler::GemHelper.install_tasks
|
11
11
|
|
12
12
|
# Loads the Hexx::RSpec and its tasks
|
13
|
-
|
14
|
-
|
13
|
+
begin
|
14
|
+
require "hexx-suit"
|
15
|
+
Hexx::Suit.install_tasks
|
16
|
+
rescue LoadError
|
17
|
+
require "hexx-rspec"
|
18
|
+
Hexx::RSpec.install_tasks
|
19
|
+
end
|
15
20
|
|
16
21
|
# Sets the Hexx::RSpec :test task to default
|
17
|
-
task default: :
|
22
|
+
task default: "test:coverage:run"
|
data/lib/hexx/suit/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -0,0 +1,14 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
# Creates settings file in a sandbox
|
4
|
+
#
|
5
|
+
# @param [Hash] settings ({})
|
6
|
+
# The list of settings to be stored in 'sandbox/.metrics.yml'
|
7
|
+
#
|
8
|
+
# @return [undefined]
|
9
|
+
def prepare_settings(settings, file = ".metrics.yml")
|
10
|
+
try_in_sandbox do
|
11
|
+
::FileUtils.mkdir_p ::File.dirname(file)
|
12
|
+
::File.write file, settings.to_yaml
|
13
|
+
end
|
14
|
+
end
|
File without changes
|
@@ -2,7 +2,7 @@
|
|
2
2
|
require "spec_helper"
|
3
3
|
require "metric_fu"
|
4
4
|
|
5
|
-
describe Hexx::Suit::Metrics::MetricFu::Saikuro, :sandbox do
|
5
|
+
describe Hexx::Suit::Metrics::MetricFu::Saikuro, :sandbox, :capture do
|
6
6
|
|
7
7
|
let(:config) do
|
8
8
|
::MetricFu::Configuration.configure_metric(:saikuro) do |metric|
|
@@ -9,7 +9,7 @@ describe "Rake::Task['check:fu:display']", :tasks do
|
|
9
9
|
let(:metric) { Hexx::Suit::Metrics::MetricFu }
|
10
10
|
let(:task) { Rake::Task["check:fu:display"] }
|
11
11
|
|
12
|
-
describe ".invoke", :sandbox do
|
12
|
+
describe ".invoke", :sandbox, :capture do
|
13
13
|
|
14
14
|
let(:subject) { try_in_sandbox { task.invoke } }
|
15
15
|
|
@@ -9,7 +9,7 @@ describe "Rake::Task['check:fu:run']", :tasks do
|
|
9
9
|
let(:metric) { Hexx::Suit::Metrics::MetricFu }
|
10
10
|
let(:task) { Rake::Task["check:fu:run"] }
|
11
11
|
|
12
|
-
describe ".invoke", :sandbox do
|
12
|
+
describe ".invoke", :sandbox, :capture do
|
13
13
|
|
14
14
|
let(:subject) { try_in_sandbox { task.invoke } }
|
15
15
|
|
@@ -9,7 +9,7 @@ describe "Rake::Task['check:yardstick:display']", :tasks do
|
|
9
9
|
let(:metric) { Hexx::Suit::Metrics::Yardstick }
|
10
10
|
let(:task) { Rake::Task["check:yardstick:display"] }
|
11
11
|
|
12
|
-
describe ".invoke", :sandbox do
|
12
|
+
describe ".invoke", :sandbox, :capture do
|
13
13
|
|
14
14
|
subject { try_in_sandbox { task.invoke } }
|
15
15
|
|
@@ -5,7 +5,7 @@ describe "Rake::Task['check:yardstick:run']", :tasks do
|
|
5
5
|
let(:metric) { Hexx::Suit::Metrics::Yardstick }
|
6
6
|
let(:task) { Rake::Task["check:yardstick:run"] }
|
7
7
|
|
8
|
-
describe ".invoke", :sandbox do
|
8
|
+
describe ".invoke", :sandbox, :capture do
|
9
9
|
|
10
10
|
subject { try_in_sandbox { task.invoke } }
|
11
11
|
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hexx-suit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kozin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: fasterer
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.1'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: guard-rspec
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,6 +94,48 @@ dependencies:
|
|
80
94
|
- - "~>"
|
81
95
|
- !ruby/object:Gem::Version
|
82
96
|
version: '0.7'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: pry-byebug
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '3.0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '3.0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: pry-rescue
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '1.4'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '1.4'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: pry-stack_explorer
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0.4'
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0.4'
|
83
139
|
- !ruby/object:Gem::Dependency
|
84
140
|
name: rubocop
|
85
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -112,7 +168,8 @@ description: The module collects gems used for development and testing.
|
|
112
168
|
email: andrew.kozin@gmail.com
|
113
169
|
executables:
|
114
170
|
- hexx-suit
|
115
|
-
extensions:
|
171
|
+
extensions:
|
172
|
+
- ext/mkrf_conf.rb
|
116
173
|
extra_rdoc_files:
|
117
174
|
- LICENSE
|
118
175
|
- README.md
|
@@ -124,6 +181,7 @@ files:
|
|
124
181
|
- ".rubocop.yml"
|
125
182
|
- ".travis.yml"
|
126
183
|
- ".yardopts"
|
184
|
+
- CHANGELOG.md
|
127
185
|
- Gemfile
|
128
186
|
- Guardfile
|
129
187
|
- LICENSE
|
@@ -131,6 +189,7 @@ files:
|
|
131
189
|
- Rakefile
|
132
190
|
- bin/hexx-suit
|
133
191
|
- config/metrics/simplecov.yml
|
192
|
+
- ext/mkrf_conf.rb
|
134
193
|
- hexx-suit.gemspec
|
135
194
|
- lib/hexx-suit.rb
|
136
195
|
- lib/hexx/suit.rb
|
@@ -169,10 +228,8 @@ files:
|
|
169
228
|
- lib/tasks/check/yardstick.rake
|
170
229
|
- lib/tasks/debug.rake
|
171
230
|
- spec/spec_helper.rb
|
172
|
-
- spec/support/
|
173
|
-
- spec/support/
|
174
|
-
- spec/support/sandbox/helpers.rb
|
175
|
-
- spec/support/sandbox/matchers.rb
|
231
|
+
- spec/support/prepare_settings.rb
|
232
|
+
- spec/support/tasks.rb
|
176
233
|
- spec/tests/bin/install_spec.rb
|
177
234
|
- spec/tests/lib/install_spec.rb
|
178
235
|
- spec/tests/lib/metrics/metric_fu/cane_spec.rb
|
@@ -251,10 +308,8 @@ test_files:
|
|
251
308
|
- spec/tests/tasks/check/inch_spec.rb
|
252
309
|
- spec/tests/suit_spec.rb
|
253
310
|
- spec/tests/bin/install_spec.rb
|
254
|
-
- spec/support/
|
255
|
-
- spec/support/
|
256
|
-
- spec/support/sandbox/matchers.rb
|
257
|
-
- spec/support/sandbox/helpers.rb
|
311
|
+
- spec/support/prepare_settings.rb
|
312
|
+
- spec/support/tasks.rb
|
258
313
|
- Rakefile
|
259
314
|
- Guardfile
|
260
315
|
has_rdoc:
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
RSpec.configure do |config|
|
4
|
-
|
5
|
-
# Prepares a sandbox before corresponding spec.
|
6
|
-
config.before :each, :sandbox do
|
7
|
-
require_relative "../sandbox/helpers"
|
8
|
-
require_relative "../sandbox/matchers"
|
9
|
-
prepare_sandbox
|
10
|
-
end
|
11
|
-
|
12
|
-
# Clears a sandbox after corresponding spec.
|
13
|
-
config.after :each, :sandbox do
|
14
|
-
clear_sandbox
|
15
|
-
end
|
16
|
-
end
|
@@ -1,62 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require "yaml"
|
3
|
-
|
4
|
-
# Yields block and captures stdout stream.
|
5
|
-
#
|
6
|
-
# @example
|
7
|
-
# capture_stdout { do_something }
|
8
|
-
#
|
9
|
-
# @return [String] The captured stream.
|
10
|
-
def capture_stdout
|
11
|
-
begin
|
12
|
-
$stdout = StringIO.new
|
13
|
-
yield
|
14
|
-
result = $stdout.string
|
15
|
-
ensure
|
16
|
-
$stdout = STDOUT
|
17
|
-
end
|
18
|
-
result.to_s
|
19
|
-
end
|
20
|
-
|
21
|
-
# Returns the path to the temporary `spec/sandbox`.
|
22
|
-
# @return [String] The absolute path.
|
23
|
-
def sandbox
|
24
|
-
@sandbox ||= File.expand_path "../../../sandbox", __FILE__
|
25
|
-
end
|
26
|
-
|
27
|
-
# Clears the temporary `spec/sandbox`.
|
28
|
-
def clear_sandbox
|
29
|
-
FileUtils.rm_rf sandbox
|
30
|
-
end
|
31
|
-
|
32
|
-
# Re-creates the temporary `spec/sandbox`.
|
33
|
-
def prepare_sandbox
|
34
|
-
clear_sandbox
|
35
|
-
FileUtils.mkdir_p sandbox
|
36
|
-
end
|
37
|
-
|
38
|
-
# Runs code from the temporary `spec/sandbox`.
|
39
|
-
def try_in_sandbox
|
40
|
-
FileUtils.cd(sandbox) { capture_stdout { yield } }
|
41
|
-
end
|
42
|
-
|
43
|
-
# Reads file in sandbox and returns file content.
|
44
|
-
# Returns a blank string when the file is absent.
|
45
|
-
# @return [String] The content.
|
46
|
-
def read_in_sandbox(filename)
|
47
|
-
file = Dir[File.join(sandbox, filename)].first
|
48
|
-
file ? File.read(file) : ""
|
49
|
-
end
|
50
|
-
|
51
|
-
# Creates settings file in a sandbox
|
52
|
-
#
|
53
|
-
# @param [Hash] settings ({})
|
54
|
-
# The list of settings to be stored in 'sandbox/.metrics.yml'
|
55
|
-
#
|
56
|
-
# @return [undefined]
|
57
|
-
def prepare_settings(settings, file = ".metrics.yml")
|
58
|
-
try_in_sandbox do
|
59
|
-
::FileUtils.mkdir_p ::File.dirname(file)
|
60
|
-
::File.write file, settings.to_yaml
|
61
|
-
end
|
62
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
# Checks if a file with given name is present in sandbox.
|
4
|
-
#
|
5
|
-
# @example
|
6
|
-
# expect("some_file.rb").to be_present_in_sandbox
|
7
|
-
RSpec::Matchers.define :be_present_in_sandbox do
|
8
|
-
match do |filename|
|
9
|
-
files = Dir[File.join(sandbox, filename)]
|
10
|
-
expect(files).to be_any
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
# Checks if a file with given name is absent in sandbox.
|
15
|
-
#
|
16
|
-
# @example
|
17
|
-
# expect("some_file.rb").to be_absent_in_sandbox
|
18
|
-
RSpec::Matchers.define_negated_matcher(
|
19
|
-
:be_absent_in_sandbox,
|
20
|
-
:be_present_in_sandbox
|
21
|
-
)
|