Skip to content

Commit

Permalink
Merge 0b30aa0 into c4226b6
Browse files Browse the repository at this point in the history
  • Loading branch information
e2 committed May 31, 2016
2 parents c4226b6 + 0b30aa0 commit d882c9c
Show file tree
Hide file tree
Showing 13 changed files with 91 additions and 52 deletions.
3 changes: 3 additions & 0 deletions .hound.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ruby:
enabled: true
config_file: .rubocop.yml
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
inherit_from:
.rubocop_todo.yml

Style/StringLiterals:
Enabled: false
10 changes: 6 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
language: ruby
bundler_args: --without tool
bundler_args: --without=tool development
rvm:
- 2.2.5
- 2.3.1
- jruby-9.0.5.0
# TODO: reenable once tests pass
# - 2.2.5
# - jruby-9.0.5.0
gemfile:
- gemfiles/Gemfile.rspec-2.99
- gemfiles/Gemfile.rspec-3.4
# TODO: reenable once tests pass
# - gemfiles/Gemfile.rspec-2.99
matrix:
allow_failures:
- rvm: jruby-9.0.50
Expand Down
13 changes: 10 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,24 @@ source "https://rubygems.org"

if ENV["USE_INSTALLED_GUARD_RSPEC"] == "1"
gem "guard-rspec"
gem "launchy"
else
gemspec
gemspec development_group: :gem_build_tools
end

# bundler + rake - always included
group :gem_build_tools do
gem "bundler", "~> 1.12", "< 2.0"
gem "rake", "~> 11.1"
end

group :test do
gem "coveralls", require: false
gem "rspec", "~> 3.4"
gem "launchy", "~> 2.4"
gem "gem_isolator", '~> 0.2'
end

group :development do
gem "rspec", "~> 3.4"
gem "rubocop", require: false
gem "guard-rubocop", require: false
gem "guard-compat", ">= 0.0.2", require: false
Expand Down
14 changes: 2 additions & 12 deletions gemfiles/Gemfile.rspec-2.99
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
source "https://rubygems.org"

gemspec path: '../'
filename = "gemfiles/common"
instance_eval(IO.read(filename), filename, 1)

gem 'rspec', '~> 2.99'

group :test do
gem 'coveralls', require: false
gem "guard-compat", ">= 0.0.2", require: false
end

group :tool do
gem 'ruby_gntp', require: false
end
14 changes: 2 additions & 12 deletions gemfiles/Gemfile.rspec-3.4
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
source "https://rubygems.org"

gemspec path: '../'
filename = "gemfiles/common"
instance_eval(IO.read(filename), filename, 1)

gem 'rspec', '~> 3.4.0'

group :test do
gem 'coveralls', require: false
gem "guard-compat", ">= 0.0.2", require: false
end

group :tool do
gem 'ruby_gntp', require: false
end
8 changes: 8 additions & 0 deletions gemfiles/common
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
source "https://rubygems.org"
gemspec path: '../'

gem "bundler", "~> 1.12", "< 2.0"
gem "rake", "~> 11.1"
gem 'coveralls', require: false
gem "launchy", "~> 2.4"
gem "gem_isolator", '~> 0.1'
4 changes: 0 additions & 4 deletions guard-rspec.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,4 @@ Gem::Specification.new do |s|
s.add_dependency "guard", "~> 2.1"
s.add_dependency "guard-compat", "~> 1.1"
s.add_dependency "rspec", ">= 2.99.0", "< 4.0"

s.add_development_dependency "bundler", ">= 1.3.5", "< 2.0"
s.add_development_dependency "rake", "~> 10.1"
s.add_development_dependency "launchy", "~> 2.4"
end
6 changes: 2 additions & 4 deletions lib/guard/rspec_formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@

require_relative "rspec_formatter_results_path"

require "guard/ui"

module Guard
class RSpecFormatter < ::RSpec::Core::Formatters::BaseFormatter
UNSUPPORTED_PATTERN =
Expand Down Expand Up @@ -117,9 +115,9 @@ def write_summary(duration, total, failures, pending)

