From e67780b2960714ec963c5829db5337899452dbe9 Mon Sep 17 00:00:00 2001 From: Alexandr Nikitin Date: Mon, 29 Jan 2024 21:43:47 -0800 Subject: [PATCH] [Docs] Update Ruby and docs dependencies to the latest versions (#773) * Update ruby and deps * Fix build script, explicit type * Code blocks, no border otherwise * Add more ruby platforms * Fix code highlight * Replace tabs with 4 spaces * Fix tests from docs --- .github/workflows/build_and_test.yml | 2 +- Gemfile | 8 +-- Gemfile.lock | 61 +++++++++++-------- README.md | 15 ++--- build/ExtractDocs.fs | 2 +- .../2010-01-01-getting-started.markdown | 30 +++++---- .../2010-01-02-creating-a-substitute.markdown | 32 +++++----- .../2010-02-01-set-return-value.markdown | 4 +- .../2010-02-02-return-for-args.markdown | 4 +- .../2010-02-03-return-for-any-args.markdown | 4 +- .../2010-02-03-return-from-function.markdown | 4 +- .../2010-02-04-multiple-returns.markdown | 4 +- .../_posts/2010-03-01-received-calls.markdown | 58 +++++++++--------- .../help/_posts/2010-05-01-callbacks.markdown | 12 ++-- 14 files changed, 125 insertions(+), 115 deletions(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 5b1bec98..a8ffcc3c 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -54,7 +54,7 @@ jobs: - name: Setup Ruby uses: ruby/setup-ruby@v1 with: - ruby-version: '2.7' + ruby-version: '3.2' bundler-cache: true - name: Build all targets diff --git a/Gemfile b/Gemfile index f068e835..994e7c17 100644 --- a/Gemfile +++ b/Gemfile @@ -1,7 +1,5 @@ source "https://rubygems.org" -gem "rake", ">= 12.3.3" -gem "liquid", "4.0" -gem "jekyll", "3.9.0" +gem 'rake', '~> 13.1' +gem 'liquid', '~> 4.0' +gem 'jekyll', '4.3.3' gem "kramdown-parser-gfm", "1.1.0" -gem "ruby_dep", "~> 1.3" - diff --git a/Gemfile.lock b/Gemfile.lock index 6929ddc0..21379d80 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -4,71 +4,78 @@ GEM addressable (2.8.6) public_suffix (>= 2.0.2, < 6.0) colorator (1.1.0) - concurrent-ruby (1.2.2) + concurrent-ruby (1.2.3) em-websocket (0.5.3) eventmachine (>= 0.12.9) http_parser.rb (~> 0) eventmachine (1.2.7) eventmachine (1.2.7-x64-mingw32) ffi (1.16.3) - ffi (1.16.3-x64-mingw32) forwardable-extended (2.6.0) + google-protobuf (3.25.2) http_parser.rb (0.8.0) - i18n (0.9.5) + i18n (1.14.1) concurrent-ruby (~> 1.0) - jekyll (3.9.0) + jekyll (4.3.3) addressable (~> 2.4) colorator (~> 1.0) em-websocket (~> 0.5) - i18n (~> 0.7) - jekyll-sass-converter (~> 1.0) + i18n (~> 1.0) + jekyll-sass-converter (>= 2.0, < 4.0) jekyll-watch (~> 2.0) - kramdown (>= 1.17, < 3) + kramdown (~> 2.3, >= 2.3.1) + kramdown-parser-gfm (~> 1.0) liquid (~> 4.0) - mercenary (~> 0.3.3) + mercenary (>= 0.3.6, < 0.5) pathutil (~> 0.9) - rouge (>= 1.7, < 4) + rouge (>= 3.0, < 5.0) safe_yaml (~> 1.0) - jekyll-sass-converter (1.5.2) - sass (~> 3.4) + terminal-table (>= 1.8, < 4.0) + webrick (~> 1.7) + jekyll-sass-converter (3.0.0) + sass-embedded (~> 1.54) jekyll-watch (2.2.1) listen (~> 3.0) kramdown (2.4.0) rexml kramdown-parser-gfm (1.1.0) kramdown (~> 2.0) - liquid (4.0.0) + liquid (4.0.4) listen (3.8.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) - mercenary (0.3.6) + mercenary (0.4.0) pathutil (0.16.2) forwardable-extended (~> 2.6) public_suffix (5.0.4) - rake (13.0.1) + rake (13.1.0) rb-fsevent (0.11.2) rb-inotify (0.10.1) ffi (~> 1.0) rexml (3.2.6) - rouge (3.30.0) - ruby_dep (1.3.1) + rouge (4.2.0) safe_yaml (1.0.5) - sass (3.7.4) - sass-listen (~> 4.0.0) - sass-listen (4.0.0) - rb-fsevent (~> 0.9, >= 0.9.4) - rb-inotify (~> 0.9, >= 0.9.7) + sass-embedded (1.70.0-x64-mingw-ucrt) + google-protobuf (~> 3.25) + sass-embedded (1.70.0-x64-mingw32) + google-protobuf (~> 3.25) + sass-embedded (1.70.0-x86_64-linux-gnu) + google-protobuf (~> 3.25) + terminal-table (3.0.2) + unicode-display_width (>= 1.1.1, < 3) + unicode-display_width (2.5.0) + webrick (1.8.1) PLATFORMS - ruby + x64-mingw-ucrt x64-mingw32 + x86_64-linux DEPENDENCIES - jekyll (= 3.9.0) + jekyll (= 4.3.3) kramdown-parser-gfm (= 1.1.0) - liquid (= 4.0) - rake (>= 12.3.3) - ruby_dep (~> 1.3) + liquid (~> 4.0) + rake (~> 13.1) BUNDLED WITH - 2.1.4 + 2.4.1 diff --git a/README.md b/README.md index 6529821b..85aae2da 100644 --- a/README.md +++ b/README.md @@ -69,13 +69,14 @@ _calculator.DidNotReceive().Add(5, 7); If our Received() assertion fails, NSubstitute tries to give us some help as to what the problem might be: - - NSubstitute.Exceptions.ReceivedCallsException : Expected to receive a call matching: - Add(1, 2) - Actually received no matching calls. - Received 2 non-matching calls (non-matching arguments indicated with '*' characters): - Add(1, *5*) - Add(*4*, *7*) +``` +NSubstitute.Exceptions.ReceivedCallsException : Expected to receive a call matching: + Add(1, 2) +Actually received no matching calls. +Received 2 non-matching calls (non-matching arguments indicated with '*' characters): + Add(1, *5*) + Add(*4*, *7*) +``` We can also work with properties using the Returns syntax we use for methods, or just stick with plain old property setters (for read/write properties): diff --git a/build/ExtractDocs.fs b/build/ExtractDocs.fs index d951636b..466b927c 100644 --- a/build/ExtractDocs.fs +++ b/build/ExtractDocs.fs @@ -18,7 +18,7 @@ let tags s : LiquidTag seq = |> Seq.map (fun m -> LiquidTag (m.Groups.[1].Value, m.Groups.[2].Value)) let toCodeBlock (LiquidTag (name, c)) = - let isTypeOrTestDecl s = Regex.IsMatch(s, TypeOrTestDeclRegex) + let isTypeOrTestDecl (s: string) = Regex.IsMatch(s, TypeOrTestDeclRegex) match name with | "csharp" -> if isTypeOrTestDecl c then Some (Declaration c) else Some (Snippet c) | "requiredcode" -> Some (Declaration c) diff --git a/docs/help/_posts/2010-01-01-getting-started.markdown b/docs/help/_posts/2010-01-01-getting-started.markdown index 27db8bf9..fe4eb0ec 100644 --- a/docs/help/_posts/2010-01-01-getting-started.markdown +++ b/docs/help/_posts/2010-01-01-getting-started.markdown @@ -7,14 +7,17 @@ layout: post First add the [NSubstitute NuGet package](https://nuget.org/List/Packages/NSubstitute) to your test project using [NuGet](https://docs.microsoft.com/en-us/nuget/quickstart/use-a-package) (either the command line executable, or via the package manager in your IDE). - > Install-Package NSubstitute +```sh +> Install-Package NSubstitute +``` It is optional but recommended to also install [NSubstitute.Analyzers.CSharp](https://www.nuget.org/packages/NSubstitute.Analyzers.CSharp/) for C# projects, or [NSubstitute.Analyzers.VisualBasic](https://www.nuget.org/packages/NSubstitute.Analyzers.VisualBasic/) for VB projects. NSubstitute will work without the analysers installed, but these packages will [help detect potential misuses of the NSubstitute API](/help/nsubstitute-analysers/). - > Install-Package NSubstitute.Analyzers.CSharp - // or - > Install-Package NSubstitute.Analyzers.VisualBasic - +```sh +> Install-Package NSubstitute.Analyzers.CSharp +// or +> Install-Package NSubstitute.Analyzers.VisualBasic +``` ## Using NSubstitute in a test fixture So now you are staring at a blank test fixture (created with your favourite unit testing framework; for these examples we're using [NUnit](https://nunit.org/)), and are wondering where to start. @@ -65,13 +68,14 @@ calculator.DidNotReceive().Add(5, 7); If our `Received()` assertion fails, NSubstitute tries to give us some help as to what the problem might be: - - NSubstitute.Exceptions.ReceivedCallsException : Expected to receive a call matching: - Add(1, 2) - Actually received no matching calls. - Received 2 non-matching calls (non-matching arguments indicated with '*' characters): - Add(*4*, *7*) - Add(1, *5*) +``` +NSubstitute.Exceptions.ReceivedCallsException : Expected to receive a call matching: + Add(1, 2) +Actually received no matching calls. +Received 2 non-matching calls (non-matching arguments indicated with '*' characters): + Add(*4*, *7*) + Add(1, *5*) +``` We can also work with properties using the `Returns` syntax we use for methods, or just stick with plain old property setters (for read/write properties): @@ -119,4 +123,4 @@ calculator.PoweringUp += Raise.Event(); Assert.That(eventWasRaised); ``` -That's pretty much all you need to get started with NSubstitute. Read on for more detailed feature descriptions, as well as for some of the less common requirements that NSubstitute supports. \ No newline at end of file +That's pretty much all you need to get started with NSubstitute. Read on for more detailed feature descriptions, as well as for some of the less common requirements that NSubstitute supports. diff --git a/docs/help/_posts/2010-01-02-creating-a-substitute.markdown b/docs/help/_posts/2010-01-02-creating-a-substitute.markdown index cb37956d..6b856cf9 100644 --- a/docs/help/_posts/2010-01-02-creating-a-substitute.markdown +++ b/docs/help/_posts/2010-01-02-creating-a-substitute.markdown @@ -47,9 +47,9 @@ Your substitute can implement several types this way, but remember you can only ```csharp var substitute = Substitute.For( - new[] { typeof(ICommand), typeof(ISomeInterface), typeof(SomeClassWithCtorArgs) }, - new object[] { 5, "hello world" } - ); + new[] { typeof(ICommand), typeof(ISomeInterface), typeof(SomeClassWithCtorArgs) }, + new object[] { 5, "hello world" } +); Assert.IsInstanceOf(substitute); Assert.IsInstanceOf(substitute); Assert.IsInstanceOf(substitute); @@ -60,27 +60,27 @@ Assert.IsInstanceOf(substitute); public interface ISomeInterface { } public abstract class SomeClassWithCtorArgs { - protected SomeClassWithCtorArgs(int anInt, string aString) { } + protected SomeClassWithCtorArgs(int anInt, string aString) { } } public interface ICommand { - void Execute(); + void Execute(); } public class CommandRunner { - private readonly ICommand _command; - public CommandRunner(ICommand command) - { - _command = command; - } - - public void RunCommand() - { - _command.Execute(); - if (_command is IDisposable) ((IDisposable)_command).Dispose(); - } + private readonly ICommand _command; + public CommandRunner(ICommand command) + { + _command = command; + } + + public void RunCommand() + { + _command.Execute(); + if (_command is IDisposable) ((IDisposable)_command).Dispose(); + } } ``` --> diff --git a/docs/help/_posts/2010-02-01-set-return-value.markdown b/docs/help/_posts/2010-02-01-set-return-value.markdown index 602b53cb..b8894f13 100644 --- a/docs/help/_posts/2010-02-01-set-return-value.markdown +++ b/docs/help/_posts/2010-02-01-set-return-value.markdown @@ -7,8 +7,8 @@ The following examples relate to substituting for the following interface: ```csharp public interface ICalculator { - int Add(int a, int b); - string Mode { get; set; } + int Add(int a, int b); + string Mode { get; set; } } ``` diff --git a/docs/help/_posts/2010-02-02-return-for-args.markdown b/docs/help/_posts/2010-02-02-return-for-args.markdown index 852dc763..d1abf636 100644 --- a/docs/help/_posts/2010-02-02-return-for-args.markdown +++ b/docs/help/_posts/2010-02-02-return-for-args.markdown @@ -6,8 +6,8 @@ layout: post