hexx-rspec 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 52647807fedad179d3c534466b83e039b9acf13a
|
4
|
+
data.tar.gz: c9a315df203a0eaba66d5ab9f55569dabf31e1d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd4ffb9213c34263e80ee44fc487ddc759786d6b49068df6e3efdb99181b0ec78899a3b9eb9760a655609a2a70b2f62d14542f47438b7bbd390021fe84b795a2
|
7
|
+
data.tar.gz: 0b5c2f50ee55f91f8fa3a2d161f16faec0c0bee61de3914971ea5369db6e5287693eff0a67f9745ec9cd0879990fc94b0d6a48ab1af85e3c897adc04d9d26ce1
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
RSpec.configure do |config|
|
4
|
+
|
5
|
+
# Captures stdout
|
6
|
+
config.around :each, :capture do |example|
|
7
|
+
begin
|
8
|
+
$stdout = StringIO.new
|
9
|
+
example.run
|
10
|
+
result = $stdout.string
|
11
|
+
ensure
|
12
|
+
$stdout = STDOUT
|
13
|
+
end
|
14
|
+
result.to_s
|
15
|
+
end
|
16
|
+
|
17
|
+
end # RSpec.configure
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "yaml"
|
3
|
+
|
4
|
+
# Returns the path to the temporary `spec/sandbox`.
|
5
|
+
# @return [String] The absolute path.
|
6
|
+
def sandbox
|
7
|
+
@sandbox ||= File.expand_path "../tmp/sandbox"
|
8
|
+
end
|
9
|
+
|
10
|
+
# Clears the temporary `spec/sandbox`.
|
11
|
+
def clear_sandbox
|
12
|
+
FileUtils.rm_rf sandbox
|
13
|
+
end
|
14
|
+
|
15
|
+
# Re-creates the temporary `spec/sandbox`.
|
16
|
+
def prepare_sandbox
|
17
|
+
clear_sandbox
|
18
|
+
FileUtils.mkdir_p sandbox
|
19
|
+
end
|
20
|
+
|
21
|
+
# Runs code from the temporary `spec/sandbox`.
|
22
|
+
def try_in_sandbox
|
23
|
+
FileUtils.cd(sandbox) { yield }
|
24
|
+
end
|
25
|
+
|
26
|
+
# Reads file in sandbox and returns file content.
|
27
|
+
# Returns a blank string when the file is absent.
|
28
|
+
# @return [String] The content.
|
29
|
+
def read_in_sandbox(filename)
|
30
|
+
file = Dir[File.join(sandbox, filename)].first
|
31
|
+
file ? File.read(file) : ""
|
32
|
+
end
|
@@ -0,0 +1,21 @@
|
|
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
|
+
)
|
@@ -0,0 +1,16 @@
|
|
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
|
data/lib/hexx/rspec/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hexx-rspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.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-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: coveralls
|
@@ -117,11 +117,15 @@ files:
|
|
117
117
|
- Rakefile
|
118
118
|
- bin/hexx-rspec
|
119
119
|
- config/initializer.rb
|
120
|
+
- config/initializers/capture.rb
|
120
121
|
- config/initializers/focus.rb
|
121
122
|
- config/initializers/garbage_collection.rb
|
122
123
|
- config/initializers/i18n.rb
|
123
124
|
- config/initializers/random_order.rb
|
124
125
|
- config/initializers/rspec.rb
|
126
|
+
- config/initializers/sandbox.rb
|
127
|
+
- config/initializers/sandbox/helpers.rb
|
128
|
+
- config/initializers/sandbox/matchers.rb
|
125
129
|
- hexx-rspec.gemspec
|
126
130
|
- lib/hexx-rspec.rb
|
127
131
|
- lib/hexx/rspec.rb
|