rspec-file_fixtures 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/Gemfile.lock +3 -3
- data/README.md +10 -10
- data/lib/rspec_file_fixtures/fixture.rb +11 -4
- data/lib/rspec_file_fixtures/version.rb +1 -1
- 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: 06bd6ac7ead0f64696bd1ed156d182ef14cf10fe252e19f7a4de489f08c5a0a5
|
4
|
+
data.tar.gz: c611cce7ce610ec5ddcc7ddc7a2e9968782c0daf39d96d203ea179c753ccd6f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 037c9ff6a4179224b55842dcb9e5b59e8a1363f4be807b765f8d8449e2b80ba365e9684cbdbba5b64220e7a56d3f8c0ff41c27905d47c6923ebafc2bee2de256
|
7
|
+
data.tar.gz: 9f777d0e72d6a434fe0c90215cebb8a427b689c8e632a033d66873f2001dff1a7de3a42f21cdb0b15425e7f7862b033a7e41ce4895383ab92fe61e5dc00af456
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -9,7 +9,7 @@ GEM
|
|
9
9
|
specs:
|
10
10
|
ast (2.4.2)
|
11
11
|
concurrent-ruby (1.1.8)
|
12
|
-
devpack (0.
|
12
|
+
devpack (0.4.0)
|
13
13
|
diff-lcs (1.4.4)
|
14
14
|
i18n (1.8.9)
|
15
15
|
concurrent-ruby (~> 1.0)
|
@@ -68,7 +68,7 @@ PLATFORMS
|
|
68
68
|
ruby
|
69
69
|
|
70
70
|
DEPENDENCIES
|
71
|
-
devpack (~> 0.
|
71
|
+
devpack (~> 0.4.0)
|
72
72
|
nokogiri (~> 1.11)
|
73
73
|
rake (~> 12.0)
|
74
74
|
rspec (~> 3.0)
|
@@ -80,4 +80,4 @@ DEPENDENCIES
|
|
80
80
|
strong_versions (~> 0.4.5)
|
81
81
|
|
82
82
|
BUNDLED WITH
|
83
|
-
2.2.
|
83
|
+
2.2.33
|
data/README.md
CHANGED
@@ -7,7 +7,7 @@ A simple and convenient file fixture loader for [_RSpec_](https://rspec.info/).
|
|
7
7
|
Add this line to your application's Gemfile:
|
8
8
|
|
9
9
|
```ruby
|
10
|
-
gem 'rspec-file_fixtures', '~> 0.1.
|
10
|
+
gem 'rspec-file_fixtures', '~> 0.1.5'
|
11
11
|
```
|
12
12
|
|
13
13
|
And then execute:
|
@@ -36,7 +36,7 @@ Use the returned `Fixture` object's various methods in your tests:
|
|
36
36
|
|
37
37
|
```ruby
|
38
38
|
it 'loads data' do
|
39
|
-
expect(subject.load(my_fixture.read)).to eql my_fixture.
|
39
|
+
expect(subject.load(my_fixture.read)).to eql my_fixture.from_json
|
40
40
|
end
|
41
41
|
```
|
42
42
|
|
@@ -46,19 +46,19 @@ The following methods are provided on the `Fixture` object:
|
|
46
46
|
|-|-|
|
47
47
|
|`#read`|Read the contents of the fixture file as a string|
|
48
48
|
|`#path`|The absolute path to the fixture file|
|
49
|
-
|`#
|
50
|
-
|`#
|
51
|
-
|`#
|
49
|
+
|`#from_json`|The parsed _JSON_ content from the file|
|
50
|
+
|`#from_yaml`|The parsed _YAML_ content from the file (aliased as `#from_yml`)|
|
51
|
+
|`#from_xml`|The parsed _XML_ content from the file (requires the [_Nokogiri_](https://nokogiri.org/) gem and returns a `Nokogiri::XML::Document`)|
|
52
52
|
|
53
53
|
### Symbolize Names
|
54
54
|
|
55
|
-
By default `Fixture#
|
55
|
+
By default `Fixture#from_yaml` and `Fixture#from_json` symbolize all keys in their output. To disable this behaviour, pass `symbolize_names: false` to either method. A shorthand version of this is available by simply passing `false` as the only parameter:
|
56
56
|
|
57
57
|
```ruby
|
58
|
-
expect(subject.load(my_fixture.
|
59
|
-
expect(subject.load(my_fixture.
|
60
|
-
expect(subject.load(my_fixture.
|
61
|
-
expect(subject.load(my_fixture.
|
58
|
+
expect(subject.load(my_fixture.from_yaml(symbolize_names: false))).to eql({ 'foo' => 'bar' })
|
59
|
+
expect(subject.load(my_fixture.from_json(symbolize_names: false))).to eql({ 'foo' => 'bar' })
|
60
|
+
expect(subject.load(my_fixture.from_yaml(false))).to eql({ 'foo' => 'bar' })
|
61
|
+
expect(subject.load(my_fixture.from_json(false))).to eql({ 'foo' => 'bar' })
|
62
62
|
```
|
63
63
|
|
64
64
|
## License
|
@@ -11,7 +11,7 @@ module RSpecFileFixtures
|
|
11
11
|
pathname.read
|
12
12
|
end
|
13
13
|
|
14
|
-
def
|
14
|
+
def from_xml
|
15
15
|
require 'nokogiri'
|
16
16
|
Nokogiri::XML.parse(read)
|
17
17
|
end
|
@@ -23,16 +23,23 @@ module RSpecFileFixtures
|
|
23
23
|
end
|
24
24
|
|
25
25
|
# rubocop:disable Style/OptionalBooleanParameter
|
26
|
-
def
|
26
|
+
def from_json(symbolize_names_shorthand = true, symbolize_names: true)
|
27
27
|
JSON.parse(read, symbolize_names: symbolize_names & symbolize_names_shorthand)
|
28
28
|
end
|
29
29
|
|
30
|
-
def
|
30
|
+
def from_yaml(symbolize_names_shorthand = true, symbolize_names: true)
|
31
31
|
YAML.safe_load(read, symbolize_names: symbolize_names & symbolize_names_shorthand)
|
32
32
|
end
|
33
33
|
# rubocop:enable Style/OptionalBooleanParameter
|
34
34
|
|
35
|
-
alias
|
35
|
+
alias from_yml from_yaml
|
36
|
+
|
37
|
+
# Backward compatibility
|
38
|
+
alias yml from_yml
|
39
|
+
alias yaml from_yaml
|
40
|
+
alias xml from_xml
|
41
|
+
alias json from_json
|
42
|
+
# /Backward compatibility
|
36
43
|
|
37
44
|
private
|
38
45
|
|
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.5
|
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: 2022-03-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|