def _write(&block)
file = RSpecFormatterResultsPath.new.path
if Guard.const_defined?(:Compat)
if ENV['GUARD_RSPEC_DEBUGGING'] == '1'
msg = "Guard::RSpec: using results file: #{file.inspect}"
Guard::Compat::UI.debug(format(msg, file))
STDERR.puts format(msg, file)
end
FileUtils.mkdir_p(File.dirname(file))
File.open(file, "w", &block)
Expand Down
4 changes: 4 additions & 0 deletions spec/acceptance/fixtures/succeeding_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
RSpec.describe "succeeding spec" do
it "works" do
end
end
43 changes: 43 additions & 0 deletions spec/acceptance/formatter_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
require 'pathname'

require 'gem_isolator'

RSpec.describe "Formatter test", type: :acceptance do
context "when isolated" do
before do
allow(Kernel).to receive(:system).and_call_original
end

context "when guard is not in Gemfile" do
let(:fixture_path) { Pathname('spec/acceptance/fixtures').expand_path }
it "works" do
Bundler.with_clean_env do
formatter_path = Pathname('lib/guard/rspec_formatter.rb').expand_path
succeeding_spec = fixture_path + 'succeeding_spec.rb'
klass_name = 'Guard::RSpecFormatter'
cmd = "rspec -r #{formatter_path} -f #{klass_name} #{succeeding_spec}"

Dir.mktmpdir do |path|
guard_env = {
'GUARD_RSPEC_RESULTS_FILE' => File.join(path, "results.txt")
}

GemIsolator.isolate(gems: [%w(rspec ~>3.4)]) do |env, isolation|
env = env.merge(guard_env)
system("pwd")
system(env, "ls -l bundle/ruby/2.3.0/gems")
system(env, "gem env")
system(env, "gem contents rspec-core")
system(env, "which rspec")
system(env, "ls -l #{env['PATH'].split(':').first}")
STDERR.puts cmd.inspect
STDERR.puts env.inspect
result = isolation.system(env, cmd)
expect(result).to eq(true)
end
end
end
end
end
end
end
6 changes: 0 additions & 6 deletions spec/lib/guard/rspec/rspec_process_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@
require "guard/rspec/rspec_process"

RSpec.describe Guard::RSpec::RSpecProcess do
before do
allow(Kernel).to receive(:spawn) do |*args|
raise "Not stubbed: Kernel.spawn(#{args.map(&:inspect) * ','})"
end
end

let(:results) { instance_double(Guard::RSpec::Results) }

let(:cmd) { "foo" }
Expand Down
15 changes: 8 additions & 7 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ def instance_double(*args)

# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
RSpec.configure do |config|
config.register_ordering :global do |examples|
examples.partition { |ex| ex.metadata[:type] != :acceptance }.flatten(1)
end

# Use global for running acceptance tests last
config.order = :global

config.expect_with :rspec do |expectations|
# This option will default to `true` in RSpec 4. It makes the `description`
# and `failure_message` of custom matchers include text for helper methods
Expand Down Expand Up @@ -89,12 +96,6 @@ def instance_double(*args)
# particularly slow.
# config.profile_examples = 10

# Run specs in random order to surface order dependencies. If you find an
# order dependency and want to debug it, you can fix the order by providing
# the seed, which is printed after each run.
# --seed 1234
config.order = :random

# Seed global randomization in this process using the `--seed` CLI option.
# Setting this allows you to use `--seed` to deterministically reproduce
# test failures related to randomization by passing the same `--seed` value
Expand Down Expand Up @@ -136,7 +137,7 @@ def instance_double(*args)
end

%w(spawn system).each do |meth|
allow(File).to receive(meth.to_sym) do |*args|
allow(Kernel).to receive(meth.to_sym) do |*args|
abort "stub me: Kernel.#{meth}(#{args.map(&:inspect) * ','})!"
end
end
Expand Down

0 comments on commit d882c9c

Please sign in to comment.