nxt_vcr_harness 0.1.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 3aca026840674f9396cfd43479e3ed694a5269d5aeb7e60e18454477fbd88e11
4
+ data.tar.gz: 21c4b9e33c2fee21820d4d528deb6875816cc633ae7111dd8f8f64ad43b696c2
5
+ SHA512:
6
+ metadata.gz: 246948e4309eba51c83d40e0d83c9606192821ed44b77d0b3d601de785a0bcaed87118634dd10b9961eff63985a394cfac6a85f6f7af64172b0255ff2702b7a3
7
+ data.tar.gz: 8a78e3940884d2efc47f726241b7aff5d58d0b7bd117dd72c7713756b4d1348f2088d94467b0b168af808c7927207eeee2d5cdb977c671fd87e4855e704be8ee
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+ !/**/.keep
13
+ /storage/
14
+ .idea/
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.6.1
7
+ before_install: gem install bundler -v 1.17.2
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in nxt_vcr_harness.gemspec
6
+ gemspec
@@ -0,0 +1,38 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ nxt_vcr_harness (0.1.0)
5
+ rspec (~> 3.0)
6
+ vcr (~> 4.0)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ diff-lcs (1.3)
12
+ rake (10.5.0)
13
+ rspec (3.8.0)
14
+ rspec-core (~> 3.8.0)
15
+ rspec-expectations (~> 3.8.0)
16
+ rspec-mocks (~> 3.8.0)
17
+ rspec-core (3.8.0)
18
+ rspec-support (~> 3.8.0)
19
+ rspec-expectations (3.8.2)
20
+ diff-lcs (>= 1.2.0, < 2.0)
21
+ rspec-support (~> 3.8.0)
22
+ rspec-mocks (3.8.0)
23
+ diff-lcs (>= 1.2.0, < 2.0)
24
+ rspec-support (~> 3.8.0)
25
+ rspec-support (3.8.0)
26
+ vcr (4.0.0)
27
+
28
+ PLATFORMS
29
+ ruby
30
+
31
+ DEPENDENCIES
32
+ bundler (~> 1.17)
33
+ nxt_vcr_harness!
34
+ rake (~> 10.0)
35
+ rspec (~> 3.0)
36
+
37
+ BUNDLED WITH
38
+ 1.17.2
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Andreas Robecke
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.
@@ -0,0 +1,39 @@
1
+ # NxtVcrHarness
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/nxt_vcr_harness`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'nxt_vcr_harness'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install nxt_vcr_harness
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/nxt_vcr_harness.
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "nxt_vcr_harness"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,19 @@
1
+ require "nxt_vcr_harness/version"
2
+ require 'nxt_vcr_harness/cassette_name_by_example'
3
+
4
+ module NxtVcrHarness
5
+ def configure(tag_name = :vcr_cassette)
6
+ RSpec.configure do |config|
7
+ config.around(:each, tag_name) do |example|
8
+ cassette_path = CassetteNameByExample.new(example).call
9
+ vcr_options = example.metadata[tag_name].is_a?(TrueClass) ? { } : example.metadata[tag_name]
10
+
11
+ VCR.use_cassette(cassette_path, **vcr_options) do
12
+ example.call
13
+ end
14
+ end
15
+ end
16
+ end
17
+
18
+ module_function :configure
19
+ end
@@ -0,0 +1,57 @@
1
+ class CassetteNameByExample
2
+ def initialize(example)
3
+ @example = example
4
+ end
5
+
6
+ attr_reader :example
7
+
8
+ def call
9
+ cassette_name_and_path
10
+ end
11
+
12
+ def cassette_name_and_path
13
+ spec_path = example.file_path.gsub(/\.rb$/, '').gsub('./spec/', '/')
14
+ [spec_path, cassette_name_from_descriptions].join('/')
15
+ end
16
+
17
+ def cassette_name_from_descriptions
18
+ descriptions = context_hierarchy_with_vcr_cassette_tags.map { |c| c[:description] }
19
+ descriptions.map(&method(:gsub_whitespace)).map(&method(:remove_hash_tags))
20
+ end
21
+
22
+ def gsub_whitespace(name)
23
+ name.gsub(/\s+/, '_')
24
+ end
25
+
26
+ def remove_hash_tags(name)
27
+ name.delete('#')
28
+ end
29
+
30
+ def context_hierarchy_with_vcr_cassette_tags
31
+ @context_hierarchy_with_vcr_cassette_tags ||= begin
32
+ context_hierarchy.reverse.inject([]) do |acc, context|
33
+ acc << context
34
+ break acc if context[:vcr_cassette]
35
+
36
+ acc
37
+ end
38
+ end
39
+ end
40
+
41
+ def context_hierarchy
42
+ @context_hierarchy ||= begin
43
+ context_hierarchy = [example.metadata]
44
+ example_group = example.metadata[:example_group]
45
+ context_hierarchy << example_group
46
+
47
+ while parent_example_group = example_group[:parent_example_group] do
48
+ context_hierarchy << parent_example_group
49
+ example_group = parent_example_group
50
+ end
51
+
52
+ context_hierarchy
53
+ rescue StandardError => e
54
+ raise StandardError, "Failed to build context hierarchy for example: #{example} - Error was: #{e.inspect}"
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,3 @@
1
+ module NxtVcrHarness
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,44 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "nxt_vcr_harness/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "nxt_vcr_harness"
8
+ spec.version = NxtVcrHarness::VERSION
9
+ spec.authors = ["Andreas Robecke", "Nils Sommer", "Raphael Kallensee"]
10
+ spec.email = ["a.robecke@getsafe.de"]
11
+
12
+ spec.summary = %q{Intuitive VCR cassette naming}
13
+ spec.description = %q{Names your vcr cassettes based on your rspec examples and let's you pass in options on the fly}
14
+ spec.homepage = "https://github.com/nxt-insurance"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ if spec.respond_to?(:metadata)
20
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
21
+
22
+ spec.metadata["homepage_uri"] = spec.homepage
23
+ spec.metadata["source_code_uri"] = "https://github.com/nxt-insurance/nxt_vcr_harness"
24
+ else
25
+ raise "RubyGems 2.0 or newer is required to protect against " \
26
+ "public gem pushes."
27
+ end
28
+
29
+ # Specify which files should be added to the gem when it is released.
30
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
31
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
32
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
33
+ end
34
+ spec.bindir = "exe"
35
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
36
+ spec.require_paths = ["lib"]
37
+
38
+ spec.add_dependency "rspec", "~> 3.0"
39
+ spec.add_dependency "vcr", "~> 4.0"
40
+
41
+ spec.add_development_dependency "bundler", "~> 1.17"
42
+ spec.add_development_dependency "rake", "~> 10.0"
43
+ spec.add_development_dependency "rspec", "~> 3.0"
44
+ end
metadata ADDED
@@ -0,0 +1,133 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nxt_vcr_harness
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Andreas Robecke
8
+ - Nils Sommer
9
+ - Raphael Kallensee
10
+ autorequire:
11
+ bindir: exe
12
+ cert_chain: []
13
+ date: 2019-02-20 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rspec
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - "~>"
20
+ - !ruby/object:Gem::Version
21
+ version: '3.0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - "~>"
27
+ - !ruby/object:Gem::Version
28
+ version: '3.0'
29
+ - !ruby/object:Gem::Dependency
30
+ name: vcr
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - "~>"
34
+ - !ruby/object:Gem::Version
35
+ version: '4.0'
36
+ type: :runtime
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - "~>"
41
+ - !ruby/object:Gem::Version
42
+ version: '4.0'
43
+ - !ruby/object:Gem::Dependency
44
+ name: bundler
45
+ requirement: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '1.17'
50
+ type: :development
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - "~>"
55
+ - !ruby/object:Gem::Version
56
+ version: '1.17'
57
+ - !ruby/object:Gem::Dependency
58
+ name: rake
59
+ requirement: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - "~>"
62
+ - !ruby/object:Gem::Version
63
+ version: '10.0'
64
+ type: :development
65
+ prerelease: false
66
+ version_requirements: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - "~>"
69
+ - !ruby/object:Gem::Version
70
+ version: '10.0'
71
+ - !ruby/object:Gem::Dependency
72
+ name: rspec
73
+ requirement: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - "~>"
76
+ - !ruby/object:Gem::Version
77
+ version: '3.0'
78
+ type: :development
79
+ prerelease: false
80
+ version_requirements: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - "~>"
83
+ - !ruby/object:Gem::Version
84
+ version: '3.0'
85
+ description: Names your vcr cassettes based on your rspec examples and let's you pass
86
+ in options on the fly
87
+ email:
88
+ - a.robecke@getsafe.de
89
+ executables: []
90
+ extensions: []
91
+ extra_rdoc_files: []
92
+ files:
93
+ - ".gitignore"
94
+ - ".rspec"
95
+ - ".travis.yml"
96
+ - Gemfile
97
+ - Gemfile.lock
98
+ - LICENSE.txt
99
+ - README.md
100
+ - Rakefile
101
+ - bin/console
102
+ - bin/setup
103
+ - lib/nxt_vcr_harness.rb
104
+ - lib/nxt_vcr_harness/cassette_name_by_example.rb
105
+ - lib/nxt_vcr_harness/version.rb
106
+ - nxt_vcr_harness.gemspec
107
+ homepage: https://github.com/nxt-insurance
108
+ licenses:
109
+ - MIT
110
+ metadata:
111
+ allowed_push_host: https://rubygems.org
112
+ homepage_uri: https://github.com/nxt-insurance
113
+ source_code_uri: https://github.com/nxt-insurance/nxt_vcr_harness
114
+ post_install_message:
115
+ rdoc_options: []
116
+ require_paths:
117
+ - lib
118
+ required_ruby_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ required_rubygems_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ requirements: []
129
+ rubygems_version: 3.0.1
130
+ signing_key:
131
+ specification_version: 4
132
+ summary: Intuitive VCR cassette naming
133
+ test_files: []