diff options
author | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-06-27 11:37:19 +0000 |
---|---|---|
committer | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-06-27 11:37:19 +0000 |
commit | 80fdfbf8099d8e802b9faaef2eda1ffdb787d1ce (patch) | |
tree | abe4d154d7577229a0b0eb48d358ae6d542cf7e3 /spec/mspec | |
parent | cbbe2fab8255223f2898489365b16a72d2c02946 (diff) | |
download | ruby-80fdfbf8099d8e802b9faaef2eda1ffdb787d1ce.tar.gz |
Update to ruby/mspec@7074b56
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63766 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/mspec')
-rw-r--r-- | spec/mspec/.travis.yml | 11 | ||||
-rw-r--r-- | spec/mspec/lib/mspec/guards/feature.rb | 6 | ||||
-rw-r--r-- | spec/mspec/lib/mspec/matchers/be_close.rb | 2 | ||||
-rw-r--r-- | spec/mspec/spec/guards/feature_spec.rb | 40 | ||||
-rw-r--r-- | spec/mspec/spec/matchers/be_close_spec.rb | 10 | ||||
-rw-r--r-- | spec/mspec/tool/sync/sync-rubyspec.rb | 32 |
6 files changed, 70 insertions, 31 deletions
diff --git a/spec/mspec/.travis.yml b/spec/mspec/.travis.yml index 0da5e83da2..62d67c7970 100644 --- a/spec/mspec/.travis.yml +++ b/spec/mspec/.travis.yml @@ -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 diff --git a/spec/mspec/lib/mspec/guards/feature.rb b/spec/mspec/lib/mspec/guards/feature.rb index 4f1df1cabe..d4c6dd1cde 100644 --- a/spec/mspec/lib/mspec/guards/feature.rb +++ b/spec/mspec/lib/mspec/guards/feature.rb @@ -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 diff --git a/spec/mspec/lib/mspec/matchers/be_close.rb b/spec/mspec/lib/mspec/matchers/be_close.rb index 8662aabd26..ea9e7f5496 100644 --- a/spec/mspec/lib/mspec/matchers/be_close.rb +++ b/spec/mspec/lib/mspec/matchers/be_close.rb @@ -8,7 +8,7 @@ class BeCloseMatcher def matches?(actual) @actual = actual - (@actual - @expected).abs < @tolerance + (@actual - @expected).abs <= @tolerance end def failure_message diff --git a/spec/mspec/spec/guards/feature_spec.rb b/spec/mspec/spec/guards/feature_spec.rb index d14e5f8e67..8761cb2fbb 100644 --- a/spec/mspec/spec/guards/feature_spec.rb +++ b/spec/mspec/spec/guards/feature_spec.rb @@ -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 diff --git a/spec/mspec/spec/matchers/be_close_spec.rb b/spec/mspec/spec/matchers/be_close_spec.rb index 9b6e56e6d5..6edff98e4a 100644 --- a/spec/mspec/spec/matchers/be_close_spec.rb +++ b/spec/mspec/spec/matchers/be_close_spec.rb @@ -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 diff --git a/spec/mspec/tool/sync/sync-rubyspec.rb b/spec/mspec/tool/sync/sync-rubyspec.rb index 13e9120b36..4a15b8e4ad 100644 --- a/spec/mspec/tool/sync/sync-rubyspec.rb +++ b/spec/mspec/tool/sync/sync-rubyspec.rb @@ -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 - - 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 + 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 + + 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 |