hexx-rspec 0.4.2 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/hexx-rspec.gemspec +2 -1
  4. data/{config → lib/hexx-rspec}/initializers/capture.rb +0 -1
  5. data/{config → lib/hexx-rspec}/initializers/focus.rb +0 -0
  6. data/{config → lib/hexx-rspec}/initializers/garbage_collection.rb +0 -0
  7. data/{config → lib/hexx-rspec}/initializers/i18n.rb +0 -0
  8. data/{config → lib/hexx-rspec}/initializers/random_order.rb +0 -0
  9. data/{config → lib/hexx-rspec}/initializers/rspec.rb +0 -0
  10. data/{config → lib/hexx-rspec}/initializers/sandbox/helpers.rb +5 -5
  11. data/{config → lib/hexx-rspec}/initializers/sandbox/matchers.rb +0 -0
  12. data/{config → lib/hexx-rspec}/initializers/sandbox.rb +0 -0
  13. data/{config/initializer.rb → lib/hexx-rspec/initializers.rb} +0 -0
  14. data/lib/{hexx/rspec → hexx-rspec}/install/Rakefile +1 -1
  15. data/lib/{hexx/rspec → hexx-rspec}/install/_rspec +1 -0
  16. data/lib/{hexx/rspec → hexx-rspec}/install/simplecov.yml +0 -0
  17. data/lib/{hexx/rspec → hexx-rspec}/install/spec_helper.erb +0 -0
  18. data/lib/{hexx/rspec → hexx-rspec}/install.rb +4 -0
  19. data/lib/{hexx/rspec → hexx-rspec}/metrics/base.rb +0 -3
  20. data/lib/{hexx/rspec → hexx-rspec}/metrics/simplecov.rb +0 -0
  21. data/lib/{tasks → hexx-rspec/tasks}/test/coverage.rake +3 -5
  22. data/lib/{tasks → hexx-rspec/tasks}/test.rake +1 -3
  23. data/lib/hexx-rspec/tasks.rb +50 -0
  24. data/lib/{hexx/rspec → hexx-rspec}/version.rb +1 -1
  25. data/lib/hexx-rspec.rb +44 -4
  26. data/spec/spec_helper.rb +3 -5
  27. data/spec/support/prepare_settings.rb +2 -2
  28. data/spec/support/tasks.rb +13 -18
  29. data/spec/{tests → unit}/bin/install_spec.rb +2 -5
  30. data/spec/unit/lib/install_spec.rb +41 -0
  31. data/spec/unit/lib/tasks_spec.rb +30 -0
  32. data/spec/{tests/lib → unit}/metrics/simplecov_spec.rb +0 -0
  33. data/spec/{tests → unit}/rspec_spec.rb +5 -20
  34. data/spec/unit/tasks/test_coverage_display_spec.rb +27 -0
  35. data/spec/unit/tasks/test_coverage_run_spec.rb +21 -0
  36. data/spec/unit/tasks/test_coverage_spec.rb +25 -0
  37. data/spec/unit/tasks/test_spec.rb +11 -0
  38. metadata +55 -39
  39. data/lib/hexx/rspec/metrics.rb +0 -23
  40. data/lib/hexx/rspec/system.rb +0 -68
  41. data/lib/hexx/rspec.rb +0 -65
  42. data/spec/tests/lib/install_spec.rb +0 -50
  43. data/spec/tests/lib/system_spec.rb +0 -99
  44. data/spec/tests/tasks/test/coverage_spec.rb +0 -26
  45. data/spec/tests/tasks/test_spec.rb +0 -21
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dac79f03664769e3027ad706c6d15d7a612e14f0
4
- data.tar.gz: 7c3649f887e14a008d1d47f316085f0d2827cb4f
3
+ metadata.gz: 7de5c381f8a0daa959533d4034eb60c76e763c82
4
+ data.tar.gz: 7a2aedbf1d293bb85f8a7681ef95e7819e613e0f
5
5
  SHA512:
