rspec-file_fixtures 0.1.7 → 0.1.9

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: 5194a0d2db316e9e13a780c7e33a1af9a6ea1869c0ab254ee3e462fceb446ecc
4
- data.tar.gz: 734ed79bf2a160cd694cf3a5a8be8eef3278a08ae7c2aae2a00c6d12b263b4ba
3
+ metadata.gz: '093408a94e9e51ba94c4f4635a34074e49e4d1b7b10190a13507e57a3bf60141'
4
+ data.tar.gz: d53f862a7af51f91c39d60e540b40165e834f97404a6884a8c969d6b362c33e3
5
5
  SHA512:
6
- metadata.gz: 1ef7bdc977c831a897242bc1e215865cd7b3c7246cf612e020f51fe1a90242f2e4ce6447eac47c0f0cb654558e44f9b86966166bd3495bf636225c6e441c5e72
7
- data.tar.gz: d34793287afaf62c2a5e35c5337031b969ec034917f4a29761eac902325f594f81535d2380e01357c08e6aa2072c0603198a107f1b263783a474ce5c6655a7ed
6
+ metadata.gz: c888bf111292b125e6e8adeac538a0da5e94f861de1033e1154376210135cea3bf1622ef192bbecfa2d6a9de91c9b4e458edb6f998e91c6e9c8cc936431685e4
7
+ data.tar.gz: b3002dc69032e39af2e889ff7bfc8ea857dc66e355375150b98ca7ec35ef48c093df2a5d7af9c1d31cf118b5b20b597a24c9b38bfe9903c8e3bcfa11a050fd9b
data/.rubocop.yml CHANGED
@@ -1,3 +1,6 @@
1
+ require:
2
+ - rubocop-rspec-documentation
3
+
1
4
  AllCops:
2
5
  NewCops: enable
3
6
 
data/Gemfile CHANGED
@@ -7,6 +7,7 @@ gemspec
7
7
 
8
8
  gem 'devpack', '~> 0.4.1'
9
9
  gem 'nokogiri', '~> 1.15'
10
+ gem 'rack-test', '~> 2.1'
10
11
  gem 'rake', '~> 13.0'
11
12
  gem 'rspec', '~> 3.12'
12
13
  gem 'rspec-documentation', '~> 0.0.5'
@@ -14,4 +15,5 @@ gem 'rspec-its', '~> 1.3'
14
15
  gem 'rubocop', '~> 1.52'
15
16
  gem 'rubocop-rake', '~> 0.6.0'
16
17
  gem 'rubocop-rspec', '~> 2.22'
18
+ gem 'rubocop-rspec-documentation', '~> 0.0.2'
17
19
  gem 'strong_versions', '~> 0.4.5'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rspec-file_fixtures (0.1.6)
4
+ rspec-file_fixtures (0.1.9)
5
5
  rspec (~> 3.12)
6
6
 
7
7
  GEM
@@ -29,9 +29,11 @@ GEM
29
29
  parser (3.2.2.1)
30
30
  ast (~> 2.4.1)
31
31
  racc (1.6.2)
32
+ rack (3.0.8)
33
+ rack-test (2.1.0)
34
+ rack (>= 1.3)
32
35
  rainbow (3.1.1)
33
36
  rake (13.0.6)
34
- redcarpet (3.6.0)
35
37
  regexp_parser (2.8.0)
36
38
  rexml (3.2.5)
37
39
  rouge (4.1.2)
@@ -41,13 +43,12 @@ GEM
41
43
  rspec-mocks (~> 3.12.0)
42
44
  rspec-core (3.12.2)
43
45
  rspec-support (~> 3.12.0)
44
- rspec-documentation (0.0.5)
46
+ rspec-documentation (0.0.11)
45
47
  htmlbeautifier (~> 1.4)
46
48
  kramdown (~> 2.4)
47
49
  kramdown-parser-gfm (~> 1.1)
48
50
  nokogiri (~> 1.15)
49
51
  paintbrush (~> 0.1.3)
50
- redcarpet (~> 3.6)
51
52
  rouge (~> 4.1)
52
53
  rspec (~> 3.12)
53
54
  rspec-expectations (3.12.3)
@@ -82,6 +83,9 @@ GEM
82
83
  rubocop (~> 1.33)
83
84
  rubocop-capybara (~> 2.17)
84
85
  rubocop-factory_bot (~> 2.22)
86
+ rubocop-rspec-documentation (0.0.2)
87
+ rspec-documentation (~> 0.0.7)
88
+ rubocop (~> 1.52)
85
89
  ruby-progressbar (1.13.0)
