rspec-file_fixtures 0.1.2 → 0.1.5
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/.gitignore +2 -0
- data/.rubocop.yml +6 -0
- data/.ruby-version +1 -1
- data/Gemfile +2 -2
- data/Gemfile.lock +11 -13
- data/Makefile +4 -1
- data/README.md +16 -5
- data/lib/rspec_file_fixtures/fixture.rb +20 -9
- 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: 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/.gitignore
CHANGED
data/.rubocop.yml
ADDED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.5.
|
1
|
+
2.5.8
|
data/Gemfile
CHANGED
@@ -5,11 +5,11 @@ source 'https://rubygems.org'
|
|
5
5
|
# Specify your gem's dependencies in rspec-file_fixtures.gemspec
|
6
6
|
gemspec
|
7
7
|
|
8
|
-
gem 'devpack', '~> 0.
|
8
|
+
gem 'devpack', '~> 0.4.0'
|
9
9
|
gem 'nokogiri', '~> 1.11'
|
10
10
|
gem 'rake', '~> 12.0'
|
11
11
|
gem 'rspec', '~> 3.0'
|
12
|
-
gem 'rspec-its',
|
12
|
+
gem 'rspec-its', '~> 1.3'
|
13
13
|
gem 'rubocop', '~> 1.10'
|
14
14
|
gem 'rubocop-rake', '~> 0.5.1'
|
15
15
|
gem 'rubocop-rspec', '~> 2.1'
|
data/Gemfile.lock
CHANGED
@@ -1,14 +1,7 @@
|
|
1
|
-
PATH
|
2
|
-
remote: ../rspec-its
|
3
|
-
specs:
|
4
|
-
rspec-its (1.3.0)
|
5
|
-
rspec-core (>= 3.0.0)
|
6
|
-
rspec-expectations (>= 3.0.0)
|
7
|
-
|
8
1
|
PATH
|
9
2
|
remote: .
|
10
3
|
specs:
|
11
|
-
rspec-file_fixtures (0.1.
|
4
|
+
rspec-file_fixtures (0.1.4)
|
12
5
|
rspec (~> 3.0)
|
13
6
|
|
14
7
|
GEM
|
@@ -16,11 +9,13 @@ GEM
|
|
16
9
|
specs:
|
17
10
|
ast (2.4.2)
|
18
11
|
concurrent-ruby (1.1.8)
|
19
|
-
devpack (0.
|
12
|
+
devpack (0.4.0)
|
20
13
|
diff-lcs (1.4.4)
|
21
14
|
i18n (1.8.9)
|
22
15
|
concurrent-ruby (~> 1.0)
|
23
|
-
|
16
|
+
mini_portile2 (2.5.0)
|
17
|
+
nokogiri (1.11.1)
|
18
|
+
mini_portile2 (~> 2.5.0)
|
24
19
|
racc (~> 1.4)
|
25
20
|
paint (2.2.1)
|
26
21
|
parallel (1.20.1)
|
@@ -40,6 +35,9 @@ GEM
|
|
40
35
|
rspec-expectations (3.10.1)
|
41
36
|
diff-lcs (>= 1.2.0, < 2.0)
|
42
37
|
rspec-support (~> 3.10.0)
|
38
|
+
rspec-its (1.3.0)
|
39
|
+
rspec-core (>= 3.0.0)
|
40
|
+
rspec-expectations (>= 3.0.0)
|
43
41
|
rspec-mocks (3.10.2)
|
44
42
|
diff-lcs (>= 1.2.0, < 2.0)
|
45
43
|
rspec-support (~> 3.10.0)
|
@@ -70,16 +68,16 @@ PLATFORMS
|
|
70
68
|
ruby
|
71
69
|
|
72
70
|
DEPENDENCIES
|
73
|
-
devpack (~> 0.
|
71
|
+
devpack (~> 0.4.0)
|
74
72
|
nokogiri (~> 1.11)
|
75
73
|
rake (~> 12.0)
|
76
74
|
rspec (~> 3.0)
|
77
75
|
rspec-file_fixtures!
|
78
|
-
rspec-its
|
76
|
+
rspec-its (~> 1.3)
|
79
77
|
rubocop (~> 1.10)
|
80
78
|
rubocop-rake (~> 0.5.1)
|
81
79
|
rubocop-rspec (~> 2.1)
|
82
80
|
strong_versions (~> 0.4.5)
|
83
81
|
|
84
82
|
BUNDLED WITH
|
85
|
-
2.
|
83
|
+
2.2.33
|
data/Makefile
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.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,9 +46,20 @@ 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
|
+
|
53
|
+
### Symbolize Names
|
54
|
+
|
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
|
+
|
57
|
+
```ruby
|
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
|
+
```
|
52
63
|
|
53
64
|
## License
|
54
65
|
|
@@ -11,25 +11,36 @@ module RSpecFileFixtures
|
|
11
11
|
pathname.read
|
12
12
|
end
|
13
13
|
|
14
|
-
def
|
15
|
-
YAML.safe_load(read, symbolize_names: true)
|
16
|
-
end
|
17
|
-
|
18
|
-
alias yml yaml
|
19
|
-
|
20
|
-
def xml
|
14
|
+
def from_xml
|
21
15
|
require 'nokogiri'
|
22
16
|
Nokogiri::XML.parse(read)
|
23
17
|
end
|
24
18
|
|
25
19
|
def path
|
26
20
|
pathname.realpath.to_s
|
21
|
+
rescue Errno::ENOENT
|
22
|
+
pathname.expand_path.to_s
|
27
23
|
end
|
28
24
|
|
29
|
-
|
30
|
-
|
25
|
+
# rubocop:disable Style/OptionalBooleanParameter
|
26
|
+
def from_json(symbolize_names_shorthand = true, symbolize_names: true)
|
27
|
+
JSON.parse(read, symbolize_names: symbolize_names & symbolize_names_shorthand)
|
31
28
|
end
|
32
29
|
|
30
|
+
def from_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 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
|
43
|
+
|
33
44
|
private
|
34
45
|
|
35
46
|
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.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
|
@@ -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
|