Skip to content

Commit

Permalink
[Docs] Update Ruby and docs dependencies to the latest versions (nsub…
Browse files Browse the repository at this point in the history
…stitute#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
  • Loading branch information
alexandrnikitin authored Jan 30, 2024
1 parent fe364d7 commit e67780b
Show file tree
Hide file tree
Showing 14 changed files with 125 additions and 115 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 3 additions & 5 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -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"

61 changes: 34 additions & 27 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand Down
2 changes: 1 addition & 1 deletion build/ExtractDocs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
30 changes: 17 additions & 13 deletions docs/help/_posts/2010-01-01-getting-started.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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):

Expand Down Expand Up @@ -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.
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.
32 changes: 16 additions & 16 deletions docs/help/_posts/2010-01-02-creating-a-substitute.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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<ICommand>(substitute);
Assert.IsInstanceOf<ISomeInterface>(substitute);
Assert.IsInstanceOf<SomeClassWithCtorArgs>(substitute);
Expand All @@ -60,27 +60,27 @@ Assert.IsInstanceOf<SomeClassWithCtorArgs>(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();
}
}
```
-->
Expand Down
4 changes: 2 additions & 2 deletions docs/help/_posts/2010-02-01-set-return-value.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
}
```

Expand Down
4 changes: 2 additions & 2 deletions docs/help/_posts/2010-02-02-return-for-args.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ layout: post
<!--
```requiredcode
public interface ICalculator {
int Add(int a, int b);
string Mode { get; set; }
int Add(int a, int b);
string Mode { get; set; }
}
ICalculator calculator;
[SetUp] public void SetUp() { calculator = Substitute.For<ICalculator>(); }
Expand Down
4 changes: 2 additions & 2 deletions docs/help/_posts/2010-02-03-return-for-any-args.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ layout: post
<!--
```requiredcode
public interface ICalculator {
int Add(int a, int b);
string Mode { get; set; }
int Add(int a, int b);
string Mode { get; set; }
}
ICalculator calculator;
[SetUp] public void SetUp() { calculator = Substitute.For<ICalculator>(); }
Expand Down
4 changes: 2 additions & 2 deletions docs/help/_posts/2010-02-03-return-from-function.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ layout: post
<!--
```requiredcode
public interface ICalculator {
int Add(int a, int b);
string Mode { get; set; }
int Add(int a, int b);
string Mode { get; set; }
}
ICalculator calculator;
[SetUp] public void SetUp() { calculator = Substitute.For<ICalculator>(); }
Expand Down
4 changes: 2 additions & 2 deletions docs/help/_posts/2010-02-04-multiple-returns.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ layout: post
<!--
```requiredcode
public interface ICalculator {
int Add(int a, int b);
string Mode { get; set; }
int Add(int a, int b);
string Mode { get; set; }
}
ICalculator calculator;
[SetUp] public void SetUp() { calculator = Substitute.For<ICalculator>(); }
Expand Down
Loading

0 comments on commit e67780b

Please sign in to comment.