rspec-middlewares 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +50 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +43 -0
- data/LICENSE +21 -0
- data/README.md +54 -0
- data/lib/rspec-middlewares/main.rb +11 -0
- data/lib/rspec-middlewares/sidekiq.rb +11 -0
- data/lib/rspec-middlewares/timecop.rb +26 -0
- data/lib/rspec-middlewares/timezone.rb +12 -0
- data/lib/rspec-middlewares/vcr.rb +23 -0
- data/lib/rspec-middlewares/version.rb +3 -0
- data/lib/rspec-middlewares.rb +7 -0
- data/rspec-middlewares.gemspec +28 -0
- metadata +140 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 432c7c00904a53688c75154dc3ba1738515f7ac7
|
4
|
+
data.tar.gz: 8cc0be86173bb6c2b66afe22eee18eaf72d29349
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 61c95112fc5c3359c9dba31c6f1e6c19e495952b118dc2cf13b6731358b149ae17ecf19cdb8911c61b775c78ea1aa86b777b719d726d45539f7af16c3ababab3
|
7
|
+
data.tar.gz: f0a0f4e78b931a2a3c6415691f45ae9a28f810d010f566243e3f203b192d1786a29a268639bd45c56f6de6e6a4c0f3ceeab176ac93c88f2545d19517a71faf56
|
data/.gitignore
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/spec/examples.txt
|
9
|
+
/test/tmp/
|
10
|
+
/test/version_tmp/
|
11
|
+
/tmp/
|
12
|
+
|
13
|
+
# Used by dotenv library to load environment variables.
|
14
|
+
# .env
|
15
|
+
|
16
|
+
## Specific to RubyMotion:
|
17
|
+
.dat*
|
18
|
+
.repl_history
|
19
|
+
build/
|
20
|
+
*.bridgesupport
|
21
|
+
build-iPhoneOS/
|
22
|
+
build-iPhoneSimulator/
|
23
|
+
|
24
|
+
## Specific to RubyMotion (use of CocoaPods):
|
25
|
+
#
|
26
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
27
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
28
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
29
|
+
#
|
30
|
+
# vendor/Pods/
|
31
|
+
|
32
|
+
## Documentation cache and generated files:
|
33
|
+
/.yardoc/
|
34
|
+
/_yardoc/
|
35
|
+
/doc/
|
36
|
+
/rdoc/
|
37
|
+
|
38
|
+
## Environment normalization:
|
39
|
+
/.bundle/
|
40
|
+
/vendor/bundle
|
41
|
+
/lib/bundler/man/
|
42
|
+
|
43
|
+
# for a library or gem, you might want to ignore these files since the code is
|
44
|
+
# intended to run in multiple environments; otherwise, check them in:
|
45
|
+
# Gemfile.lock
|
46
|
+
# .ruby-version
|
47
|
+
# .ruby-gemset
|
48
|
+
|
49
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
50
|
+
.rvmrc
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
rspec-middlewares (0.0.1)
|
5
|
+
rspec (~> 3.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
diff-lcs (1.3)
|
11
|
+
ibsciss-middleware (0.4.1)
|
12
|
+
rake (0.9.6)
|
13
|
+
rspec (3.5.0)
|
14
|
+
rspec-core (~> 3.5.0)
|
15
|
+
rspec-expectations (~> 3.5.0)
|
16
|
+
rspec-mocks (~> 3.5.0)
|
17
|
+
rspec-core (3.5.4)
|
18
|
+
rspec-support (~> 3.5.0)
|
19
|
+
rspec-expectations (3.5.0)
|
20
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
21
|
+
rspec-support (~> 3.5.0)
|
22
|
+
rspec-mocks (3.5.0)
|
23
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
24
|
+
rspec-support (~> 3.5.0)
|
25
|
+
rspec-support (3.5.0)
|
26
|
+
rubygems-tasks (0.2.4)
|
27
|
+
|
28
|
+
PLATFORMS
|
29
|
+
ruby
|
30
|
+
|
31
|
+
DEPENDENCIES
|
32
|
+
bundler (~> 1.0)
|
33
|
+
ibsciss-middleware
|
34
|
+
rake (~> 0.8)
|
35
|
+
rspec
|
36
|
+
rspec-middlewares!
|
37
|
+
rubygems-tasks (~> 0.2)
|
38
|
+
|
39
|
+
RUBY VERSION
|
40
|
+
ruby 2.3.3p222
|
41
|
+
|
42
|
+
BUNDLED WITH
|
43
|
+
1.14.4
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2017 IMRealtor
|
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 all
|
13
|
+
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 THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# rspec-middlewares
|
2
|
+
A set of helpful middlewares for useage with rspec.
|
3
|
+
|
4
|
+
#Useage
|
5
|
+
|
6
|
+
```> gem install rspec-middlewares```
|
7
|
+
|
8
|
+
In ```spec-helper.rb``` or ```rails_helper.rb```.
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
require 'rspec-middlewares'
|
12
|
+
|
13
|
+
Rspec.configure do |config|
|
14
|
+
config.around(:each) do |test|
|
15
|
+
stack = Middleware::Builder.new do |builder|
|
16
|
+
if test.metadata[:timezone].present?
|
17
|
+
builder.use RspecMiddlewares::Timezone, timezone: test.metadata[:timezone]
|
18
|
+
end
|
19
|
+
|
20
|
+
if test.metadata[:current_time].present?
|
21
|
+
builder.use RspecMiddlewares::Timecop, current_time: test.metadata[:current_time]
|
22
|
+
end
|
23
|
+
|
24
|
+
if test.metadata[:freeze_time].present?
|
25
|
+
builder.use RspecMiddlewares::Timecop, freeze_time: test.metadata[:freeze_time]
|
26
|
+
end
|
27
|
+
|
28
|
+
if test.metadata[:record].present?
|
29
|
+
builder.use RspecMiddlewares::VCR,
|
30
|
+
cassette_name: test.metadata[:cassette_name],
|
31
|
+
record: test.metadata[:record],
|
32
|
+
match_requests_on: test.metadata[:match_requests_on]
|
33
|
+
end
|
34
|
+
builder.use TestMiddlewares::Sidekiq if test.metadata[:run_jobs]
|
35
|
+
builder.use TestMiddlewares::Main
|
36
|
+
end
|
37
|
+
|
38
|
+
stack.call test: test
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
```
|
43
|
+
|
44
|
+
Then in your tests
|
45
|
+
```ruby
|
46
|
+
require 'rails_helper'
|
47
|
+
|
48
|
+
describe MyTest,
|
49
|
+
record: :all,
|
50
|
+
match_requests_on: [:method, :host, :path] do
|
51
|
+
# each of your tests will now be run with the VCR middleware enabled.
|
52
|
+
end
|
53
|
+
|
54
|
+
```
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module RspecMiddlewares
|
2
|
+
class Timecop
|
3
|
+
def initialize(app, current_time: nil, freeze_time: nil)
|
4
|
+
@app = app
|
5
|
+
@current_time = current_time
|
6
|
+
@freeze_time = freeze_time
|
7
|
+
end
|
8
|
+
|
9
|
+
def call(env)
|
10
|
+
if @current_time.present?
|
11
|
+
::Timecop.travel(time) { @app.call env }
|
12
|
+
elsif @freeze_time.present?
|
13
|
+
::Timecop.travel(frozen_time) { @app.call env }
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
def frozen_time
|
19
|
+
Time.zone.parse(@freeze_time)
|
20
|
+
end
|
21
|
+
|
22
|
+
def time
|
23
|
+
Time.zone.parse(@current_time)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module RspecMiddlewares
|
2
|
+
class VCR
|
3
|
+
def initialize(app, cassette_name: nil, record:, match_requests_on:)
|
4
|
+
@app = app
|
5
|
+
@cassette_name = cassette_name
|
6
|
+
@record = record || :once
|
7
|
+
@match_requests_on = match_requests_on || [:method, :uri, :body]
|
8
|
+
end
|
9
|
+
|
10
|
+
def call(env)
|
11
|
+
::VCR.use_cassette((@cassette_name || derived_cassette_name(env)), record: @record, match_requests_on: @match_requests_on) do
|
12
|
+
@app.call env
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def derived_cassette_name(env)
|
17
|
+
directory = env[:test].file_path.gsub("_spec.rb", "").gsub("./spec/", "") + "/"
|
18
|
+
filename = env[:test].full_description.underscore.downcase.gsub(/[^\w]/, "_")
|
19
|
+
|
20
|
+
directory + filename
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require File.expand_path('../lib/rspec-middlewares/version', __FILE__)
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.name = "rspec-middlewares"
|
7
|
+
gem.version = RspecMiddlewares::VERSION
|
8
|
+
gem.summary = "Rspec middleware meta helpers"
|
9
|
+
gem.description = "."
|
10
|
+
gem.license = "MIT"
|
11
|
+
gem.authors = ["Bram Whillock"]
|
12
|
+
gem.email = "bramski@gmail.com"
|
13
|
+
gem.homepage = "https://github.com/imrealtor/rspec-middlewares"
|
14
|
+
gem.required_ruby_version = '~> 2.3'
|
15
|
+
|
16
|
+
gem.files = `git ls-files`.split($/)
|
17
|
+
gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
|
18
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
19
|
+
gem.require_paths = ['lib']
|
20
|
+
|
21
|
+
gem.add_dependency "rspec", "~> 3.0"
|
22
|
+
gem.add_dependency 'ibciss-middleware', "~> 0.4.0"
|
23
|
+
|
24
|
+
gem.add_development_dependency 'bundler', '~> 1.0'
|
25
|
+
gem.add_development_dependency 'rake', '~> 0.8'
|
26
|
+
gem.add_development_dependency 'rspec', '~> 3.3'
|
27
|
+
gem.add_development_dependency 'rubygems-tasks', '~> 0.2'
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,140 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rspec-middlewares
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Bram Whillock
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-03-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: ibciss-middleware
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.4.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.4.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.8'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.8'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.3'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.3'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rubygems-tasks
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.2'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.2'
|
97
|
+
description: "."
|
98
|
+
email: bramski@gmail.com
|
99
|
+
executables: []
|
100
|
+
extensions: []
|
101
|
+
extra_rdoc_files: []
|
102
|
+
files:
|
103
|
+
- ".gitignore"
|
104
|
+
- Gemfile
|
105
|
+
- Gemfile.lock
|
106
|
+
- LICENSE
|
107
|
+
- README.md
|
108
|
+
- lib/rspec-middlewares.rb
|
109
|
+
- lib/rspec-middlewares/main.rb
|
110
|
+
- lib/rspec-middlewares/sidekiq.rb
|
111
|
+
- lib/rspec-middlewares/timecop.rb
|
112
|
+
- lib/rspec-middlewares/timezone.rb
|
113
|
+
- lib/rspec-middlewares/vcr.rb
|
114
|
+
- lib/rspec-middlewares/version.rb
|
115
|
+
- rspec-middlewares.gemspec
|
116
|
+
homepage: https://github.com/imrealtor/rspec-middlewares
|
117
|
+
licenses:
|
118
|
+
- MIT
|
119
|
+
metadata: {}
|
120
|
+
post_install_message:
|
121
|
+
rdoc_options: []
|
122
|
+
require_paths:
|
123
|
+
- lib
|
124
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - "~>"
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: '2.3'
|
129
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - ">="
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
requirements: []
|
135
|
+
rubyforge_project:
|
136
|
+
rubygems_version: 2.5.2
|
137
|
+
signing_key:
|
138
|
+
specification_version: 4
|
139
|
+
summary: Rspec middleware meta helpers
|
140
|
+
test_files: []
|