mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	Update to ruby/mspec@7074b56
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63766 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
		
							parent
							
								
									cbbe2fab82
								
							
						
					
					
						commit
						80fdfbf809
					
				
					 6 changed files with 69 additions and 30 deletions
				
			
		| 
						 | 
				
			
			@ -1,8 +1,5 @@
 | 
			
		|||
sudo: false
 | 
			
		||||
language: ruby
 | 
			
		||||
before_script:
 | 
			
		||||
  # https://github.com/travis-ci/travis-ci/issues/8408
 | 
			
		||||
  - unset _JAVA_OPTIONS
 | 
			
		||||
script:
 | 
			
		||||
  - bundle exec rspec
 | 
			
		||||
matrix:
 | 
			
		||||
| 
						 | 
				
			
			@ -23,8 +20,10 @@ matrix:
 | 
			
		|||
      # https://github.com/travis-ci/travis-ci/issues/8978
 | 
			
		||||
      - gem update --system
 | 
			
		||||
      - gem install bundler
 | 
			
		||||
  - jdk: oraclejdk8
 | 
			
		||||
  - rvm: system
 | 
			
		||||
    install:
 | 
			
		||||
      - curl -L https://github.com/oracle/truffleruby/releases/download/vm-enterprise-0.28/truffleruby-testing-0.28.tar.gz | tar xz
 | 
			
		||||
      - source truffleruby/setup_env
 | 
			
		||||
      - curl -L https://github.com/oracle/truffleruby/releases/download/vm-1.0.0-rc2/truffleruby-1.0.0-rc2-linux-amd64.tar.gz | tar xz
 | 
			
		||||
      - export PATH="$PWD/truffleruby-1.0.0-rc2-linux-amd64/bin:$PATH"
 | 
			
		||||
      - $PWD/truffleruby-1.0.0-rc2-linux-amd64/lib/truffle/post_install_hook.sh
 | 
			
		||||
      - gem install bundler
 | 
			
		||||
      - bundle install
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -40,8 +40,6 @@ def with_feature(*features, &block)
 | 
			
		|||
  FeatureGuard.new(*features).run_if(:with_feature, &block)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
MSpecEnv.class_eval do
 | 
			
		||||
  def without_feature(*features, &block)
 | 
			
		||||
    FeatureGuard.new(*features).run_unless(:without_feature, &block)
 | 
			
		||||
  end
 | 
			
		||||
