rspec-repetitive 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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 12a9d6e6f1de32209fb33488bd190368dac720666b07d14f7e66c8241195f8cc
4
+ data.tar.gz: 0a7d4b5a230380cb6b7e674511e0c00750ae7210b6e88d78d9fa09943b56311a
5
+ SHA512:
6
+ metadata.gz: 0ec33e6016846afa5dd6d090ae3e29b721cf6c535fb4729fc85589cdd241a402ad9d83662275c7ab492924bdf350e76c40405db2d4149a522b3ba568e5381706
7
+ data.tar.gz: 8031a3f402e4e0c9bbdc6c82dc05be5ccb165dc7ae98c8d136ca93a37a55b9140c3fc5399acea95e630548cf4f16f4b612d478fdea1b1b4f5d90905c1da5800d
data/.gitignore ADDED
@@ -0,0 +1,11 @@
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
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,33 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ rspec-repetitive (0.1.0)
5
+ rspec-core (~> 3.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ diff-lcs (1.3)
11
+ rspec (3.8.0)
12
+ rspec-core (~> 3.8.0)
13
+ rspec-expectations (~> 3.8.0)
14
+ rspec-mocks (~> 3.8.0)
15
+ rspec-core (3.8.0)
16
+ rspec-support (~> 3.8.0)
17
+ rspec-expectations (3.8.2)
18
+ diff-lcs (>= 1.2.0, < 2.0)
19
+ rspec-support (~> 3.8.0)
20
+ rspec-mocks (3.8.0)
21
+ diff-lcs (>= 1.2.0, < 2.0)
22
+ rspec-support (~> 3.8.0)
23
+ rspec-support (3.8.0)
24
+
25
+ PLATFORMS
26
+ ruby
27
+
28
+ DEPENDENCIES
29
+ rspec (~> 3.0)
30
+ rspec-repetitive!
31
+
32
+ BUNDLED WITH
33
+ 2.0.1
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Jamie English
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/README.md ADDED
@@ -0,0 +1,59 @@
1
+ # RSpec::Repetitive
2
+
3
+ Repetitive RSpec examples with custom setup.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'rspec-repetitive'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install rspec-repetitive
20
+
21
+ ## Usage
22
+
23
+ The following RSpec example would run twice: first without then with a feature switch enabled.
24
+
25
+ ```rb
26
+ require 'rspec'
27
+ require 'rspec-repetitive'
28
+
29
+ RSpec.configure do |config|
30
+ RSpec::Repetitive.configure(config)
31
+ end
32
+
33
+ RSpec.describe "something that should work with and without a feature switch enabled" do
34
+ repeat_each_example "with my_feature enabled" do
35
+ FeatureSwitch.enable(:my_feature)
36
+ end
37
+
38
+ it "works" do
39
+ # ...
40
+ end
41
+ end
42
+ ```
43
+
44
+ Running the above example would produce the following:
45
+
46
+ ```
47
+ $ rspec my_spec.rb
48
+
49
+ something that should work with and without a feature switch enabled
50
+ works
51
+ with my_feature enabled works
52
+
53
+ Finished in 0.00153 seconds (files took 0.12087 seconds to load)
54
+ 2 examples, 0 failures
55
+ ```
56
+
57
+ ## License
58
+
59
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -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
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "rspec/repetitive"
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__)
data/bin/setup ADDED
@@ -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,5 @@
1
+ module RSpec
2
+ module Repetitive
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,49 @@
1
+ require "rspec/repetitive/version"
2
+
3
+ module RSpec
4
+ module Repetitive
5
+ def self.configure(configuration)
6
+ configuration.extend(self)
7
+
8
+ configuration.on_example_group_definition do |top_level_example_group|
9
+ tagged_examples(top_level_example_group, :"rspec-repetitive_before_block").each do |example|
10
+ new_description = example.metadata[:"rspec-repetitive_example_description_prefix"] + " " + example.description
11
+
12
+ register_example_from_source_example(example, new_description) do |old_block, *args|
13
+ instance_exec(*args, &example.metadata[:"rspec-repetitive_before_block"])
14
+ instance_exec(*args, &old_block)
15
+ end
16
+ end
17
+ end
18
+ end
19
+
20
+ def self.register_example_from_source_example(source_example, description, &around_example_block)
21
+ example_block = if block_given?
22
+ ->(*args) { instance_exec(source_example.metadata[:block], *args, &around_example_block) }
23
+ else
24
+ source_example.metadata[:block]
25
+ end
26
+
27
+ new_metadata = Hash[source_example.metadata.reject { |k, v| RSpec::Core::Metadata::RESERVED_KEYS.include?(k) }].
28
+ merge(:caller => [source_example.metadata[:block].source_location.join(":")])
29
+
30
+ RSpec::Core::Example.new(source_example.example_group, description, new_metadata, example_block)
31
+ end
32
+
33
+ def self.tagged_examples(example_group, tag)
34
+ _each_example(example_group).select { |example| example.metadata[tag] }.to_a
35
+ end
36
+
37
+ def self._each_example(example_group, &block)
38
+ return enum_for(:_each_example, example_group) unless block_given?
39
+
40
+ example_group.examples.each(&block)
41
+ example_group.children.each { |child_example_group| _each_example(child_example_group, &block) }
42
+ end
43
+
44
+ def repeat_each_example(example_description_prefix = "", &block)
45
+ metadata[:"rspec-repetitive_before_block"] = block
46
+ metadata[:"rspec-repetitive_example_description_prefix"] = example_description_prefix
47
+ end
48
+ end
49
+ end
@@ -0,0 +1 @@
1
+ require 'rspec/repetitive'
@@ -0,0 +1,27 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "rspec/repetitive/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "rspec-repetitive"
8
+ spec.version = RSpec::Repetitive::VERSION
9
+ spec.authors = ["Jamie English"]
10
+ spec.email = ["jamienglish@gmail.com"]
11
+
12
+ spec.summary = %q{Repetitive RSpec examples with custom setup.}
13
+ spec.description = %q{Repetitive RSpec examples with custom setup.}
14
+ spec.homepage = "https://github.com/english/rspec-repetitive"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_dependency "rspec-core", "~> 3.0"
25
+
26
+ spec.add_development_dependency "rspec", "~> 3.0"
27
+ end
metadata ADDED
@@ -0,0 +1,84 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rspec-repetitive
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Jamie English
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-03-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec-core
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: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.0'
41
+ description: Repetitive RSpec examples with custom setup.
42
+ email:
43
+ - jamienglish@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - ".rspec"
50
+ - Gemfile
51
+ - Gemfile.lock
52
+ - LICENSE.txt
53
+ - README.md
54
+ - Rakefile
55
+ - bin/console
56
+ - bin/setup
57
+ - lib/rspec-repetitive.rb
58
+ - lib/rspec/repetitive.rb
59
+ - lib/rspec/repetitive/version.rb
60
+ - rspec-repetitive.gemspec
61
+ homepage: https://github.com/english/rspec-repetitive
62
+ licenses:
63
+ - MIT
64
+ metadata: {}
65
+ post_install_message:
66
+ rdoc_options: []
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ requirements: []
80
+ rubygems_version: 3.0.1
81
+ signing_key:
82
+ specification_version: 4
83
+ summary: Repetitive RSpec examples with custom setup.
84
+ test_files: []