diff options
author | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-10-28 15:14:55 +0000 |
---|---|---|
committer | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-10-28 15:14:55 +0000 |
commit | 974e862db9f6c91dc9448570d1a103aad357a6e5 (patch) | |
tree | 02c6ae19120f92f7aea5d691be9e9a20618be7e7 /spec/mspec/spec | |
parent | ad1b64d35d7ca980a0398f09cff527d7420cd5c1 (diff) |
Update to ruby/mspec@90925d6
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60523 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/mspec/spec')
-rw-r--r-- | spec/mspec/spec/commands/mspec_run_spec.rb | 11 | ||||
-rw-r--r-- | spec/mspec/spec/matchers/raise_error_spec.rb | 12 | ||||
-rw-r--r-- | spec/mspec/spec/mocks/mock_spec.rb | 6 | ||||
-rw-r--r-- | spec/mspec/spec/runner/filters/profile_spec.rb | 8 | ||||
-rw-r--r-- | spec/mspec/spec/utils/script_spec.rb | 9 |
5 files changed, 26 insertions, 20 deletions
diff --git a/spec/mspec/spec/commands/mspec_run_spec.rb b/spec/mspec/spec/commands/mspec_run_spec.rb index 90a42bd62b..fcb44ad5a9 100644 --- a/spec/mspec/spec/commands/mspec_run_spec.rb +++ b/spec/mspec/spec/commands/mspec_run_spec.rb @@ -17,8 +17,6 @@ end describe MSpecRun, "#options" do before :each do - @stdout, $stdout = $stdout, IOStub.new - @argv = [one_spec, two_spec] @options, @config = new_option MSpecOptions.stub(:new).and_return(@options) @@ -27,10 +25,6 @@ describe MSpecRun, "#options" do @script.stub(:config).and_return(@config) end - after :each do - $stdout = @stdout - end - it "enables the filter options" do @options.should_receive(:filters) @script.options @argv @@ -114,15 +108,14 @@ describe MSpecRun, "#options" do it "exits if there are no files to process and './spec' is not a directory" do File.should_receive(:directory?).with("./spec").and_return(false) @options.should_receive(:parse).and_return([]) - @script.should_receive(:exit) + @script.should_receive(:abort).with("No files specified.") @script.options - $stdout.should include "No files specified" end it "process 'spec/' if it is a directory and no files were specified" do File.should_receive(:directory?).with("./spec").and_return(true) @options.should_receive(:parse).and_return([]) - @script.should_receive(:files).with(["spec/"]) + @script.should_receive(:files).with(["spec/"]).and_return(["spec/a_spec.rb"]) @script.options end diff --git a/spec/mspec/spec/matchers/raise_error_spec.rb b/spec/mspec/spec/matchers/raise_error_spec.rb index 88aab34d53..7c93f0f64c 100644 --- a/spec/mspec/spec/matchers/raise_error_spec.rb +++ b/spec/mspec/spec/matchers/raise_error_spec.rb @@ -90,6 +90,18 @@ describe RaiseErrorMatcher do ["Expected ExpectedException (expected)", "but no exception was raised (nil was returned)"] end + it "provides a useful failure message when no exception is raised and the result raises in #pretty_inspect" do + result = Object.new + def result.pretty_inspect + raise ArgumentError, "bad" + end + proc = Proc.new { result } + matcher = RaiseErrorMatcher.new(ExpectedException, "expected") + matcher.matches?(proc) + matcher.failure_message.should == + ["Expected ExpectedException (expected)", "but no exception was raised (#pretty_inspect raised ArgumentError; A #<Object> was returned)"] + end + it "provides a useful negative failure message" do proc = Proc.new { raise ExpectedException, "expected" } matcher = RaiseErrorMatcher.new(ExpectedException, "expected") diff --git a/spec/mspec/spec/mocks/mock_spec.rb b/spec/mspec/spec/mocks/mock_spec.rb index d996b5285c..c814ec7bfe 100644 --- a/spec/mspec/spec/mocks/mock_spec.rb +++ b/spec/mspec/spec/mocks/mock_spec.rb @@ -284,21 +284,21 @@ describe Mock, ".verify_call" do ScratchPad.recorded.should == 1 end - it "raises an expection when it is expected to yield but no block is given" do + it "raises an exception when it is expected to yield but no block is given" do @proxy.and_yield(1, 2, 3) lambda { Mock.verify_call(@mock, :method_call) }.should raise_error(SpecExpectationNotMetError) end - it "raises an expection when it is expected to yield more arguments than the block can take" do + it "raises an exception when it is expected to yield more arguments than the block can take" do @proxy.and_yield(1, 2, 3) lambda { Mock.verify_call(@mock, :method_call) {|a, b|} }.should raise_error(SpecExpectationNotMetError) end - it "does not raise an expection when it is expected to yield to a block that can take any number of arguments" do + it "does not raise an exception when it is expected to yield to a block that can take any number of arguments" do @proxy.and_yield(1, 2, 3) expect { Mock.verify_call(@mock, :method_call) {|*a|} diff --git a/spec/mspec/spec/runner/filters/profile_spec.rb b/spec/mspec/spec/runner/filters/profile_spec.rb index 78807bca5c..89d0ad1911 100644 --- a/spec/mspec/spec/runner/filters/profile_spec.rb +++ b/spec/mspec/spec/runner/filters/profile_spec.rb @@ -15,25 +15,25 @@ describe ProfileFilter, "#find" do @filter.find(@file).should == @file end - it "attemps to locate the file in 'spec/profiles'" do + it "attempts to locate the file in 'spec/profiles'" do path = File.join "spec/profiles", @file File.should_receive(:exist?).with(path).and_return(true) @filter.find(@file).should == path end - it "attemps to locate the file in 'spec'" do + it "attempts to locate the file in 'spec'" do path = File.join "spec", @file File.should_receive(:exist?).with(path).and_return(true) @filter.find(@file).should == path end - it "attemps to locate the file in 'profiles'" do + it "attempts to locate the file in 'profiles'" do path = File.join "profiles", @file File.should_receive(:exist?).with(path).and_return(true) @filter.find(@file).should == path end - it "attemps to locate the file in '.'" do + it "attempts to locate the file in '.'" do path = File.join ".", @file File.should_receive(:exist?).with(path).and_return(true) @filter.find(@file).should == path diff --git a/spec/mspec/spec/utils/script_spec.rb b/spec/mspec/spec/utils/script_spec.rb index 20b5d293b0..2582809fae 100644 --- a/spec/mspec/spec/utils/script_spec.rb +++ b/spec/mspec/spec/utils/script_spec.rb @@ -172,7 +172,7 @@ describe MSpecScript, "#load" do @script.load(@base).should == :loaded end - it "attemps to locate the file in '.'" do + it "attempts to locate the file in '.'" do path = File.expand_path @file, "." File.should_receive(:exist?).with(path).and_return(true) Kernel.should_receive(:load).with(path).and_return(:loaded) @@ -186,7 +186,7 @@ describe MSpecScript, "#load" do @script.load(@base).should == :loaded end - it "attemps to locate the file in 'spec'" do + it "attempts to locate the file in 'spec'" do path = File.expand_path @file, "spec" File.should_receive(:exist?).with(path).and_return(true) Kernel.should_receive(:load).with(path).and_return(:loaded) @@ -438,8 +438,9 @@ describe MSpecScript, "#files" do @script.files([":files"]).should == ["file1", "file2"] end - it "returns an empty list if the config key is not set" do - @script.files([":all_files"]).should == [] + it "aborts if the config key is not set" do + @script.should_receive(:abort).with("Key :all_files not found in mspec config.") + @script.files([":all_files"]) end end |