Skip to content

Commit

Permalink
Merge 10c65cf into bc4c4bc
Browse files Browse the repository at this point in the history
  • Loading branch information
myronmarston committed Aug 3, 2014
2 parents bc4c4bc + 10c65cf commit 9f9cb97
Show file tree
Hide file tree
Showing 13 changed files with 46 additions and 35 deletions.
4 changes: 2 additions & 2 deletions Gemfile
Expand Up @@ -16,8 +16,8 @@ gem 'yard', '~> 0.8.7', :require => false

### deps for rdoc.info
group :documentation do
gem 'redcarpet', '2.1.1'
gem 'github-markup', '0.7.2'
gem 'redcarpet', '2.1.1', :platform => :mri
gem 'github-markup', '0.7.2', :platform => :mri
end

platforms :ruby_18, :jruby do
Expand Down
6 changes: 4 additions & 2 deletions lib/rspec/core/example.rb
Expand Up @@ -201,13 +201,15 @@ class Procsy
attr_reader :example

Example.public_instance_methods(false).each do |name|
unless name.to_sym == :run
unless name.to_sym == :run || name.to_sym == :inspect
define_method(name) { |*a, &b| @example.__send__(name, *a, &b) }
end
end

Proc.public_instance_methods(false).each do |name|
define_method(name) { |*a, &b| @proc.__send__(name, *a, &b) }
unless name.to_sym == :inspect
define_method(name) { |*a, &b| @proc.__send__(name, *a, &b) }
end
end
alias run call

Expand Down
2 changes: 1 addition & 1 deletion lib/rspec/core/minitest_assertions_adapter.rb
Expand Up @@ -2,7 +2,7 @@
# Only the minitest 5.x gem includes the minitest.rb and assertions.rb files
require 'minitest'
require 'minitest/assertions'
rescue LoadError => _ignored
rescue LoadError
# We must be using Ruby Core's MiniTest or the Minitest gem 4.x
require 'minitest/unit'
Minitest = MiniTest
Expand Down
2 changes: 1 addition & 1 deletion lib/rspec/core/test_unit_assertions_adapter.rb
Expand Up @@ -22,7 +22,7 @@ module TestUnitAssertionsAdapter
require 'rspec/core/minitest_assertions_adapter'
include ::RSpec::Core::MinitestAssertionsAdapter
end
rescue NameError => _ignored
rescue NameError
# No-op. Minitest 5.x was not loaded
end
end
Expand Down
6 changes: 0 additions & 6 deletions spec/rspec/core/configuration_spec.rb
Expand Up @@ -89,8 +89,6 @@ module RSpec::Core
end

describe "#requires=" do
include_context "isolate load path mutation"

def absolute_path_to(dir)
File.expand_path("../../../../#{dir}", __FILE__)
end
Expand Down Expand Up @@ -1109,17 +1107,13 @@ def metadata_hash(*args)
end

describe "#libs=" do
include_context "isolate load path mutation"

it "adds directories to the LOAD_PATH" do
expect($LOAD_PATH).to receive(:unshift).with("a/dir")
config.libs = ["a/dir"]
end
end

describe "libs" do
include_context "isolate load path mutation"

it 'records paths added to the load path' do
config.libs = ["a/dir"]
expect(config.libs).to eq ["a/dir"]
Expand Down
12 changes: 0 additions & 12 deletions spec/rspec/core/rake_task_spec.rb
Expand Up @@ -110,18 +110,6 @@ def specify_consistent_ordering_of_files_to_run(pattern, file_searcher)
end

describe "load path manipulation" do
around(:example) do |ex|
# use the `include` matcher to ensure it's already loaded; otherwise,
# it could be used for the first time below after the load path has
# been changed, which would trigger an attempted autoload of the `Include`
# matcher that would fail.
expect([1]).to include(1)

orig_load_path = $LOAD_PATH.dup
ex.run
$LOAD_PATH.replace(orig_load_path)
end

def self.it_configures_rspec_load_path(description, path_template)
context "when rspec is installed as #{description}" do
it "adds the current rspec-core and rspec-support dirs to the load path to ensure the current version is used" do
Expand Down
24 changes: 18 additions & 6 deletions spec/rspec/core_spec.rb
@@ -1,6 +1,17 @@
require 'spec_helper'
require 'rspec/support/spec/prevent_load_time_warnings'

RSpec.describe RSpec do
fake_minitest = File.expand_path('../../support/fake_minitest', __FILE__)
it_behaves_like 'a library that issues no warnings when loaded', 'rspec-core',
# Loading minitest issues warnings, so we put our fake minitest on the load
# path to prevent the real minitest from being loaded.
"$LOAD_PATH.unshift '#{fake_minitest}'", 'require "rspec/core"', 'RSpec::Core::Runner.disable_autorun!' do
if RUBY_VERSION == '1.9.2' || (RUBY_PLATFORM == 'java' && RUBY_VERSION == '2.0.0')
before { pending "Not working on #{RUBY_DESCRIPTION}" }
end
end

