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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 52647807fedad179d3c534466b83e039b9acf13a
4
- data.tar.gz: c9a315df203a0eaba66d5ab9f55569dabf31e1d1
3
+ metadata.gz: 5c3f3ee5615e66a328d8255252dccabd953a6570
4
+ data.tar.gz: ccc0f6897d2777e470dc445a616bd1c0986fc5e9
5
5
  SHA512:
6
- metadata.gz: fd4ffb9213c34263e80ee44fc487ddc759786d6b49068df6e3efdb99181b0ec78899a3b9eb9760a655609a2a70b2f62d14542f47438b7bbd390021fe84b795a2
7
- data.tar.gz: 0b5c2f50ee55f91f8fa3a2d161f16faec0c0bee61de3914971ea5369db6e5287693eff0a67f9745ec9cd0879990fc94b0d6a48ab1af85e3c897adc04d9d26ce1
6
+ metadata.gz: 7b455cea9ec5af943c715c55cfd5b36ca0e5b237c2775c7da57b824b558460de9ebe0cfe59df3868dd9394517a65e23f800545e5b503f4fc41b45300363a5751
7
+ data.tar.gz: 0fd060e8ea59c56cae7983f30dc99c977655d3e451193da01d6cf3ad76b502f6b5e47f391c9fd82bf64befa0a856b30ca4d09605034966c0c7edc5c321a4780a
@@ -6,3 +6,5 @@ require_relative "initializers/i18n"
6
6
  require_relative "initializers/focus"
7
7
  require_relative "initializers/random_order"
8
8
  require_relative "initializers/garbage_collection"
9
+ require_relative "initializers/capture"
10
+ require_relative "initializers/sandbox"
@@ -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.2.0".freeze
9
+ VERSION = "0.2.1".freeze
10
10
 
11
11
  end # module RSpec
12
12
 
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # Loads the RSpec support files.
2
2
  require "rspec"
3
- Dir[File.expand_path "spec/support/config/*.rb"].each { |file| require file }
3
+ Dir[File.expand_path "spec/support/*.rb"].each { |file| require file }
4
4
 
5
5
  # encoding: utf-8
6
6
  require "coveralls"
@@ -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
 
3
3
  describe Hexx::RSpec::Install, :sandbox do
4
4
 
5
- describe ".start" do
5
+ describe ".start", :capture do
6
6
 
7
7
  subject { try_in_sandbox { described_class.start options } }
8
8
 
@@ -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)
@@ -12,7 +12,7 @@ describe "Rake::Task[:test]", :tasks do
12
12
 
13
13
  subject { try_in_sandbox { task.invoke } }
14
14
 
15
- it "runs tests" do
15
+ it "runs tests", :capture do
16
16
  expect { subject }.to change { commands }.to [
17
17
  "bundle exec rspec spec"
18
18
  ]
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.0
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/config/sandbox.rb
145
- - spec/support/config/tasks.rb
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/config/sandbox.rb
189
- - spec/support/config/tasks.rb
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
- )