6
- metadata.gz: 9b3046cf054b9a66571462ad56888dc22d521456231ddbfa7393a8910db76f3326baa26ed80affde370f5c8383cc546a872aca32845323cbd22ede0e2f0672df
7
- data.tar.gz: 872e2ac0711e348be4c05f1631605287a4ea1104b03c8156a929ef73f51fbea4faa997b22816b7e88973cf77204f155b91b6bdbef7574b58075d121f1329ebe9
6
+ metadata.gz: fd9d226af3fec99ddf9bf599b80445f169311f5e255edd58f611b6f8930435b41669ea21af41efc2a5f908c80a03ef4bd5889199baf78a0d68721af4074d57d4
7
+ data.tar.gz: f4e2cf1ccec5ef806c082c3c2206660013966de7f0e0da423c748fe96faef70eba892ff6c84d35da1574e4a44d7627af4579ac647563d892d5c412e031334ed0
data/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
  [![Coverage](https://img.shields.io/coveralls/hexx-rb/hexx-rspec.svg?style=flat)][coveralls]
8
8
  [![Inline docs](http://inch-ci.org/github/hexx-rb/hexx-rspec.svg)][inch]
9
9
 
10
- [readthedocs]: https://readthedocs.org/projects/hexx-rspec/?badge=latest
10
+ [readthedocs]: http://hexx-rspec.readthedocs.org
11
11
  [gem]: https://rubygems.org/gems/hexx-rspec
12
12
  [travis]: https://travis-ci.org/hexx-rb/hexx-rspec
13
13
  [gemnasium]: https://gemnasium.com/hexx-rb/hexx-rspec
data/hexx-rspec.gemspec CHANGED
@@ -1,5 +1,5 @@
1
1
  $:.push File.expand_path("../lib", __FILE__)
2
- require "hexx/rspec/version"
2
+ require "hexx-rspec/version"
3
3
 
4
4
  Gem::Specification.new do |gem|
5
5
 
@@ -26,5 +26,6 @@ Gem::Specification.new do |gem|
26
26
  gem.add_runtime_dependency "rspec", "~> 3.0"
27
27
  gem.add_runtime_dependency "simplecov", "~> 0.9"
28
28
  gem.add_runtime_dependency "thor", "~> 0.19"
29
+ gem.add_runtime_dependency "launchy", "~> 2.4"
29
30
 
30
31
  end
@@ -5,7 +5,6 @@ RSpec.configure do |config|
5
5
  def capture_stdout
6
6
  $stdout = StringIO.new
7
7
  yield if block_given?
8
-
9
8
  $stdout.string
10
9
  rescue
11
10
  ""
File without changes
File without changes
File without changes
@@ -1,24 +1,24 @@
1
1
  # encoding: utf-8
2
2
  require "yaml"
3
3
 
4
- # Returns the path to the temporary `spec/tmp/sandbox`.
4
+ # Returns the path to the temporary `tmp/sandbox`.
5
5
  # @return [String] The absolute path.
6
6
  def sandbox
7
- @sandbox ||= File.expand_path "spec/tmp/sandbox"
7
+ @sandbox ||= File.expand_path "tmp/sandbox"
8
8
  end
9
9
 
10
- # Clears the temporary `spec/sandbox`.
10
+ # Clears the temporary `tmp/sandbox`.
11
11
  def clear_sandbox
12
12
  FileUtils.rm_rf sandbox
13
13
  end
14
14
 
15
- # Re-creates the temporary `spec/sandbox`.
15
+ # Re-creates the temporary `tmp/sandbox`.
16
16
  def prepare_sandbox
17
17
  clear_sandbox
18
18
  FileUtils.mkdir_p sandbox
19
19
  end
20
20
 
21
- # Runs code from the temporary `spec/sandbox`.
21
+ # Runs code from the temporary `tmp/sandbox`.
22
22
  def try_in_sandbox
23
23
  FileUtils.cd(sandbox) { yield }
24
24
  end
File without changes
@@ -11,7 +11,7 @@ Bundler::GemHelper.install_tasks
11
11
 
12
12
  # Loads the Hexx::RSpec and its tasks
13
13
  require "hexx-rspec"
14
- Hexx::RSpec.install_tasks
14
+ Hexx::RSpec.install
15
15
 
16
16
  # Sets the Hexx::RSpec :test task to default
17
17
  task default: :test
@@ -1,2 +1,3 @@
1
1
  --require spec_helper
2
2
  --color
3
+ --warnings
@@ -1,8 +1,12 @@
1
+ # encoding: utf-8
2
+
1
3
  module Hexx
4
+
2
5
  module RSpec
3
6
 
4
7
  # The generator creates a Rakefile in a destination root
5
8
  class Install < Thor::Group
9
+
6
10
  include Thor::Actions
7
11
 
8
12
  # @!scope class
@@ -11,9 +11,6 @@ module Hexx
11
11
  # To be used by the 'hexx-suit' module as well
12
12
  class Base
13
13
 
14
- # The utility class for sending commands to the system
15
- SYSTEM = System
16
-
17
14
  # Loads metric settings and configures the current metric
18
15
  #
19
16
  # @return [Hexx::RSpec::Metrics]
File without changes
@@ -3,7 +3,6 @@ namespace :test do
3
3
  namespace :coverage do
4
4
 
5
5
  metric = Hexx::RSpec::Metrics::SimpleCov
6
- caller = Hexx::RSpec::System
7
6
  output = -> { ENV.fetch("SIMPLECOV_OUTPUT") { "coveralls/index.html" } }
8
7
 
9
8
  # Loads settings for simplecov from the 'config/metrics/simplecov.yml'
@@ -12,14 +11,13 @@ namespace :test do
12
11
  end
13
12
 
14
13
  desc "Runs tests under the coveralls"
15
- task run: :configure do
16
- caller.call "rake test"
17
- puts "see results in #{ output.call }"
14
+ task run: [:configure, :test] do
15
+ puts "see results in #{output.call}"
18
16
  end
19
17
 
20
18
  desc "Displays results of the coveralls last run"
21
19
  task display: :configure do
22
- caller.call "launchy #{ output.call }"
20
+ Hexx::RSpec["launchy #{output.call}"]
23
21
  end
24
22
  end
25
23
 
@@ -1,6 +1,4 @@
1
- caller = Hexx::RSpec::System
2
-
3
1
  desc "Runs a test rspec in a bundle environment, without monitoring coverage."
4
2
  task :test do
5
- caller.call "bundle exec rspec spec"
3
+ Hexx::RSpec["bundle exec rspec spec"]
6
4
  end
@@ -0,0 +1,50 @@
1
+ # encoding: utf-8
2
+
3
+ module Hexx
4
+
5
+ module RSpec
6
+
7
+ # The utility that loads gem-specific rake tasks
8
+ #
9
+ module Tasks
10
+
11
+ # Installs all the necessary rake tasks
12
+ #
13
+ # @example
14
+ # Hexx::RSpec::Tasks.install
15
+ #
16
+ # @return [self]
17
+ #
18
+ def self.install
19
+ gem_tasks
20
+ rspec_tasks
21
+ custom_tasks
22
+
23
+ self
24
+ end
25
+
26
+ # @private
27
+ def self.gem_tasks
28
+ require "bundler/gem_tasks"
29
+ Bundler::GemHelper.install_tasks
30
+ end
31
+
32
+ # @private
33
+ def self.rspec_tasks
34
+ require "rspec/core/rake_task"
35
+ ::RSpec::Core::RakeTask.new(:spec)
36
+ end
37
+
38
+ # @private
39
+ def self.custom_tasks
40
+ Dir[File.expand_path("../tasks/**/*.rake", __FILE__)]
41
+ .each(&method(:load))
42
+ end
43
+
44
+ private_class_method :gem_tasks, :rspec_tasks, :custom_tasks
45
+
46
+ end # module Load
47
+
48
+ end # module RSpec
49
+
50
+ end # module Hexx
@@ -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.4.2".freeze
9
+ VERSION = "0.5.1".freeze
10
10
 
11
11
  end # module RSpec
12
12
 
data/lib/hexx-rspec.rb CHANGED
@@ -6,11 +6,51 @@ require "rspec"
6
6
  require "thor"
7
7
  require "yaml"
8
8
 
9
- # Shared namespace for the Hexx-based gems
9
+ require_relative "hexx-rspec/initializers"
10
+ require_relative "hexx-rspec/install"
11
+ require_relative "hexx-rspec/tasks"
12
+ require_relative "hexx-rspec/metrics/base"
13
+ require_relative "hexx-rspec/metrics/simplecov"
14
+
10
15
  module Hexx
11
16
 
12
- require_relative "hexx/rspec/version"
13
- require_relative "hexx/rspec"
14
- require_relative "../config/initializer.rb"
17
+ module RSpec
18
+
19
+ # Wraps calls to system
20
+ #
21
+ # @param [#to_s] string
22
+ #
23
+ # @return [undefined]
24
+ #
25
+ def self.[](string)
26
+ system(string)
27
+ fail "finished with status #{$?.exitstatus}" unless $?.success?
28
+ end
29
+
30
+ # Loads coverage metric in a given scope
31
+ #
32
+ # Checks if a corresponding environment is set
33
+ #
34
+ # @example
35
+ # # spec/spec_helper.rb
36
+ # Hexx::RSpec.load_metrics_for(self)
37
+ #
38
+ # @param [Object] scope
39
+ #
40
+ # @return [self]
41
+ def self.load_metrics_for(scope)
42
+ return unless ENV["USE_SIMPLECOV"] && (RUBY_ENGINE == "ruby")
43
+ scope.instance_eval { Metrics::SimpleCov.run }
44
+ end
45
+
46
+ # Installs gem-specific rake tasks
47
+ #
48
+ # @return [undefined]
49
+ #
50
+ def self.install_tasks
51
+ Tasks.install
52
+ end
53
+
54
+ end # module RSpec
15
55
 
16
56
  end # module Hexx
data/spec/spec_helper.rb CHANGED
@@ -1,13 +1,11 @@
1
1
  # encoding: utf-8
2
2
 
3
- # Loads the RSpec support files.
4
- require "rspec"
5
- Dir[File.expand_path "spec/support/*.rb"].each { |file| require file }
6
-
7
3
  if RUBY_ENGINE == "ruby"
8
4
  require "coveralls"
9
5
  Coveralls.wear!
10
6
  end
11
7
 
12
- # Loads the code of the module with the RSpec test rspec.
13
8
  require "hexx-rspec"
9
+
10
+ require_relative "support/prepare_settings"
11
+ require_relative "support/tasks"
@@ -8,7 +8,7 @@
8
8
  # @return [undefined]
9
9
  def prepare_settings(settings, file = ".metrics.yml")
10
10
  try_in_sandbox do
11
- ::FileUtils.mkdir_p ::File.dirname(file)
12
- ::File.write file, settings.to_yaml
11
+ FileUtils.mkdir_p File.dirname(file)
12
+ File.write file, settings.to_yaml
13
13
  end
14
14
  end
@@ -1,13 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
- RSpec.configure do |config|
4
-
5
- # Array of commands that was sent to system
6
- #
7
- # @return [Array<String>]
8
- def commands
9
- @commands ||= []
10
- end
3
+ ::RSpec.configure do |config|
11
4
 
12
5
  # Checks whether a task with given name has been invoked
13
6
  #
@@ -18,15 +11,17 @@ RSpec.configure do |config|
18
11
  Rake::Task[name].instance_eval { @already_invoked }
19
12
  end
20
13
 
21
- config.before :example, :tasks do
22
-
23
- # Resets Rake application and reinstalls all tasks to be available
24
- Rake.application = nil
25
- Hexx::RSpec.install_tasks
14
+ # Resets Rake application
15
+ config.around :example, :tasks do |example|
16
+ app, Rake.application = Rake.application, nil
17
+ example.run
18
+ Rake.application = app
19
+ end
26
20
 
27
- # Captures commands that System utility sends to system
28
- # and stores them in {#commands} array.
29
- allow_any_instance_of(Hexx::RSpec::System)
30
- .to receive(:system) { |command| commands << command }
21
+ # Reinstalls tasks and mocks system calls
22
+ config.before :example, :tasks do
23
+ Hexx::RSpec::Tasks.install
24
+ allow(Hexx::RSpec).to receive(:[])
31
25
  end
32
- end
26
+
27
+ end # RSpec.configure
@@ -5,11 +5,8 @@ describe "hexx-rspec install", :sandbox do
5
5
  before { try_in_sandbox { `hexx-rspec install` } }
6
6
 
7
7
  it "creates necessary files" do
8
- %w(
9
- .rspec
10
- Rakefile
11
- config/metrics/simplecov.yml
12
- ).each { |file| expect(file).to be_present_in_sandbox }
8
+ %w(.rspec Rakefile config/metrics/simplecov.yml spec/spec_helper.rb)
9
+ .each { |file| expect(file).to be_present_in_sandbox }
13
10
  end
14
11
 
15
12
  end # describe hexx-rspec install
@@ -0,0 +1,41 @@
1
+ # encoding: utf-8
2
+
3
+ describe Hexx::RSpec::Install, :sandbox do
4
+
5
+ describe ".start", :capture do
6
+
7
+ before { try_in_sandbox { described_class.start options } }
8
+
9
+ context "without options" do
10
+
11
+ let(:options) { %w() }
12
+
13
+ it "creates main files" do
14
+ %w(.rspec config/metrics/simplecov.yml spec/spec_helper.rb)
15
+ .each { |file| expect(file).to be_present_in_sandbox }
16
+ end
17
+
18
+ it "adds Hexx::RSpec tasks loader to Rakefile" do
19
+ expect(read_in_sandbox "Rakefile").to include "Hexx::RSpec.install"
20
+ end
21
+
22
+ end # context
23
+
24
+ context "--no-rakefile" do
25
+
26
+ let(:options) { %w(--no-rakefile) }
27
+
28
+ it "creates main files" do
29
+ %w(.rspec config/metrics/simplecov.yml spec/spec_helper.rb)
30
+ .each { |file| expect(file).to be_present_in_sandbox }
31
+ end
32
+
33
+ it "doesn't create a Rakefile" do
34
+ expect("Rakefile").to be_absent_in_sandbox
35
+ end
36
+
37
+ end # context
38
+
39
+ end # describe .install
40
+
41
+ end # describe Hexx::RSpec
@@ -0,0 +1,30 @@
1
+ # encoding: utf-8
2
+
3
+ describe Hexx::RSpec::Tasks do
4
+
5
+ describe ".install" do
6
+
7
+ let(:rake_tasks) { Rake::Task.tasks.map(&:name) }
8
+
9
+ before { described_class.install }
10
+
11
+ it "loads Gem tasks" do
12
+ expect(rake_tasks).to include("build", "install", "release")
13
+ end
14
+
15
+ it "loads RSpec tasks" do
16
+ expect(rake_tasks).to include("spec")
17
+ end
18
+
19
+ it "loads described_class tasks" do
20
+ expect(rake_tasks).to include(*%w(
21
+ test:coverage
22
+ test:coverage:display
23
+ test:coverage:run
24
+ test
25
+ ))
26
+ end
27
+
28
+ end # display .install
29
+
30
+ end # describe Hexx::RSpec
File without changes
@@ -5,28 +5,13 @@ describe Hexx::RSpec do
5
5
  let(:coverage_settings) { described_class::Metrics::SimpleCov }
6
6
  let(:rake_tasks) { Rake::Task.tasks.map(&:name) }
7
7
 
8
- describe ".install_tasks" do
8
+ describe ".[]" do
9
9
 
10
- before { described_class.install_tasks }
11
-
12
- it "installs Gem tasks" do
13
- expect(rake_tasks).to include("build", "install", "release")
14
- end
15
-
16
- it "installs RSpec tasks" do
17
- expect(rake_tasks).to include("spec")
18
- end
19
-
20
- it "installs described_class tasks" do
21
- expect(rake_tasks).to include(*%w(
22
- test:coverage
23
- test:coverage:display
24
- test:coverage:run
25
- test
26
- ))
10
+ it "fails with unexecutable string" do
11
+ expect { described_class['foo'] }.to raise_error RuntimeError
27
12
  end
28
13
 
29
- end # display .insall_tasks
14
+ end # describe .[]
30
15
 
31
16
  describe ".load_metrics_for" do
32
17
 
@@ -61,4 +46,4 @@ describe Hexx::RSpec do
61
46
 
62
47
  end # display .load_metrics_for
63
48
 
64
- end # display Hexx::RSpec
49
+ end # describe Hexx::RSpec
@@ -0,0 +1,27 @@
1
+ # encoding: utf-8
2
+
3
+ describe "Rake::Task['test:coverage:display']", :tasks do
4
+
5
+ before { ENV.delete "SIMPLECOV_OUTPUT" }
6
+ after { Rake::Task["test:coverage:display"].invoke }
7
+
8
+ it "loads metric" do
9
+ expect(Hexx::RSpec::Metrics::SimpleCov).to receive(:load)
10
+ end
11
+
12
+ it "displays results for metric settings" do
13
+ expect(Hexx::RSpec).to receive(:[]).with "launchy tmp/coverage/index.html"
14
+ end
15
+
16
+ it "displays results for default ENV settings" do
17
+ allow(Hexx::RSpec::Metrics::SimpleCov).to receive(:load)
18
+ expect(Hexx::RSpec).to receive(:[]).with "launchy coveralls/index.html"
19
+ end
20
+
21
+ it "displays results for custom ENV settings" do
22
+ allow(Hexx::RSpec::Metrics::SimpleCov).to receive(:load)
23
+ ENV["SIMPLECOV_OUTPUT"] = "custom"
24
+ expect(Hexx::RSpec).to receive(:[]).with "launchy custom"
25
+ end
26
+
27
+ end # describe Rake::Task[:test:coverage:display]
@@ -0,0 +1,21 @@
1
+ # encoding: utf-8
2
+
3
+ describe "Rake::Task['test:coverage:run']", :tasks do
4
+
5
+ around do |example|
6
+ $stdout = StringIO.new
7
+ example.run
8
+ $stdout = STDOUT
9
+ end
10
+
11
+ after { Rake::Task["test:coverage:run"].invoke }
12
+
13
+ it "loads metric" do
14
+ expect(Hexx::RSpec::Metrics::SimpleCov).to receive(:load)
15
+ end
16
+
17
+ it "runs tests" do
18
+ expect(Hexx::RSpec).to receive(:[]).with "bundle exec rspec spec"
19
+ end
20
+
21
+ end # describe Rake::Task[:test:coverage:run]
@@ -0,0 +1,25 @@
1
+ # encoding: utf-8
2
+
3
+ describe "Rake::Task['test:coverage']", :tasks do
4
+
5
+ around do |example|
6
+ $stdout = StringIO.new
7
+ example.run
8
+ $stdout = STDOUT
9
+ end
10
+
11
+ after { Rake::Task["test:coverage"].invoke }
12
+
13
+ it "loads metric" do
14
+ expect(Hexx::RSpec::Metrics::SimpleCov).to receive(:load)
15
+ end
16
+
17
+ it "runs tests" do
18
+ expect(Hexx::RSpec).to receive(:[]).with "bundle exec rspec spec"
19
+ end
20
+
21
+ it "displays results" do
22
+ expect(Hexx::RSpec).to receive(:[]).with "launchy tmp/coverage/index.html"
23
+ end
24
+
25
+ end # describe Rake::Task[:test:coverage]
@@ -0,0 +1,11 @@
1
+ # encoding: utf-8
2
+
3
+ describe "Rake::Task['test']", :tasks do
4
+
5
+ after { Rake::Task["test"].invoke }
6
+
7
+ it "runs tests" do
8
+ expect(Hexx::RSpec).to receive(:[]).with "bundle exec rspec spec"
9
+ end
10
+
11
+ end # describe Rake::Task[:test]
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.2
4
+ version: 0.5.1
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-06-11 00:00:00.000000000 Z
11
+ date: 2015-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0.19'
111
+ - !ruby/object:Gem::Dependency
112
+ name: launchy
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '2.4'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '2.4'
111
125
  description: RSpec, Coveralls and Simplecov settings.
112
126
  email: andrew.kozin@gmail.com
113
127
  executables:
@@ -130,41 +144,41 @@ files:
130
144
  - README.md
131
145
  - Rakefile
132
146
  - bin/hexx-rspec
133
- - config/initializer.rb
134
- - config/initializers/capture.rb
135
- - config/initializers/focus.rb
136
- - config/initializers/garbage_collection.rb
137
- - config/initializers/i18n.rb
138
- - config/initializers/random_order.rb
139
- - config/initializers/rspec.rb
140
- - config/initializers/sandbox.rb
141
- - config/initializers/sandbox/helpers.rb
142
- - config/initializers/sandbox/matchers.rb
143
147
  - hexx-rspec.gemspec
144
148
  - lib/hexx-rspec.rb
145
- - lib/hexx/rspec.rb
146
- - lib/hexx/rspec/install.rb
147
- - lib/hexx/rspec/install/Rakefile
148
- - lib/hexx/rspec/install/_rspec
149
- - lib/hexx/rspec/install/simplecov.yml
150
- - lib/hexx/rspec/install/spec_helper.erb
151
- - lib/hexx/rspec/metrics.rb
152
- - lib/hexx/rspec/metrics/base.rb
153
- - lib/hexx/rspec/metrics/simplecov.rb
154
- - lib/hexx/rspec/system.rb
155
- - lib/hexx/rspec/version.rb
156
- - lib/tasks/test.rake
157
- - lib/tasks/test/coverage.rake
149
+ - lib/hexx-rspec/initializers.rb
150
+ - lib/hexx-rspec/initializers/capture.rb
151
+ - lib/hexx-rspec/initializers/focus.rb
152
+ - lib/hexx-rspec/initializers/garbage_collection.rb
153
+ - lib/hexx-rspec/initializers/i18n.rb
154
+ - lib/hexx-rspec/initializers/random_order.rb
155
+ - lib/hexx-rspec/initializers/rspec.rb
156
+ - lib/hexx-rspec/initializers/sandbox.rb
157
+ - lib/hexx-rspec/initializers/sandbox/helpers.rb
158
+ - lib/hexx-rspec/initializers/sandbox/matchers.rb
159
+ - lib/hexx-rspec/install.rb
160
+ - lib/hexx-rspec/install/Rakefile
161
+ - lib/hexx-rspec/install/_rspec
162
+ - lib/hexx-rspec/install/simplecov.yml
163
+ - lib/hexx-rspec/install/spec_helper.erb
164
+ - lib/hexx-rspec/metrics/base.rb
165
+ - lib/hexx-rspec/metrics/simplecov.rb
166
+ - lib/hexx-rspec/tasks.rb
167
+ - lib/hexx-rspec/tasks/test.rake
168
+ - lib/hexx-rspec/tasks/test/coverage.rake
169
+ - lib/hexx-rspec/version.rb
158
170
  - spec/spec_helper.rb
159
171
  - spec/support/prepare_settings.rb
160
172
  - spec/support/tasks.rb
161
- - spec/tests/bin/install_spec.rb
162
- - spec/tests/lib/install_spec.rb
163
- - spec/tests/lib/metrics/simplecov_spec.rb
164
- - spec/tests/lib/system_spec.rb
165
- - spec/tests/rspec_spec.rb
166
- - spec/tests/tasks/test/coverage_spec.rb
167
- - spec/tests/tasks/test_spec.rb
173
+ - spec/unit/bin/install_spec.rb
174
+ - spec/unit/lib/install_spec.rb
175
+ - spec/unit/lib/tasks_spec.rb
176
+ - spec/unit/metrics/simplecov_spec.rb
177
+ - spec/unit/rspec_spec.rb
178
+ - spec/unit/tasks/test_coverage_display_spec.rb
179
+ - spec/unit/tasks/test_coverage_run_spec.rb
180
+ - spec/unit/tasks/test_coverage_spec.rb
181
+ - spec/unit/tasks/test_spec.rb
168
182
  homepage: https://github.com/hexx-rb/hexx-rspec
169
183
  licenses:
170
184
  - MIT
@@ -191,13 +205,15 @@ specification_version: 4
191
205
  summary: RSpec settings.
192
206
  test_files:
193
207
  - spec/spec_helper.rb
194
- - spec/tests/rspec_spec.rb
195
- - spec/tests/lib/metrics/simplecov_spec.rb
196
- - spec/tests/lib/system_spec.rb
197
- - spec/tests/lib/install_spec.rb
198
- - spec/tests/bin/install_spec.rb
199
- - spec/tests/tasks/test_spec.rb
200
- - spec/tests/tasks/test/coverage_spec.rb
208
+ - spec/unit/metrics/simplecov_spec.rb
209
+ - spec/unit/rspec_spec.rb
210
+ - spec/unit/lib/tasks_spec.rb
211
+ - spec/unit/lib/install_spec.rb
212
+ - spec/unit/bin/install_spec.rb
213
+ - spec/unit/tasks/test_coverage_run_spec.rb
214
+ - spec/unit/tasks/test_coverage_display_spec.rb
215
+ - spec/unit/tasks/test_spec.rb
216
+ - spec/unit/tasks/test_coverage_spec.rb
201
217
  - spec/support/prepare_settings.rb
202
218
  - spec/support/tasks.rb
203
219
  - Rakefile
@@ -1,23 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module Hexx
4
-
5
- module RSpec
6
-
7
- # Contains metric configurators
8
- #
9
- # Any configurator loads metric settings from a corresponding yaml,
10
- # sets necessary environments via {.load} method,
11
- # and then runs the metric via {.run} method.
12
- #
13
- # Configurators loads their own dependencies in a corresponding constructor.
14
- module Metrics
15
-
16
- require_relative "metrics/base"
17
- require_relative "metrics/simplecov.rb"
18
-
19
- end
20
-
21
- end # module RSpec
22
-
23
- end # mdoule Hexx
@@ -1,68 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module Hexx
4
-
5
- module RSpec
6
-
7
- # The utility sends multiline string to system
8
- #
9
- # Allows stubbing system calls in specifications.
10
- #
11
- # @example
12
- # System.call %(
13
- # inch --pedantic
14
- # rubocop
15
- # )
16
- #
17
- # @api private
18
- class System < String
19
-
20
- # Initializes multiline text to be sent to system
21
- #
22
- # Removes repetitive spaces from itself
23
- #
24
- # @param [#to_s] _
25
- # Multiline text to be sent to system
26
- #
27
- # @return [undefined]
28
- def initialize(_)
29
- super
30
- strip!
31
- gsub!(/ {2,}/, " ")
32
- end
33
-
34
- # Returns non-empty lines without trailing spaces
35
- #
36
- # @return [Array<String>]
37
- def lines
38
- Array(super) # Array() is needed to support rubies 1.9.3
39
- .map(&:strip)
40
- .reject(&:empty?)
41
- end
42
-
43
- # Sends itself to system line by line
44
- #
45
- # @return [self]
46
- def call
47
- lines.each(&method(:system))
48
-
49
- self
50
- end
51
-
52
- # Sends multiline string to system
53
- #
54
- # @example (see Hexx::RSpec::System)
55
- #
56
- # @param (see #initialize)
57
- #
58
- # @return [Hexx::RSpec::System]
59
- # utility object (allows chaining)
60
- def self.call(text)
61
- new(text).call
62
- end
63
-
64
- end # class System
65
-
66
- end # module RSpec
67
-
68
- end # module Hexx
data/lib/hexx/rspec.rb DELETED
@@ -1,65 +0,0 @@
1
- # encoding: utf-8
2
-
3
- module Hexx
4
-
5
- # Namespace for the module.
6
- #
7
- # @api public
8
- module RSpec
9
-
10
- require_relative "rspec/system"
11
- require_relative "rspec/metrics"
12
- require_relative "rspec/install"
13
-
14
- class << self
15
-
16
- # Loads coverage metric in a given scope
17
- #
18
- # Checks if a corresponding environment is set
19
- #
20
- # @example
21
- # # spec/spec_helper.rb
22
- # Hexx::RSpec.load_metrics_for(self)
23
- #
24
- # @param [Object] scope
25
- #
26
- # @return [self]
27
- def load_metrics_for(scope)
28
- return unless ENV["USE_SIMPLECOV"] && (RUBY_ENGINE == "ruby")
29
- scope.instance_eval { Hexx::RSpec::Metrics::SimpleCov.run }
30
- end
31
-
32
- # Loads all the necessary rake tasks
33
- #
34
- # @example
35
- # Hexx::RSpec.install_tasks
36
- #
37
- # @return [self]
38
- def install_tasks
39
- load_gem_tasks
40
- load_rspec_tasks
41
- load_custom_tasks
42
- end
43
-
44
- private
45
-
46
- def load_gem_tasks
47
- require "bundler/gem_tasks"
48
- ::Bundler::GemHelper.install_tasks
49
- end
50
-
51
- def load_rspec_tasks
52
- require "rspec/core/rake_task"
53
- ::RSpec::Core::RakeTask.new(:spec)
54
- end
55
-
56
- def load_custom_tasks
57
- tasks = ::File.expand_path "../../tasks/**/*.rake", __FILE__
58
- ::Dir[tasks].each { |task| load task }
59
- end
60
-
61
- end # singleton class RSpec
62
-
63
- end # module RSpec
64
-
65
- end # module Hexx
@@ -1,50 +0,0 @@
1
- # encoding: utf-8
2
-
3
- describe Hexx::RSpec::Install, :sandbox do
4
-
5
- describe ".start", :capture do
6
-
7
- subject { try_in_sandbox { described_class.start options } }
8
-
9
- context "without options" do
10
-
11
- let(:options) { %w() }
12
- before { subject }
13
-
14
- it "creates necessary files" do
15
- %w(
16
- .rspec
17
- Rakefile
18
- config/metrics/simplecov.yml
19
- spec/spec_helper.rb
20
- ).each { |file| expect(file).to be_present_in_sandbox }
21
- end
22
-
23
- it "adds Hexx::RSpec tasks loader to Rakefile" do
24
- expect(read_in_sandbox "Rakefile")
25
- .to include "Hexx::RSpec.install_tasks"
26
- end
27
-
28
- end # context
29
-
30
- context "--no-rakefile" do
31
-
32
- let(:options) { %w(--no-rakefile) }
33
- before { subject }
34
-
35
- it "creates necessary files" do
36
- %w(
37
- .rspec
38
- config/metrics/simplecov.yml
39
- ).each { |file| expect(file).to be_present_in_sandbox }
40
- end
41
-
42
- it "doesn't create a Rakefile" do
43
- expect("Rakefile").to be_absent_in_sandbox
44
- end
45
-
46
- end # context
47
-
48
- end # describe .start
49
-
50
- end # describe Hexx::RSpec::Install
@@ -1,99 +0,0 @@
1
- # encoding: utf-8
2
-
3
- describe Hexx::RSpec::System do
4
-
5
- it "is a string" do
6
- subject = described_class.new ""
7
- expect(subject).to be_kind_of String
8
- end
9
-
10
- describe ".new" do
11
-
12
- it "removes repetitive spaces from source" do
13
- subject = described_class.new "foo bar \n baz"
14
-
15
- expect(subject).to eq "foo bar \n baz"
16
- end
17
-
18
- it "strips the source" do
19
- subject = described_class.new " foo bar \n baz "
20
-
21
- expect(subject).to eq "foo bar \n baz"
22
- end
23
-
24
- end # describe .new
25
-
26
- describe "#lines" do
27
-
28
- it "strips lines" do
29
- subject = described_class.new " foo bar \n baz "
30
-
31
- expect(subject.lines).to eq ["foo bar", "baz"]
32
- end
33
-
34
- it "ignores empty lines" do
35
- subject = described_class.new " \nfoo bar\n \nbaz\n "
36
-
37
- expect(subject.lines).to eq ["foo bar", "baz"]
38
- end
39
-
40
- it "returns an array of utilities" do
41
- subject = described_class.new "foo bar\nbaz"
42
-
43
- subject.lines.each { |line| expect(line).to be_kind_of described_class }
44
- end
45
-
46
- end # describe #lines
47
-
48
- describe "#call" do
49
-
50
- before { allow_any_instance_of(described_class).to receive :system }
51
-
52
- it "returns itself (allows chaining)" do
53
- subject = described_class.new "foo"
54
-
55
- expect(subject.call).to eq subject
56
- end
57
-
58
- context "single line" do
59
-
60
- subject { described_class.new "foo bar" }
61
- after { subject.call }
62
-
63
- it "sends itself to system" do
64
- expect(subject).to receive(:system).with(subject)
65
- end
66
-
67
- end # context
68
-
69
- context "multiline string" do
70
-
71
- subject { described_class.new "foo bar\nbaz" }
72
- after { subject.call }
73
-
74
- it "sends each line to system" do
75
- subject.lines.each do |line|
76
- expect(subject).to receive(:system).with(line).ordered
77
- end
78
- end
79
-
80
- end # context
81
-
82
- end # describe #call
83
-
84
- describe ".call" do
85
-
86
- let!(:value) { "foo bar\nbaz" }
87
- let!(:utility) { described_class.new value }
88
-
89
- before { allow(described_class).to receive(:new) { utility } }
90
-
91
- it "constucts the utility object and calls it" do
92
- expect(described_class).to receive(:new).with(value)
93
- expect(utility).to receive :call
94
- described_class.call value
95
- end
96
-
97
- end # describe .call
98
-
99
- end
@@ -1,26 +0,0 @@
1
- # encoding: utf-8
2
-
3
- describe "Rake::Task['test:coverage']", :tasks do
4
-
5
- # The {#task_invoked?} helper is defined in the spec/support/config/tasks.rb
6
- # It tests if a task has been invoked.
7
-
8
- let(:task) { Rake::Task["test:coverage"] }
9
-
10
- describe ".invoke", :sandbox do
11
-
12
- subject { try_in_sandbox { task.invoke } }
13
-
14
- it "invokes test:coverage:run", :capture do
15
- expect { subject }
16
- .to change { task_invoked? "test:coverage:run" }
17
- .to(true)
18
- end
19
-
20
- it "invokes test:coverage:display", :capture do
21
- expect { subject }
22
- .to change { task_invoked? "test:coverage:display" }
23
- .to(true)
24
- end
25
- end
26
- end
@@ -1,21 +0,0 @@
1
- # encoding: utf-8
2
-
3
- describe "Rake::Task[:test]", :tasks do
4
-
5
- # The {#commands} variable is defined in the spec/support/config/tasks.rb
6
- # It collects the list of commands, that has been sent to system by
7
- # any instance of Hexx::RSpec::System utility.
8
-
9
- let(:task) { Rake::Task[:test] }
10
-
11
- describe ".invoke", :sandbox do
12
-
13
- subject { try_in_sandbox { task.invoke } }
14
-
15
- it "runs tests", :capture do
16
- expect { subject }.to change { commands }.to [
17
- "bundle exec rspec spec"
18
- ]
19
- end
20
- end
21
- end