hexx-rspec 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/config/initializer.rb +2 -0
- data/lib/hexx/rspec/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/lib/install_spec.rb +1 -1
- data/spec/tests/tasks/test/coverage_spec.rb +2 -2
- data/spec/tests/tasks/test_spec.rb +1 -1
- metadata +5 -9
- 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: 5c3f3ee5615e66a328d8255252dccabd953a6570
|
4
|
+
data.tar.gz: ccc0f6897d2777e470dc445a616bd1c0986fc5e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b455cea9ec5af943c715c55cfd5b36ca0e5b237c2775c7da57b824b558460de9ebe0cfe59df3868dd9394517a65e23f800545e5b503f4fc41b45300363a5751
|
7
|
+
data.tar.gz: 0fd060e8ea59c56cae7983f30dc99c977655d3e451193da01d6cf3ad76b502f6b5e47f391c9fd82bf64befa0a856b30ca4d09605034966c0c7edc5c321a4780a
|
data/config/initializer.rb
CHANGED
data/lib/hexx/rspec/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
|
@@ -11,13 +11,13 @@ describe "Rake::Task['test:coverage']", :tasks do
|
|
11
11
|
|
12
12
|
subject { try_in_sandbox { task.invoke } }
|
13
13
|
|
14
|
-
it "invokes test:coverage:run" do
|
14
|
+
it "invokes test:coverage:run", :capture do
|
15
15
|
expect { subject }
|
16
16
|
.to change { task_invoked? "test:coverage:run" }
|
17
17
|
.to(true)
|
18
18
|
end
|
19
19
|
|
20
|
-
it "invokes test:coverage:display" do
|
20
|
+
it "invokes test:coverage:display", :capture do
|
21
21
|
expect { subject }
|
22
22
|
.to change { task_invoked? "test:coverage:display" }
|
23
23
|
.to(true)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hexx-rspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kozin
|
@@ -141,10 +141,8 @@ files:
|
|
141
141
|
- lib/tasks/test.rake
|
142
142
|
- lib/tasks/test/coverage.rake
|
143
143
|
- spec/spec_helper.rb
|
144
|
-
- spec/support/
|
145
|
-
- spec/support/
|
146
|
-
- spec/support/sandbox/helpers.rb
|
147
|
-
- spec/support/sandbox/matchers.rb
|
144
|
+
- spec/support/prepare_settings.rb
|
145
|
+
- spec/support/tasks.rb
|
148
146
|
- spec/tests/bin/install_spec.rb
|
149
147
|
- spec/tests/lib/install_spec.rb
|
150
148
|
- spec/tests/lib/metrics/simplecov_spec.rb
|
@@ -185,10 +183,8 @@ test_files:
|
|
185
183
|
- spec/tests/tasks/test/coverage_spec.rb
|
186
184
|
- spec/tests/bin/install_spec.rb
|
187
185
|
- spec/tests/rspec_spec.rb
|
188
|
-
- spec/support/
|
189
|
-
- spec/support/
|
190
|
-
- spec/support/sandbox/matchers.rb
|
191
|
-
- spec/support/sandbox/helpers.rb
|
186
|
+
- spec/support/prepare_settings.rb
|
187
|
+
- spec/support/tasks.rb
|
192
188
|
- Rakefile
|
193
189
|
- Guardfile
|
194
190
|
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
|
-
)
|