rspec-file_fixtures 0.1.9 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/README.md +1 -1
- data/lib/rspec_file_fixtures/version.rb +1 -1
- data/lib/rspec_file_fixtures.rb +1 -0
- data/rspec-documentation/pages/000-Introduction.md +1 -1
- data/rspec-documentation/pages/010-Usage/010-JSON.md +2 -2
- data/rspec-documentation/pages/010-Usage/020-YAML.md +2 -2
- data/rspec-documentation/pages/010-Usage/030-XML.md +1 -1
- data/rspec-documentation/pages/010-Usage/040-Copy_to.md +1 -1
- data/rspec-documentation/pages/010-Usage/050-Pathname.md +3 -3
- data/rspec-documentation/pages/010-Usage/060-Upload.md +1 -1
- data/rspec-documentation/pages/010-Usage.md +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18c47f70c0d769c839cc22ada66950e6dd6da2c17bf889c20c437f6b0fc0a9ca
|
4
|
+
data.tar.gz: 0b72c0874186f10e6056c01f28f11926f89e4845e2a7699b9ac9531d6d4cba8f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d98eaa662f6bad79124257c63a45f5383244005943d76445da80dbf5a94099999d301a580866f94afecf124d5edc7e487aafa8abebde7f2bfe3a92dd629e1ab
|
7
|
+
data.tar.gz: 74ef86e76c093e70eea4df1326eecb191f8d216f1f97bef970c1668caafdfa9705bb758ad211ac8bd3751129c586f2a19482bf29345c0db625487f61c68321a9
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
data/lib/rspec_file_fixtures.rb
CHANGED
@@ -25,7 +25,7 @@ require 'rspec/file_fixtures'
|
|
25
25
|
Use the provided `fixture` helper anywhere in your tests to load content from `spec/fixtures/`:
|
26
26
|
|
27
27
|
```rspec:json
|
28
|
-
subject {
|
28
|
+
subject { load_fixture('example.json').read }
|
29
29
|
|
30
30
|
it { is_expected.to include '{"key":"value"}' }
|
31
31
|
```
|
@@ -5,7 +5,7 @@ _JSON_ fixtures can be parsed into a _Ruby_ object using the `#from_json` method
|
|
5
5
|
This is equivalent to `JSON.parse(..., symbolize_names: true)`.
|
6
6
|
|
7
7
|
```rspec
|
8
|
-
subject {
|
8
|
+
subject { load_fixture('example.json').from_json }
|
9
9
|
|
10
10
|
it { is_expected.to eql({ key: 'value' }) }
|
11
11
|
```
|
@@ -15,7 +15,7 @@ it { is_expected.to eql({ key: 'value' }) }
|
|
15
15
|
Keys are symbolized by default. If you prefer to work with strings, pass `symbolize_names: false`:
|
16
16
|
|
17
17
|
```rspec
|
18
|
-
subject {
|
18
|
+
subject { load_fixture('example.json').from_json(symbolize_names: false) }
|
19
19
|
|
20
20
|
it { is_expected.to eql({ 'key' => 'value' }) }
|
21
21
|
```
|
@@ -5,7 +5,7 @@ _YAML_ fixtures can be parsed into a _Ruby_ object using the `#from_yaml` method
|
|
5
5
|
This is equivalent to `YAML.safe_load(..., symbolize_names: true)`.
|
6
6
|
|
7
7
|
```rspec
|
8
|
-
subject {
|
8
|
+
subject { load_fixture('example.yaml').from_yaml }
|
9
9
|
|
10
10
|
it { is_expected.to eql({ key: 'value' }) }
|
11
11
|
```
|
@@ -15,7 +15,7 @@ it { is_expected.to eql({ key: 'value' }) }
|
|
15
15
|
Keys are symbolized by default. If you prefer to work with strings, pass `symbolize_names: false`:
|
16
16
|
|
17
17
|
```rspec
|
18
|
-
subject {
|
18
|
+
subject { load_fixture('example.yaml').from_yaml(symbolize_names: false) }
|
19
19
|
|
20
20
|
it { is_expected.to eql({ 'key' => 'value' }) }
|
21
21
|
```
|
@@ -5,7 +5,7 @@ _XML_ fixtures can be parsed into a _Ruby_ [Nokogiri::XML::Document](https://nok
|
|
5
5
|
_Nokogiri_ is not a hard dependency of _Rspec::FileFixtures_ so you must install and require _Nokogiri_ yourself to use this feature.
|
6
6
|
|
7
7
|
```rspec
|
8
|
-
subject {
|
8
|
+
subject { load_fixture('example.xml').from_xml }
|
9
9
|
|
10
10
|
it { is_expected.to be_a Nokogiri::XML::Document }
|
11
11
|
```
|
@@ -5,7 +5,7 @@ You can use the `#copy_to(destination)` method to copy the fixture file to the d
|
|
5
5
|
```rspec:json
|
6
6
|
subject { File.read(destination_path).chomp }
|
7
7
|
|
8
|
-
let(:example_fixture) {
|
8
|
+
let(:example_fixture) { load_fixture('example.json') }
|
9
9
|
let(:destination_path) { File.join(Dir.mktmpdir, 'path/to/destination/copied.json') }
|
10
10
|
|
11
11
|
before { example_fixture.copy_to(destination_path) }
|
@@ -3,19 +3,19 @@
|
|
3
3
|
The object returned from each call to `fixture` delegates to its underlying [`Pathname`](https://docs.ruby-lang.org/en/3.2/Pathname.html) object, so you can call `#path`, `#read`, `#dirname` etc. just like a regular _Ruby_ `Pathname` object.
|
4
4
|
|
5
5
|
```rspec:xml
|
6
|
-
subject {
|
6
|
+
subject { load_fixture('example.xml').read }
|
7
7
|
|
8
8
|
it { is_expected.to include '<a type="integer">1</a>' }
|
9
9
|
```
|
10
10
|
|
11
11
|
```rspec
|
12
|
-
subject {
|
12
|
+
subject { load_fixture('example.json').dirname.to_s }
|
13
13
|
|
14
14
|
it { is_expected.to eql 'spec/fixtures' }
|
15
15
|
```
|
16
16
|
|
17
17
|
```rspec
|
18
|
-
subject {
|
18
|
+
subject { load_fixture('example.json').relative? }
|
19
19
|
|
20
20
|
it { is_expected.to be true }
|
21
21
|
```
|
@@ -5,7 +5,7 @@ Create a `Rack::Test::UploadedFile` instance by calling `#upload(content_type: '
|
|
5
5
|
The returned object can be passed as a parameter in a _request_ spec to simulate uploading a file.
|
6
6
|
|
7
7
|
```rspec
|
8
|
-
subject {
|
8
|
+
subject { load_fixture('example.xml').upload(content_type: 'application/xml') }
|
9
9
|
|
10
10
|
it { is_expected.to be_a Rack::Test::UploadedFile }
|
11
11
|
```
|
@@ -1,11 +1,11 @@
|
|
1
1
|
# Usage
|
2
2
|
|
3
|
-
_RSpec::FileFixtures_ provides a helper named `
|
3
|
+
_RSpec::FileFixtures_ provides a helper named `file_fixture` available in all specs. This method receives a filename as a string and the provided file is loaded from `spec/fixtures/`.
|
4
4
|
|
5
5
|
Fetch the fixture's path:
|
6
6
|
|
7
7
|
```rspec
|
8
|
-
subject {
|
8
|
+
subject { load_fixture('example.yaml').path }
|
9
9
|
|
10
10
|
it { is_expected.to end_with '/spec/fixtures/example.yaml' }
|
11
11
|
```
|
@@ -13,7 +13,7 @@ it { is_expected.to end_with '/spec/fixtures/example.yaml' }
|
|
13
13
|
Read the fixture's content:
|
14
14
|
|
15
15
|
```rspec:yaml
|
16
|
-
subject {
|
16
|
+
subject { load_fixture('example.yaml').read }
|
17
17
|
|
18
18
|
it { is_expected.to include 'key: value' }
|
19
19
|
```
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-file_fixtures
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bob Farrell
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-07-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|