def without_feature(*features, &block)
 | 
			
		||||
  FeatureGuard.new(*features).run_unless(:without_feature, &block)
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -8,7 +8,7 @@ class BeCloseMatcher
 | 
			
		|||
 | 
			
		||||
  def matches?(actual)
 | 
			
		||||
    @actual = actual
 | 
			
		||||
    (@actual - @expected).abs < @tolerance
 | 
			
		||||
    (@actual - @expected).abs <= @tolerance
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def failure_message
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -78,3 +78,43 @@ describe Object, "#with_feature" do
 | 
			
		|||
    ScratchPad.recorded.should be_nil
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
describe Object, "#without_feature" do
 | 
			
		||||
  before :each do
 | 
			
		||||
    ScratchPad.clear
 | 
			
		||||
 | 
			
		||||
    @guard = FeatureGuard.new :encoding
 | 
			
		||||
    FeatureGuard.stub(:new).and_return(@guard)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  it "sets the name of the guard to :without_feature" do
 | 
			
		||||
    without_feature(:encoding) { }
 | 
			
		||||
    @guard.name.should == :without_feature
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  it "calls #unregister even when an exception is raised in the guard block" do
 | 
			
		||||
    @guard.should_receive(:match?).and_return(false)
 | 
			
		||||
    @guard.should_receive(:unregister)
 | 
			
		||||
    lambda do
 | 
			
		||||
      without_feature { raise Exception }
 | 
			
		||||
    end.should raise_error(Exception)
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
describe Object, "#without_feature" do
 | 
			
		||||
  before :each do
 | 
			
		||||
    ScratchPad.clear
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  it "does not yield if the feature is enabled" do
 | 
			
		||||
    MSpec.should_receive(:feature_enabled?).with(:encoding).and_return(true)
 | 
			
		||||
    without_feature(:encoding) { ScratchPad.record :yield }
 | 
			
		||||
    ScratchPad.recorded.should be_nil
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  it "yields if the feature is disabled" do
 | 
			
		||||
    MSpec.should_receive(:feature_enabled?).with(:encoding).and_return(false)
 | 
			
		||||
    without_feature(:encoding) { ScratchPad.record :yield }
 | 
			
		||||
    ScratchPad.recorded.should == :yield
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -16,12 +16,14 @@ describe BeCloseMatcher do
 | 
			
		|||
    BeCloseMatcher.new(5.0, 0.5).matches?(4.51).should == true
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  it "does not match when actual == (expected + tolerance)" do
 | 
			
		||||
    BeCloseMatcher.new(5.0, 0.5).matches?(5.5).should == false
 | 
			
		||||
  it "matches when actual == (expected + tolerance)" do
 | 
			
		||||
    BeCloseMatcher.new(5.0, 0.5).matches?(5.5).should == true
 | 
			
		||||
    BeCloseMatcher.new(3, 2).matches?(5).should == true
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  it "does not match when actual == (expected - tolerance)" do
 | 
			
		||||
    BeCloseMatcher.new(5.0, 0.5).matches?(4.5).should == false
 | 
			
		||||
  it "matches when actual == (expected - tolerance)" do
 | 
			
		||||
    BeCloseMatcher.new(5.0, 0.5).matches?(4.5).should == true
 | 
			
		||||
    BeCloseMatcher.new(3, 2).matches?(1).should == true
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  it "does not match when actual < (expected - tolerance)" do
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -159,22 +159,22 @@ end
 | 
			
		|||
def test_new_specs
 | 
			
		||||
  require "yaml"
 | 
			
		||||
  Dir.chdir(SOURCE_REPO) do
 | 
			
		||||
    if MSPEC
 | 
			
		||||
      sh "bundle", "exec", "rspec"
 | 
			
		||||
    else
 | 
			
		||||
      versions = YAML.load_file(".travis.yml")
 | 
			
		||||
      versions = versions["matrix"]["include"].map { |job| job["rvm"] }
 | 
			
		||||
      versions.delete "ruby-head"
 | 
			
		||||
      min_version, max_version = versions.minmax
 | 
			
		||||
    versions = YAML.load_file(".travis.yml")
 | 
			
		||||
    versions = versions["matrix"]["include"].map { |job| job["rvm"] }
 | 
			
		||||
    versions.delete "ruby-head"
 | 
			
		||||
    versions.delete "system"
 | 
			
		||||
    min_version, max_version = versions.minmax
 | 
			
		||||
 | 
			
		||||
      run_rubyspec = -> version {
 | 
			
		||||
        command = "chruby #{version} && ../mspec/bin/mspec -j"
 | 
			
		||||
        sh ENV["SHELL"], "-c", command
 | 
			
		||||
      }
 | 
			
		||||
      run_rubyspec[min_version]
 | 
			
		||||
      run_rubyspec[max_version]
 | 
			
		||||
      run_rubyspec["trunk"]
 | 
			
		||||
    end
 | 
			
		||||
    test_command = MSPEC ? "bundle exec rspec" : "../mspec/bin/mspec -j"
 | 
			
		||||
 | 
			
		||||
    run_test = -> version {
 | 
			
		||||
      command = "chruby #{version} && #{test_command}"
 | 
			
		||||
      sh ENV["SHELL"], "-c", command
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    run_test[min_version]
 | 
			
		||||
    run_test[max_version]
 | 
			
		||||
    run_test["trunk"]
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue