diff options
author | Benoit Daloze <eregontp@gmail.com> | 2020-03-28 00:22:48 +0100 |
---|---|---|
committer | Benoit Daloze <eregontp@gmail.com> | 2020-03-28 00:22:48 +0100 |
commit | 296f68816cf575b3ff920f92aec8a4109a7d81d4 (patch) | |
tree | d1e8321dcfd77aa788751583eb54826da55de4f2 /spec/mspec/spec | |
parent | d214c188e48db5049fba8049a57dd6f73b1a57b0 (diff) |
Update to ruby/mspec@16b5a0a
Diffstat (limited to 'spec/mspec/spec')
-rw-r--r-- | spec/mspec/spec/guards/guard_spec.rb | 4 | ||||
-rw-r--r-- | spec/mspec/spec/guards/version_spec.rb | 58 | ||||
-rw-r--r-- | spec/mspec/spec/runner/context_spec.rb | 29 | ||||
-rw-r--r-- | spec/mspec/spec/runner/example_spec.rb | 10 | ||||
-rw-r--r-- | spec/mspec/spec/runner/mspec_spec.rb | 19 | ||||
-rw-r--r-- | spec/mspec/spec/utils/options_spec.rb | 2 | ||||
-rw-r--r-- | spec/mspec/spec/utils/script_spec.rb | 2 |
7 files changed, 68 insertions, 56 deletions
diff --git a/spec/mspec/spec/guards/guard_spec.rb b/spec/mspec/spec/guards/guard_spec.rb index 5c3dae4b3f..2c3317afe6 100644 --- a/spec/mspec/spec/guards/guard_spec.rb +++ b/spec/mspec/spec/guards/guard_spec.rb @@ -254,7 +254,7 @@ describe Object, "#guard" do end it "allows to combine guards" do - guard1 = VersionGuard.new 'x.x.x' + guard1 = VersionGuard.new '1.2.3', 'x.x.x' VersionGuard.stub(:new).and_return(guard1) guard2 = PlatformGuard.new :dummy PlatformGuard.stub(:new).and_return(guard2) @@ -360,7 +360,7 @@ describe Object, "#guard_not" do end it "allows to combine guards" do - guard1 = VersionGuard.new 'x.x.x' + guard1 = VersionGuard.new '1.2.3', 'x.x.x' VersionGuard.stub(:new).and_return(guard1) guard2 = PlatformGuard.new :dummy PlatformGuard.stub(:new).and_return(guard2) diff --git a/spec/mspec/spec/guards/version_spec.rb b/spec/mspec/spec/guards/version_spec.rb index 07eb451ec9..b0025efcfb 100644 --- a/spec/mspec/spec/guards/version_spec.rb +++ b/spec/mspec/spec/guards/version_spec.rb @@ -14,44 +14,44 @@ require 'mspec/guards' describe VersionGuard, "#match?" do before :each do hide_deprecation_warnings - stub_const "VersionGuard::FULL_RUBY_VERSION", SpecVersion.new('1.8.6') + @current = '1.8.6' end it "returns true when the argument is equal to RUBY_VERSION" do - VersionGuard.new('1.8.6').match?.should == true + VersionGuard.new(@current, '1.8.6').match?.should == true end it "returns true when the argument is less than RUBY_VERSION" do - VersionGuard.new('1.8').match?.should == true - VersionGuard.new('1.8.5').match?.should == true + VersionGuard.new(@current, '1.8').match?.should == true + VersionGuard.new(@current, '1.8.5').match?.should == true end it "returns false when the argument is greater than RUBY_VERSION" do - VersionGuard.new('1.8.7').match?.should == false - VersionGuard.new('1.9.2').match?.should == false + VersionGuard.new(@current, '1.8.7').match?.should == false + VersionGuard.new(@current, '1.9.2').match?.should == false end it "returns true when the argument range includes RUBY_VERSION" do - VersionGuard.new('1.8.5'..'1.8.7').match?.should == true - VersionGuard.new('1.8'..'1.9').match?.should == true - VersionGuard.new('1.8'...'1.9').match?.should == true - VersionGuard.new('1.8'..'1.8.6').match?.should == true - VersionGuard.new('1.8.5'..'1.8.6').match?.should == true - VersionGuard.new(''...'1.8.7').match?.should == true + VersionGuard.new(@current, '1.8.5'..'1.8.7').match?.should == true + VersionGuard.new(@current, '1.8'..'1.9').match?.should == true + VersionGuard.new(@current, '1.8'...'1.9').match?.should == true + VersionGuard.new(@current, '1.8'..'1.8.6').match?.should == true + VersionGuard.new(@current, '1.8.5'..'1.8.6').match?.should == true + VersionGuard.new(@current, ''...'1.8.7').match?.should == true end it "returns false when the argument range does not include RUBY_VERSION" do - VersionGuard.new('1.8.7'..'1.8.9').match?.should == false - VersionGuard.new('1.8.4'..'1.8.5').match?.should == false - VersionGuard.new('1.8.4'...'1.8.6').match?.should == false - VersionGuard.new('1.8.5'...'1.8.6').match?.should == false - VersionGuard.new(''...'1.8.6').match?.should == false + VersionGuard.new(@current, '1.8.7'..'1.8.9').match?.should == false + VersionGuard.new(@current, '1.8.4'..'1.8.5').match?.should == false + VersionGuard.new(@current, '1.8.4'...'1.8.6').match?.should == false + VersionGuard.new(@current, '1.8.5'...'1.8.6').match?.should == false + VersionGuard.new(@current, ''...'1.8.6').match?.should == false end end describe Object, "#ruby_version_is" do before :each do - @guard = VersionGuard.new 'x.x.x' + @guard = VersionGuard.new '1.2.3', 'x.x.x' VersionGuard.stub(:new).and_return(@guard) ScratchPad.clear end @@ -88,3 +88,25 @@ describe Object, "#ruby_version_is" do end.should raise_error(Exception) end end + +describe Object, "#version_is" do + before :each do + hide_deprecation_warnings + end + + it "returns the expected values" do + version_is('1.2.3', '1.2.2').should == true + version_is('1.2.3', '1.2.3').should == true + version_is('1.2.3', '1.2.4').should == false + + version_is('1.2.3', '1').should == true + version_is('1.2.3', '1.0').should == true + version_is('1.2.3', '2').should == false + version_is('1.2.3', '2.0').should == false + + version_is('1.2.3', '1.2.2'..'1.2.4').should == true + version_is('1.2.3', '1.2.2'..'1.2.3').should == true + version_is('1.2.3', '1.2.2'...'1.2.3').should == false + version_is('1.2.3', '1.2.3'..'1.2.4').should == true + end +end diff --git a/spec/mspec/spec/runner/context_spec.rb b/spec/mspec/spec/runner/context_spec.rb index d9c20aa0cf..c5aa691323 100644 --- a/spec/mspec/spec/runner/context_spec.rb +++ b/spec/mspec/spec/runner/context_spec.rb @@ -55,22 +55,6 @@ describe ContextState, "#to_s" do it "returns a description string for self when passed a String" do ContextState.new("SomeClass").to_s.should == "SomeClass" end - - it "returns a description string for self when passed a Module, String" do - ContextState.new(Object, "when empty").to_s.should == "Object when empty" - end - - it "returns a description string for self when passed a Module and String beginning with '#'" do - ContextState.new(Object, "#to_s").to_s.should == "Object#to_s" - end - - it "returns a description string for self when passed a Module and String beginning with '.'" do - ContextState.new(Object, ".to_s").to_s.should == "Object.to_s" - end - - it "returns a description string for self when passed a Module and String beginning with '::'" do - ContextState.new(Object, "::to_s").to_s.should == "Object::to_s" - end end describe ContextState, "#description" do @@ -464,11 +448,14 @@ describe ContextState, "#process" do end it "shuffles the spec list if MSpec.randomize? is true" do - MSpec.randomize - MSpec.should_receive(:shuffle) - @state.it("") { } - @state.process - MSpec.randomize false + MSpec.randomize = true + begin + MSpec.should_receive(:shuffle) + @state.it("") { } + @state.process + ensure + MSpec.randomize = false + end end it "sets the current MSpec ContextState" do diff --git a/spec/mspec/spec/runner/example_spec.rb b/spec/mspec/spec/runner/example_spec.rb index b4391f802d..7d3ad6be30 100644 --- a/spec/mspec/spec/runner/example_spec.rb +++ b/spec/mspec/spec/runner/example_spec.rb @@ -14,7 +14,7 @@ end describe ExampleState, "#describe" do before :each do - @context = ContextState.new Object, "#to_s" + @context = ContextState.new "Object#to_s" @state = ExampleState.new @context, "it" end @@ -64,16 +64,16 @@ end describe ExampleState, "#filtered?" do before :each do - MSpec.store :include, nil - MSpec.store :exclude, nil + MSpec.store :include, [] + MSpec.store :exclude, [] @state = ExampleState.new ContextState.new("describe"), "it" @filter = double("filter") end after :each do - MSpec.store :include, nil - MSpec.store :exclude, nil + MSpec.store :include, [] + MSpec.store :exclude, [] end it "returns false if MSpec include filters list is empty" do diff --git a/spec/mspec/spec/runner/mspec_spec.rb b/spec/mspec/spec/runner/mspec_spec.rb index 91338c6ddb..7dad4458d3 100644 --- a/spec/mspec/spec/runner/mspec_spec.rb +++ b/spec/mspec/spec/runner/mspec_spec.rb @@ -1,4 +1,5 @@ require 'spec_helper' +require 'mspec/expectations/expectations' require 'mspec/helpers/tmp' require 'mspec/helpers/fs' require 'mspec/matchers/base' @@ -8,7 +9,7 @@ require 'mspec/runner/example' describe MSpec, ".register_files" do it "records which spec files to run" do MSpec.register_files [:one, :two, :three] - MSpec.retrieve(:files).should == [:one, :two, :three] + MSpec.files_array.should == [:one, :two, :three] end end @@ -66,9 +67,9 @@ end describe MSpec, ".randomize" do it "sets the flag to randomize spec execution order" do MSpec.randomize?.should == false - MSpec.randomize + MSpec.randomize = true MSpec.randomize?.should == true - MSpec.randomize false + MSpec.randomize = false MSpec.randomize?.should == false end end @@ -342,17 +343,19 @@ describe MSpec, ".files" do end it "shuffles the file list if .randomize? is true" do - MSpec.randomize + MSpec.randomize = true MSpec.should_receive(:shuffle) MSpec.files - MSpec.randomize false + MSpec.randomize = false end it "registers the current file" do - MSpec.should_receive(:store).with(:file, :one) - MSpec.should_receive(:store).with(:file, :two) - MSpec.should_receive(:store).with(:file, :three) + load = double("load") + files = [] + load.stub(:load).and_return { files << MSpec.file } + MSpec.register :load, load MSpec.files + files.should == [:one, :two, :three] end end diff --git a/spec/mspec/spec/utils/options_spec.rb b/spec/mspec/spec/utils/options_spec.rb index face909286..ef85c41246 100644 --- a/spec/mspec/spec/utils/options_spec.rb +++ b/spec/mspec/spec/utils/options_spec.rb @@ -1044,7 +1044,7 @@ describe "The -H, --random option" do end it "registers the MSpec randomize mode" do - MSpec.should_receive(:randomize).twice + MSpec.should_receive(:randomize=).twice ["-H", "--random"].each do |opt| @options.parse opt end diff --git a/spec/mspec/spec/utils/script_spec.rb b/spec/mspec/spec/utils/script_spec.rb index 3cc85fa1e2..c7fa3eb354 100644 --- a/spec/mspec/spec/utils/script_spec.rb +++ b/spec/mspec/spec/utils/script_spec.rb @@ -250,8 +250,8 @@ describe MSpecScript, "#register" do it "registers :formatter with the formatter instance" do @formatter.stub(:new).and_return(@formatter) - MSpec.should_receive(:store).with(:formatter, @formatter) @script.register + MSpec.formatter.should be(@formatter) end it "does not register :formatter if config[:formatter] is false" do |