-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #374 from guard/fix-373_using_guard_ui
stop using Guard::UI in formatter + isolated test
- Loading branch information
Showing
4 changed files
with
59 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
RSpec.describe "succeeding spec" do | ||
it "works" do | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
require 'pathname' | ||
require 'tempfile' | ||
|
||
require 'gem_isolator' | ||
|
||
RSpec.describe "Formatter test", type: :acceptance do | ||
context "when isolated" do | ||
before { allow(Kernel).to receive(:system).and_call_original } | ||
|
||
let!(:formatter) { File.expand_path('lib/guard/rspec_formatter.rb') } | ||
|
||
context "when a valid results file path is given" do | ||
around do |example| | ||
Tempfile.open('results') do |tempfile| | ||
@results_file = tempfile.path | ||
example.run | ||
end | ||
end | ||
|
||
context "when a succeeding command is given" do | ||
let!(:spec) do | ||
File.expand_path('spec/acceptance/fixtures/succeeding_spec.rb') | ||
end | ||
|
||
let(:rspec_args) do | ||
['-r', formatter, '-f', 'Guard::RSpecFormatter', spec] | ||
end | ||
|
||
context "when guard is not in Gemfile" do | ||
let(:gems) { [%w(rspec ~>3.4)] } | ||
|
||
it "works" do | ||
GemIsolator.isolate(gems: gems) do |env, isolation| | ||
env = env.merge('GUARD_RSPEC_RESULTS_FILE' => @results_file) | ||
|
||
# TODO: I don't know why Travis needs a full path for binaries | ||
# for system() to work. | ||
rspec = env['PATH'].sub(/:.*/, '/rspec') | ||
expect(isolation.system(env, rspec, *rspec_args)).to eq(true) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters