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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c18279790c66bd029a549c0ea4445c0c0b4e90df69530aca58c23297116379e4
4
- data.tar.gz: 359c4a1c967b8ba42309129bb3228557db85ad12ad98883860dabf42edfe5b3c
3
+ metadata.gz: 85d67f3d04a4a97738f1626c01c8a95c75ad0925e0e0aa02c012aa977b4cb5c8
4
+ data.tar.gz: 32518d16d21e798f15b44c0b498cdf6df0a95941194d7a640a6ad6553f5fdfa1
5
5
  SHA512:
6
- metadata.gz: 4477a4266dd1144e6f0b0aaea2b0e6a62efe7d260c48601124fb20795c8160e57f56138ddfa7df0d5d082cdd81da969f93977fa1c620ad4ff14bffc92ccac697
7
- data.tar.gz: d4f5ce52deb8bcb9a2a00afbd21c7472773f5481234fd94cb215f2af956eb42e1ecaf2e15aef531607d3709eb9dd2603ac1283f7dae08dfe9cfb11f572a97190
6
+ metadata.gz: 564b89fae7079ca7e59f12b28362660ba9a7e47cb9fdf6de3d5fbe3e365e227c4d603baa545a5a327340e399d5f43bbae3b6515f1640ddd6c8ceb37e54256693
7
+ data.tar.gz: 29ef70ef81b8a13f076fc454544281a84b5828d2f3dc03d9fedf3960a6e1f6e5277488fe6b0b61d8cd2f708bf09ac3dc94d3acdfd90a6f3599715cfb229bbf9b
data/.rubocop.yml ADDED
@@ -0,0 +1,6 @@
1
+ AllCops:
2
+ NewCops: enable
3
+
4
+ Metrics/BlockLength:
5
+ Exclude:
6
+ - 'spec/**/*_spec.rb'
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.5.3
1
+ 2.5.8
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rspec-file_fixtures (0.1.3)
4
+ rspec-file_fixtures (0.1.4)
5
5
  rspec (~> 3.0)
6
6
 
7
7
  GEM
@@ -80,4 +80,4 @@ DEPENDENCIES
80
80
  strong_versions (~> 0.4.5)
81
81
 
82
82
  BUNDLED WITH
83
- 2.1.4
83
+ 2.2.16
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.3'
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
- def json
32
- JSON.parse(read, symbolize_names: true)
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RSpecFileFixtures
4
- VERSION = '0.1.3'
4
+ VERSION = '0.1.4'
5
5
  end
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.3
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-04-03 00:00:00.000000000 Z
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