rspec-file_fixtures 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +6 -0
- data/.ruby-version +1 -1
- data/Gemfile.lock +2 -2
- data/README.md +13 -2
- data/lib/rspec_file_fixtures/fixture.rb +10 -8
- data/lib/rspec_file_fixtures/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 85d67f3d04a4a97738f1626c01c8a95c75ad0925e0e0aa02c012aa977b4cb5c8
|
4
|
+
data.tar.gz: 32518d16d21e798f15b44c0b498cdf6df0a95941194d7a640a6ad6553f5fdfa1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 564b89fae7079ca7e59f12b28362660ba9a7e47cb9fdf6de3d5fbe3e365e227c4d603baa545a5a327340e399d5f43bbae3b6515f1640ddd6c8ceb37e54256693
|
7
|
+
data.tar.gz: 29ef70ef81b8a13f076fc454544281a84b5828d2f3dc03d9fedf3960a6e1f6e5277488fe6b0b61d8cd2f708bf09ac3dc94d3acdfd90a6f3599715cfb229bbf9b
|
data/.rubocop.yml
ADDED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.5.
|
1
|
+
2.5.8
|
data/Gemfile.lock
CHANGED
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.4'
|
11
11
|
```
|
12
12
|
|
13
13
|
And then execute:
|
@@ -47,9 +47,20 @@ The following methods are provided on the `Fixture` object:
|
|
47
47
|
|`#read`|Read the contents of the fixture file as a string|
|
48
48
|
|`#path`|The absolute path to the fixture file|
|
49
49
|
|`#json`|The parsed _JSON_ content from the file|
|
50
|
-
|`#yaml`|The parsed _YAML_ content from the file|
|
50
|
+
|`#yaml`|The parsed _YAML_ content from the file (aliased as `#yml`)|
|
51
51
|
|`#xml`|The parsed _XML_ content from the file (requires the [_Nokogiri_](https://nokogiri.org/) gem and returns a `Nokogiri::XML::Document`)|
|
52
52
|
|
53
|
+
### Symbolize Names
|
54
|
+
|
55
|
+
By default `Fixture#yaml` and `Fixture#json` symbolize all keys in their output. To disable this behaviour, pass `symbolize_names: true` to either method. A shorthand version of this is available by simply passing `false` as the only parameter:
|
56
|
+
|
57
|
+
```ruby
|
58
|
+
expect(subject.load(my_fixture.yaml(symbolize_names: false))).to eql({ 'foo' => 'bar' })
|
59
|
+
expect(subject.load(my_fixture.json(symbolize_names: false))).to eql({ 'foo' => 'bar' })
|
60
|
+
expect(subject.load(my_fixture.yaml(false))).to eql({ 'foo' => 'bar' })
|
61
|
+
expect(subject.load(my_fixture.json(false))).to eql({ 'foo' => 'bar' })
|
62
|
+
```
|
63
|
+
|
53
64
|
## License
|
54
65
|
|
55
66
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
@@ -11,12 +11,6 @@ module RSpecFileFixtures
|
|
11
11
|
pathname.read
|
12
12
|
end
|
13
13
|
|
14
|
-
def yaml
|
15
|
-
YAML.safe_load(read, symbolize_names: true)
|
16
|
-
end
|
17
|
-
|
18
|
-
alias yml yaml
|
19
|
-
|
20
14
|
def xml
|
21
15
|
require 'nokogiri'
|
22
16
|
Nokogiri::XML.parse(read)
|
@@ -28,10 +22,18 @@ module RSpecFileFixtures
|
|
28
22
|
pathname.expand_path.to_s
|
29
23
|
end
|
30
24
|
|
31
|
-
|
32
|
-
|
25
|
+
# rubocop:disable Style/OptionalBooleanParameter
|
26
|
+
def json(symbolize_names_shorthand = true, symbolize_names: true)
|
27
|
+
JSON.parse(read, symbolize_names: symbolize_names & symbolize_names_shorthand)
|
33
28
|
end
|
34
29
|
|
30
|
+
def yaml(symbolize_names_shorthand = true, symbolize_names: true)
|
31
|
+
YAML.safe_load(read, symbolize_names: symbolize_names & symbolize_names_shorthand)
|
32
|
+
end
|
33
|
+
# rubocop:enable Style/OptionalBooleanParameter
|
34
|
+
|
35
|
+
alias yml yaml
|
36
|
+
|
35
37
|
private
|
36
38
|
|
37
39
|
def pathname
|
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.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bob Farrell
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-05-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -33,6 +33,7 @@ extra_rdoc_files: []
|
|
33
33
|
files:
|
34
34
|
- ".gitignore"
|
35
35
|
- ".rspec"
|
36
|
+
- ".rubocop.yml"
|
36
37
|
- ".ruby-version"
|
37
38
|
- Gemfile
|
38
39
|
- Gemfile.lock
|
@@ -69,7 +70,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
69
70
|
version: '0'
|
70
71
|
requirements: []
|
71
72
|
rubyforge_project:
|
72
|
-
rubygems_version: 2.7.6
|
73
|
+
rubygems_version: 2.7.6.2
|
73
74
|
signing_key:
|
74
75
|
specification_version: 4
|
75
76
|
summary: Simple file fixture loader for RSpec
|