Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: ed91cb4b4c39
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 91d706492d50
Choose a head ref
  • 2 commits
  • 7 files changed
  • 1 contributor

Commits on Oct 1, 2016

  1. Squashed 'spec/mspec/' changes from 5576c6e..eeba75b

    eeba75b Add an integration test of a typical MSpec run
    c064388 Fix: prefer the passed interpreter (with -t) to the config one in subprocesses
    
    git-subtree-dir: spec/mspec
    git-subtree-split: eeba75b324d89af8828134745acfda44ed58b09d
    eregon committed Oct 1, 2016
    Copy the full SHA
    a2641df View commit details
  2. Copy the full SHA
    91d7064 View commit details
10 changes: 8 additions & 2 deletions spec/mspec/lib/mspec/utils/script.rb
Original file line number Diff line number Diff line change
@@ -212,8 +212,14 @@ def files(list)

def setup_env
ENV['MSPEC_RUNNER'] = '1'
ENV['RUBY_EXE'] = config[:target] if config[:target]
ENV['RUBY_FLAGS'] = config[:flags].join(" ") if config[:flags]

unless ENV['RUBY_EXE']
ENV['RUBY_EXE'] = config[:target] if config[:target]
end

unless ENV['RUBY_FLAGS']
ENV['RUBY_FLAGS'] = config[:flags].join(" ") if config[:flags]
end
end

# Instantiates an instance and calls the series of methods to
15 changes: 15 additions & 0 deletions spec/mspec/spec/fixtures/a_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
unless defined?(RSpec)
describe "Foo#bar" do
it "passes" do
1.should == 1
end

it "errors" do
1.should == 2
end

it "fails" do
raise "failure"
end
end
end
5 changes: 5 additions & 0 deletions spec/mspec/spec/fixtures/config.mspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class MSpecScript
set :target, 'ruby'

set :backtrace_filter, /lib\/mspec\//
end
4 changes: 4 additions & 0 deletions spec/mspec/spec/fixtures/my_ruby
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash

echo $RUBY_EXE
ruby "$@"
4 changes: 4 additions & 0 deletions spec/mspec/spec/fixtures/print_interpreter_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
unless defined?(RSpec)
puts ENV["RUBY_EXE"]
puts ruby_cmd("nil").split.first
end
21 changes: 21 additions & 0 deletions spec/mspec/spec/integration/interpreter_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
require 'spec_helper'

describe "The interpreter passed with -t" do
it "is used in subprocess" do
fixtures = "spec/fixtures"
interpreter = "#{fixtures}/my_ruby"
cmd = "bin/mspec run"
cmd << " -B #{fixtures}/config.mspec"
cmd << " #{fixtures}/print_interpreter_spec.rb"
cmd << " -t #{interpreter}"
out = `#{cmd}`
out = out.lines.map(&:chomp).reject { |line|
line == RUBY_DESCRIPTION
}.take(3)
out.should == [
interpreter,
interpreter,
File.expand_path(interpreter)
]
end
end
40 changes: 40 additions & 0 deletions spec/mspec/spec/integration/run_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
require 'spec_helper'

describe "Running mspec" do
it "runs the specs" do
fixtures = "spec/fixtures"
cwd = Dir.pwd

cmd = "bin/mspec run"
cmd << " -B #{fixtures}/config.mspec"
cmd << " #{fixtures}/a_spec.rb"
out = `#{cmd}`
out = out.lines.reject { |line|
line.chomp == RUBY_DESCRIPTION
}.join
out = out.gsub(/\d\.\d{6}/, "D.DDDDDD")
out.should == <<EOS
.FE
1)
Foo#bar errors FAILED
Expected 1
to equal 2
#{cwd}/spec/fixtures/a_spec.rb:8:in `block (2 levels) in <top (required)>'
#{cwd}/spec/fixtures/a_spec.rb:2:in `<top (required)>'
#{cwd}/bin/mspec-run:7:in `<main>'
2)
Foo#bar fails ERROR
RuntimeError: failure
#{cwd}/spec/fixtures/a_spec.rb:12:in `block (2 levels) in <top (required)>'
#{cwd}/spec/fixtures/a_spec.rb:2:in `<top (required)>'
#{cwd}/bin/mspec-run:7:in `<main>'
Finished in D.DDDDDD seconds
1 file, 3 examples, 2 expectations, 1 failure, 1 error, 0 tagged
EOS
end
end