describe "::configuration" do
it "returns the same object every time" do
expect(RSpec.configuration).to equal(RSpec.configuration)
Expand Down Expand Up @@ -70,16 +81,17 @@
end
end

include RSpec::Support::ShellOut

# This is hard to test :(. Best way I could come up with was starting
# fresh ruby process w/o this stuff already loaded.
it "loads mocks and expectations when the constants are referenced", :slow do
code = "$LOAD_PATH.replace(#{$LOAD_PATH.inspect}); " +
'require "rspec"; ' +
"puts RSpec::Mocks.name; " +
"puts RSpec::Expectations.name"
code = 'require "rspec"; puts RSpec::Mocks.name; puts RSpec::Expectations.name'
out, err, status = run_ruby_with_current_load_path(code)

result = `ruby -e '#{code}'`.chomp
expect(result.split("\n")).to eq(%w[ RSpec::Mocks RSpec::Expectations ])
expect(err).to eq("")
expect(out.split("\n")).to eq(%w[ RSpec::Mocks RSpec::Expectations ])
expect(status.exitstatus).to eq(0)
end

it 'correctly raises an error when an invalid const is referenced' do
Expand Down
6 changes: 6 additions & 0 deletions spec/spec_helper.rb
Expand Up @@ -122,6 +122,12 @@ def without_env_vars(*vars)
# structural
c.alias_it_behaves_like_to 'it_has_behavior'
c.around {|example| Sandboxing.sandboxed { example.run }}
c.around do |ex|
orig_load_path = $LOAD_PATH.dup
ex.run
$LOAD_PATH.replace(orig_load_path)
end

c.include(RSpecHelpers)
c.include Aruba::Api, :file_path => /spec\/command_line/

Expand Down
Empty file.
4 changes: 4 additions & 0 deletions spec/support/fake_minitest/minitest/minitest_assertions.rb
@@ -0,0 +1,4 @@
module Minitest
module Assertions
end
end
6 changes: 6 additions & 0 deletions spec/support/fake_minitest/test/unit/assertions.rb
@@ -0,0 +1,6 @@
module Test
module Unit
module Assertions
end
end
end
4 changes: 4 additions & 0 deletions spec/support/formatter_support.rb
Expand Up @@ -56,6 +56,8 @@ def expected_summary_output_for_example_specs
| # ./spec/rspec/core/resources/formatter_specs.rb:31
| # ./spec/spec_helper.rb:77:in `run'
| # ./spec/support/formatter_support.rb:13:in `run_example_specs_with_formatter'
| # ./spec/spec_helper.rb:127:in `run'
| # ./spec/spec_helper.rb:127
| # ./spec/spec_helper.rb:124:in `run'
| # ./spec/spec_helper.rb:124
| # ./spec/spec_helper.rb:82:in `instance_exec'
Expand Down Expand Up @@ -113,6 +115,7 @@ def expected_summary_output_for_example_specs
| # ./spec/rspec/core/resources/formatter_specs.rb:31:in `block (2 levels) in <top (required)>'
| # ./spec/spec_helper.rb:77:in `run'
| # ./spec/support/formatter_support.rb:13:in `run_example_specs_with_formatter'
| # ./spec/spec_helper.rb:127:in `block (3 levels) in <top (required)>'
| # ./spec/spec_helper.rb:124:in `block (4 levels) in <top (required)>'
| # ./spec/spec_helper.rb:82:in `instance_exec'
| # ./spec/spec_helper.rb:82:in `block in sandboxed'
Expand All @@ -127,6 +130,7 @@ def expected_summary_output_for_example_specs
| # ./spec/rspec/core/resources/formatter_specs.rb:39:in `block (2 levels) in <top (required)>'
| # ./spec/spec_helper.rb:77:in `run'
| # ./spec/support/formatter_support.rb:13:in `run_example_specs_with_formatter'
| # ./spec/spec_helper.rb:127:in `block (3 levels) in <top (required)>'
| # ./spec/spec_helper.rb:124:in `block (4 levels) in <top (required)>'
| # ./spec/spec_helper.rb:82:in `instance_exec'
| # ./spec/spec_helper.rb:82:in `block in sandboxed'
Expand Down
5 changes: 0 additions & 5 deletions spec/support/isolate_load_path_mutation.rb

This file was deleted.

0 comments on commit 9f9cb97

Please sign in to comment.