86
90
  strong_versions (0.4.5)
87
91
  i18n (>= 0.5)
@@ -94,6 +98,7 @@ PLATFORMS
94
98
  DEPENDENCIES
95
99
  devpack (~> 0.4.1)
96
100
  nokogiri (~> 1.15)
101
+ rack-test (~> 2.1)
97
102
  rake (~> 13.0)
98
103
  rspec (~> 3.12)
99
104
  rspec-documentation (~> 0.0.5)
@@ -102,7 +107,8 @@ DEPENDENCIES
102
107
  rubocop (~> 1.52)
103
108
  rubocop-rake (~> 0.6.0)
104
109
  rubocop-rspec (~> 2.22)
110
+ rubocop-rspec-documentation (~> 0.0.2)
105
111
  strong_versions (~> 0.4.5)
106
112
 
107
113
  BUNDLED WITH
108
- 2.4.13
114
+ 2.4.14
data/Makefile CHANGED
@@ -13,5 +13,5 @@ test:
13
13
  .PHONY: publish
14
14
  publish:
15
15
  @RSPEC_DOCUMENTATION_URL_ROOT='/$(project)' bundle exec rspec-documentation
16
- @rsync --delete -r rspec-documentation/bundle/ docs01.bob.frl:/mnt/docs/$(project)/
16
+ @rsync --delete -r rspec-documentation/bundle/ docs.bob.frl:/var/www/html/$(project)/
17
17
  @echo 'Published.'
@@ -11,6 +11,15 @@ module RSpecFileFixtures
11
11
  pathname.read
12
12
  end
13
13
 
14
+ def copy_to(destination)
15
+ Pathname.new(destination).dirname.mkpath
16
+ FileUtils.copy(pathname, destination)
17
+ end
18
+
19
+ def upload(content_type:)
20
+ Rack::Test::UploadedFile.new(path, content_type)
21
+ end
22
+
14
23
  def from_xml
15
24
  require 'nokogiri'
16
25
  Nokogiri::XML.parse(read)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RSpecFileFixtures
4
- VERSION = '0.1.7'
4
+ VERSION = '0.1.9'
5
5
  end
@@ -0,0 +1,16 @@
1
+ # Copy_to
2
+
3
+ You can use the `#copy_to(destination)` method to copy the fixture file to the destination path. The `#copy_to` method expects a path or string. See examples at [FileUtils#cp](https://rubyapi.org/3.3/o/fileutils#method-i-cp) method, which this method basically wraps. By using `#copy_to`, you can achieve faster file copying compared to the `File#read` then `File#write` approach, as it avoids loading the entire file into memory.
4
+
5
+ ```rspec:json
6
+ subject { File.read(destination_path).chomp }
7
+
8
+ let(:example_fixture) { fixture('example.json') }
9
+ let(:destination_path) { File.join(Dir.mktmpdir, 'path/to/destination/copied.json') }
10
+
11
+ before { example_fixture.copy_to(destination_path) }
12
+
13
+ after { File.unlink(destination_path) }
14
+
15
+ it { is_expected.to eql '{"key":"value"}' }
16
+ ```
@@ -0,0 +1,11 @@
1
+ # Upload
2
+
3
+ Create a `Rack::Test::UploadedFile` instance by calling `#upload(content_type: 'image/png')` (e.g.).
4
+
5
+ The returned object can be passed as a parameter in a _request_ spec to simulate uploading a file.
6
+
7
+ ```rspec
8
+ subject { fixture('example.xml').upload(content_type: 'application/xml') }
9
+
10
+ it { is_expected.to be_a Rack::Test::UploadedFile }
11
+ ```
@@ -1,3 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'tempfile'
4
+
3
5
  require 'rspec/file_fixtures'
6
+ require 'rack/test/uploaded_file'
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.7
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bob Farrell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-05 00:00:00.000000000 Z
11
+ date: 2023-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -52,7 +52,9 @@ files:
52
52
  - rspec-documentation/pages/010-Usage/010-JSON.md
53
53
  - rspec-documentation/pages/010-Usage/020-YAML.md
54
54
  - rspec-documentation/pages/010-Usage/030-XML.md
55
- - rspec-documentation/pages/010-Usage/040-Pathname.md
55
+ - rspec-documentation/pages/010-Usage/040-Copy_to.md
56
+ - rspec-documentation/pages/010-Usage/050-Pathname.md
57
+ - rspec-documentation/pages/010-Usage/060-Upload.md
56
58
  - rspec-documentation/pages/500-License.md
57
59
  - rspec-documentation/spec_helper.rb
58
60
  - rspec-file_fixtures.gemspec