rspec-file_fixtures 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.ruby-version +1 -0
- data/Gemfile +16 -0
- data/Gemfile.lock +84 -0
- data/LICENSE.txt +21 -0
- data/Makefile +5 -0
- data/README.md +53 -0
- data/Rakefile +8 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/lib/rspec/file_fixtures.rb +25 -0
- data/lib/rspec/file_fixtures/fixture.rb +45 -0
- data/lib/rspec/file_fixtures/version.rb +7 -0
- data/rspec-file_fixtures.gemspec +26 -0
- metadata +61 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 219117ea610a1ea78ae84b2abff8a60b65581695a7de1a1806632f40870b4098
|
4
|
+
data.tar.gz: 92e40f4b983e72e158c77f621cd59c9c857bf3c3c4cdf7df16139b38e1247f3d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b1401aff9349871ee322c5c98df5549b96e8782db2eff6458af6974012adfa009bbcc6a60c5997e4ec3d9f497bd63c16626f79d8d9199842cb30b3efe54d72ec
|
7
|
+
data.tar.gz: fdebe93e851e33f810c31489fdb9feb337eabe35c26c2733aaf3d4d5102a2712b3abcf2a654bcebbcb41b1a1360ea7c7210ee9c67582b1c6df89ad814324fdad
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.5.3
|
data/Gemfile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source 'https://rubygems.org'
|
4
|
+
|
5
|
+
# Specify your gem's dependencies in rspec-file_fixtures.gemspec
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
gem 'devpack', '~> 0.3.2'
|
9
|
+
gem 'nokogiri', '~> 1.11'
|
10
|
+
gem 'rake', '~> 12.0'
|
11
|
+
gem 'rspec', '~> 3.0'
|
12
|
+
gem 'rspec-its', path: '../rspec-its'
|
13
|
+
gem 'rubocop', '~> 1.10'
|
14
|
+
gem 'rubocop-rake', '~> 0.5.1'
|
15
|
+
gem 'rubocop-rspec', '~> 2.1'
|
16
|
+
gem 'strong_versions', '~> 0.4.5'
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,84 @@
|
|
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
|
+
PATH
|
9
|
+
remote: .
|
10
|
+
specs:
|
11
|
+
rspec-file_fixtures (0.1.0)
|
12
|
+
|
13
|
+
GEM
|
14
|
+
remote: https://rubygems.org/
|
15
|
+
specs:
|
16
|
+
ast (2.4.2)
|
17
|
+
concurrent-ruby (1.1.8)
|
18
|
+
devpack (0.3.2)
|
19
|
+
diff-lcs (1.4.4)
|
20
|
+
i18n (1.8.9)
|
21
|
+
concurrent-ruby (~> 1.0)
|
22
|
+
nokogiri (1.11.1-x86_64-darwin)
|
23
|
+
racc (~> 1.4)
|
24
|
+
paint (2.2.1)
|
25
|
+
parallel (1.20.1)
|
26
|
+
parser (3.0.0.0)
|
27
|
+
ast (~> 2.4.1)
|
28
|
+
racc (1.5.2)
|
29
|
+
rainbow (3.0.0)
|
30
|
+
rake (12.3.3)
|
31
|
+
regexp_parser (2.0.3)
|
32
|
+
rexml (3.2.4)
|
33
|
+
rspec (3.10.0)
|
34
|
+
rspec-core (~> 3.10.0)
|
35
|
+
rspec-expectations (~> 3.10.0)
|
36
|
+
rspec-mocks (~> 3.10.0)
|
37
|
+
rspec-core (3.10.1)
|
38
|
+
rspec-support (~> 3.10.0)
|
39
|
+
rspec-expectations (3.10.1)
|
40
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
41
|
+
rspec-support (~> 3.10.0)
|
42
|
+
rspec-mocks (3.10.2)
|
43
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
44
|
+
rspec-support (~> 3.10.0)
|
45
|
+
rspec-support (3.10.2)
|
46
|
+
rubocop (1.10.0)
|
47
|
+
parallel (~> 1.10)
|
48
|
+
parser (>= 3.0.0.0)
|
49
|
+
rainbow (>= 2.2.2, < 4.0)
|
50
|
+
regexp_parser (>= 1.8, < 3.0)
|
51
|
+
rexml
|
52
|
+
rubocop-ast (>= 1.2.0, < 2.0)
|
53
|
+
ruby-progressbar (~> 1.7)
|
54
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
55
|
+
rubocop-ast (1.4.1)
|
56
|
+
parser (>= 2.7.1.5)
|
57
|
+
rubocop-rake (0.5.1)
|
58
|
+
rubocop
|
59
|
+
rubocop-rspec (2.2.0)
|
60
|
+
rubocop (~> 1.0)
|
61
|
+
rubocop-ast (>= 1.1.0)
|
62
|
+
ruby-progressbar (1.11.0)
|
63
|
+
strong_versions (0.4.5)
|
64
|
+
i18n (>= 0.5)
|
65
|
+
paint (~> 2.0)
|
66
|
+
unicode-display_width (2.0.0)
|
67
|
+
|
68
|
+
PLATFORMS
|
69
|
+
ruby
|
70
|
+
|
71
|
+
DEPENDENCIES
|
72
|
+
devpack (~> 0.3.2)
|
73
|
+
nokogiri (~> 1.11)
|
74
|
+
rake (~> 12.0)
|
75
|
+
rspec (~> 3.0)
|
76
|
+
rspec-file_fixtures!
|
77
|
+
rspec-its!
|
78
|
+
rubocop (~> 1.10)
|
79
|
+
rubocop-rake (~> 0.5.1)
|
80
|
+
rubocop-rspec (~> 2.1)
|
81
|
+
strong_versions (~> 0.4.5)
|
82
|
+
|
83
|
+
BUNDLED WITH
|
84
|
+
2.1.4
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2021 Bob Farrell
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/Makefile
ADDED
data/README.md
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# RSpec::FileFixtures
|
2
|
+
|
3
|
+
## Installation
|
4
|
+
|
5
|
+
Add this line to your application's Gemfile:
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
gem 'rspec-file_fixtures'
|
9
|
+
```
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle install
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install rspec-file_fixtures
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
Load the gem in your test environment (e.g. in `spec/spec_helper.rb`):
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
require 'rspec/file_fixtures'
|
25
|
+
```
|
26
|
+
|
27
|
+
Use the `fixture` helper method to load a fixture from `spec/fixtures`:
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
let(:my_fixture) { fixture('fixture.json') }
|
31
|
+
```
|
32
|
+
|
33
|
+
Use the returned `Fixture` object's various methods in your tests:
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
it 'loads data' do
|
37
|
+
expect(subject.load(my_fixture.read)).to eql my_fixture.json
|
38
|
+
end
|
39
|
+
```
|
40
|
+
|
41
|
+
The following methods are provided on the `Fixture` object:
|
42
|
+
|
43
|
+
|Method|Definition|
|
44
|
+
|-|-|
|
45
|
+
|`#read`|Read the contents of the fixture file as a string|
|
46
|
+
|`#path`|The absolute path to the fixture file|
|
47
|
+
|`#json`|The parsed _JSON_ content from the file|
|
48
|
+
|`#yaml`|The parsed _YAML_ content from the file|
|
49
|
+
|`#xml`|The parsed _XML_ content from the file (requires the [_Nokogiri_](https://nokogiri.org/) gem and returns a `Nokogiri::XML::Document`)|
|
50
|
+
|
51
|
+
## License
|
52
|
+
|
53
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'rspec/file_fixtures'
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require 'irb'
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'yaml'
|
4
|
+
require 'json'
|
5
|
+
require 'pathname'
|
6
|
+
|
7
|
+
require 'rspec'
|
8
|
+
|
9
|
+
require 'rspec/file_fixtures/version'
|
10
|
+
require 'rspec/file_fixtures/fixture'
|
11
|
+
|
12
|
+
module RSpec
|
13
|
+
# Provides a `fixture` method in all RSpec tests.
|
14
|
+
module FileFixtures
|
15
|
+
class Error < StandardError; end
|
16
|
+
|
17
|
+
def fixture(path)
|
18
|
+
Fixture.new(path)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
RSpec.configure do |config|
|
24
|
+
config.include(RSpec::FileFixtures)
|
25
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RSpec
|
4
|
+
module FileFixtures
|
5
|
+
# Provides access to the contents and location of a file fixture.
|
6
|
+
class Fixture
|
7
|
+
def initialize(raw_path)
|
8
|
+
@raw_path = raw_path
|
9
|
+
end
|
10
|
+
|
11
|
+
def read
|
12
|
+
pathname.read
|
13
|
+
end
|
14
|
+
|
15
|
+
def yaml
|
16
|
+
YAML.safe_load(read, symbolize_names: true)
|
17
|
+
end
|
18
|
+
|
19
|
+
alias yml yaml
|
20
|
+
|
21
|
+
def xml
|
22
|
+
require 'nokogiri'
|
23
|
+
Nokogiri::XML.parse(read)
|
24
|
+
end
|
25
|
+
|
26
|
+
def path
|
27
|
+
pathname.realpath.to_s
|
28
|
+
end
|
29
|
+
|
30
|
+
def json
|
31
|
+
JSON.parse(read, symbolize_names: true)
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def pathname
|
37
|
+
@pathname ||= base_path.join(@raw_path)
|
38
|
+
end
|
39
|
+
|
40
|
+
def base_path
|
41
|
+
Pathname.new(File.join('spec', 'fixtures'))
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'lib/rspec/file_fixtures/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'rspec-file_fixtures'
|
7
|
+
spec.version = RSpec::FileFixtures::VERSION
|
8
|
+
spec.authors = ['Bob Farrell']
|
9
|
+
spec.email = ['git@bob.frl']
|
10
|
+
|
11
|
+
spec.summary = 'Simple file fixture loader for RSpec'
|
12
|
+
spec.description = 'Load files from test fixtures directory quickly and conveniently'
|
13
|
+
spec.homepage = 'https://github.com/bobf/rspec-file_fixtures'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 2.5.0')
|
16
|
+
|
17
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
18
|
+
spec.metadata['source_code_uri'] = spec.homepage
|
19
|
+
|
20
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
21
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
22
|
+
end
|
23
|
+
spec.bindir = 'bin'
|
24
|
+
spec.executables = []
|
25
|
+
spec.require_paths = ['lib']
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rspec-file_fixtures
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Bob Farrell
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-02-21 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Load files from test fixtures directory quickly and conveniently
|
14
|
+
email:
|
15
|
+
- git@bob.frl
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- ".gitignore"
|
21
|
+
- ".rspec"
|
22
|
+
- ".ruby-version"
|
23
|
+
- Gemfile
|
24
|
+
- Gemfile.lock
|
25
|
+
- LICENSE.txt
|
26
|
+
- Makefile
|
27
|
+
- README.md
|
28
|
+
- Rakefile
|
29
|
+
- bin/console
|
30
|
+
- bin/setup
|
31
|
+
- lib/rspec/file_fixtures.rb
|
32
|
+
- lib/rspec/file_fixtures/fixture.rb
|
33
|
+
- lib/rspec/file_fixtures/version.rb
|
34
|
+
- rspec-file_fixtures.gemspec
|
35
|
+
homepage: https://github.com/bobf/rspec-file_fixtures
|
36
|
+
licenses:
|
37
|
+
- MIT
|
38
|
+
metadata:
|
39
|
+
homepage_uri: https://github.com/bobf/rspec-file_fixtures
|
40
|
+
source_code_uri: https://github.com/bobf/rspec-file_fixtures
|
41
|
+
post_install_message:
|
42
|
+
rdoc_options: []
|
43
|
+
require_paths:
|
44
|
+
- lib
|
45
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 2.5.0
|
50
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
requirements: []
|
56
|
+
rubyforge_project:
|
57
|
+
rubygems_version: 2.7.6
|
58
|
+
signing_key:
|
59
|
+
specification_version: 4
|
60
|
+
summary: Simple file fixture loader for RSpec
|
61
|
+
test_files: []
|