hexx-rspec 0.1.0 → 0.2.0

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
  SHA1:
3
- metadata.gz: 67652175ea9eb8c746d5a6ad79ab0c7976127d2c
4
- data.tar.gz: 8003dc0d6a042e99bcfbef02e508d2c3553c3f79
3
+ metadata.gz: 52647807fedad179d3c534466b83e039b9acf13a
4
+ data.tar.gz: c9a315df203a0eaba66d5ab9f55569dabf31e1d1
5
5
  SHA512:
6
- metadata.gz: a602ca2e93cffcd4545b0198f890a5ed77d7244f69662a127d5ce8e2b1046fd80c842980cd42a8a20ce9bf855b422ca3e81453e0d33e0c6265ca9ee8f172bf5b
7
- data.tar.gz: b1a6292022ee603ee0bd6977836e43eb541ada5da54c077f762a1d59da6ca40f509b9327cb91c8fe7bb0d752a575bcb8c04b4556e4e4ca880940dbdb51d49fcb
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
@@ -6,7 +6,7 @@ module Hexx
6
6
 
7
7
  # The semantic version of the module.
8
8
  # @see http://semver.org/ Semantic versioning 2.0
9
- VERSION = "0.1.0".freeze
9
+ VERSION = "0.2.0".freeze
10
10
 
11
11
  end # module RSpec
12
12
 
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.1.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 00:00:00.000000000 Z
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