ruby-changes:51554
From: eregon <ko1@a...>
Date: Thu, 28 Jun 2018 06:00:49 +0900 (JST)
Subject: [ruby-changes:51554] eregon:r63766 (trunk): Update to ruby/mspec@7074b56
eregon 2018-06-27 20:37:19 +0900 (Wed, 27 Jun 2018) New Revision: 63766 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=63766 Log: Update to ruby/mspec@7074b56 Modified files: trunk/spec/mspec/.travis.yml trunk/spec/mspec/lib/mspec/guards/feature.rb trunk/spec/mspec/lib/mspec/matchers/be_close.rb trunk/spec/mspec/spec/guards/feature_spec.rb trunk/spec/mspec/spec/matchers/be_close_spec.rb trunk/spec/mspec/tool/sync/sync-rubyspec.rb Index: spec/mspec/.travis.yml =================================================================== --- spec/mspec/.travis.yml (revision 63765) +++ spec/mspec/.travis.yml (revision 63766) @@ -1,8 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/spec/mspec/.travis.yml#L1 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/ruby/ruby/blob/trunk/spec/mspec/.travis.yml#L20 # 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 Index: spec/mspec/lib/mspec/guards/feature.rb =================================================================== --- spec/mspec/lib/mspec/guards/feature.rb (revision 63765) +++ spec/mspec/lib/mspec/guards/feature.rb (revision 63766) @@ -40,8 +40,6 @@ def with_feature(*features, &block) https://github.com/ruby/ruby/blob/trunk/spec/mspec/lib/mspec/guards/feature.rb#L40 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 Index: spec/mspec/lib/mspec/matchers/be_close.rb =================================================================== --- spec/mspec/lib/mspec/matchers/be_close.rb (revision 63765) +++ spec/mspec/lib/mspec/matchers/be_close.rb (revision 63766) @@ -8,7 +8,7 @@ class BeCloseMatcher https://github.com/ruby/ruby/blob/trunk/spec/mspec/lib/mspec/matchers/be_close.rb#L8 def matches?(actual) @actual = actual - (@actual - @expected).abs < @tolerance + (@actual - @expected).abs <= @tolerance end def failure_message Index: spec/mspec/spec/guards/feature_spec.rb =================================================================== --- spec/mspec/spec/guards/feature_spec.rb (revision 63765) +++ spec/mspec/spec/guards/feature_spec.rb (revision 63766) @@ -78,3 +78,43 @@ describe Object, "#with_feature" do https://github.com/ruby/ruby/blob/trunk/spec/mspec/spec/guards/feature_spec.rb#L78 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 Index: spec/mspec/spec/matchers/be_close_spec.rb =================================================================== --- spec/mspec/spec/matchers/be_close_spec.rb (revision 63765) +++ spec/mspec/spec/matchers/be_close_spec.rb (revision 63766) @@ -16,12 +16,14 @@ describe BeCloseMatcher do https://github.com/ruby/ruby/blob/trunk/spec/mspec/spec/matchers/be_close_spec.rb#L16 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 Index: spec/mspec/tool/sync/sync-rubyspec.rb =================================================================== --- spec/mspec/tool/sync/sync-rubyspec.rb (revision 63765) +++ spec/mspec/tool/sync/sync-rubyspec.rb (revision 63766) @@ -159,22 +159,22 @@ end https://github.com/ruby/ruby/blob/trunk/spec/mspec/tool/sync/sync-rubyspec.rb#L159 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/