rspec-file_fixtures 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +11 -2
- data/lib/rspec_file_fixtures/fixture.rb +12 -0
- data/lib/rspec_file_fixtures/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c78567396d3fd63b7f4daafa0cb226bcb0356889a6a55b7998e1121b49c7657e
|
4
|
+
data.tar.gz: 00a465a84406eaa3e859b0c1afc1f1bb9f811d2efe5771c33cfabc31be0c8f48
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa6d335a04dc1271cc4f46323ea06f12431edbce2935414e5c7cf838eb5df2d3d945be8b54707292494e3201d26f90d40a8c982c11e371f69b428c0546fe5164
|
7
|
+
data.tar.gz: 04b06c35060234ca74e00bcdc5b747681fc5ae71cd2b184839393f269bb61c23a5bd0524a0675ccb9f838ba7eec878f72e6a5c2be98e2fcdab873d89b0996d20
|
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.6'
|
11
11
|
```
|
12
12
|
|
13
13
|
And then execute:
|
@@ -35,11 +35,18 @@ let(:my_fixture) { fixture('fixture.json') }
|
|
35
35
|
Use the returned `Fixture` object's various methods in your tests:
|
36
36
|
|
37
37
|
```ruby
|
38
|
-
it '
|
38
|
+
it 'parses JSON data' do
|
39
39
|
expect(subject.load(my_fixture.read)).to eql my_fixture.from_json
|
40
40
|
end
|
41
41
|
```
|
42
42
|
|
43
|
+
```ruby
|
44
|
+
it 'contains same filenames as fixture directory' do
|
45
|
+
# `#dirname` delegated to underlying `Pathname` object, returning a new `Pathname` instance:
|
46
|
+
expect(subject.created_files).to eql my_fixture.dirname.entries
|
47
|
+
end
|
48
|
+
```
|
49
|
+
|
43
50
|
The following methods are provided on the `Fixture` object:
|
44
51
|
|
45
52
|
|Method|Definition|
|
@@ -50,6 +57,8 @@ The following methods are provided on the `Fixture` object:
|
|
50
57
|
|`#from_yaml`|The parsed _YAML_ content from the file (aliased as `#from_yml`)|
|
51
58
|
|`#from_xml`|The parsed _XML_ content from the file (requires the [_Nokogiri_](https://nokogiri.org/) gem and returns a `Nokogiri::XML::Document`)|
|
52
59
|
|
60
|
+
Methods not specifically defined above are delegated to the underlying `Pathname` object (`#join`, `#dirname`, `#mkpath`, etc.). See the [Pathname documentation](https://ruby-doc.org/stdlib-2.7.5/libdoc/pathname/rdoc/Pathname.html) for more details.
|
61
|
+
|
53
62
|
### Symbolize Names
|
54
63
|
|
55
64
|
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:
|
@@ -43,6 +43,18 @@ module RSpecFileFixtures
|
|
43
43
|
|
44
44
|
private
|
45
45
|
|
46
|
+
def method_missing(method_name, *args)
|
47
|
+
return pathname.public_send(method_name, *args) if respond_to_missing?(method_name)
|
48
|
+
|
49
|
+
super
|
50
|
+
end
|
51
|
+
|
52
|
+
def respond_to_missing?(method_name, _ = false)
|
53
|
+
return true if pathname.respond_to?(method_name)
|
54
|
+
|
55
|
+
super
|
56
|
+
end
|
57
|
+
|
46
58
|
def pathname
|
47
59
|
@pathname ||= base_path.join(@raw_path)
|
48
60
|
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.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bob Farrell
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-03-
|
11
|
+
date: 2022-03-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -69,8 +69,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
69
69
|
- !ruby/object:Gem::Version
|
70
70
|
version: '0'
|
71
71
|
requirements: []
|
72
|
-
|
73
|
-
rubygems_version: 2.7.6.2
|
72
|
+
rubygems_version: 3.3.9
|
74
73
|
signing_key:
|
75
74
|
specification_version: 4
|
76
75
|
summary: Simple file fixture loader for RSpec
|