rspec-bdd-style 1.0.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.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/rspec_bdd_style.rb +45 -0
  3. metadata +47 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 11c4ee9d0d3bdb41e210845c7d0cba681f85056f6f1fc42639e73dfacaa7c9d4
4
+ data.tar.gz: 4520197634f676cc4790ebee88083742ddd1a3177dcf001c74d56c04bbf59ad4
5
+ SHA512:
6
+ metadata.gz: 53f321a5faaeb7eea8273453f80f7eb158cd0970574de1cd9fde8006356575c4b39929d004131a9e8047c83c903aa1d49166b43cb7e0bc2d7d83499d770259d3
7
+ data.tar.gz: 5755656992f22764e723c4593a55beeda1aaa3e7ba36c3749290d7d348587a7ad081c2b1f7df9f91a8424005d34ed1e372b821a720c6d9da4dceb1faeb73736e
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RspecBddStyle
4
+ PREFIXES = %w[given_i when_i and_i then_i].freeze
5
+
6
+ PREFIXES.each do |prefix|
7
+ define_method("#{prefix}_method_missing") do |method_name, *args, &block|
8
+ action, action_name = parse_method_name(method_name)
9
+
10
+ if action && respond_to?(action_name, true)
11
+ if args.first.is_a?(Hash)
12
+ send(action_name, **args.first, &block)
13
+ else
14
+ send(action_name, *args, &block)
15
+ end
16
+ else
17
+ super
18
+ end
19
+ end
20
+ end
21
+
22
+ private
23
+
24
+ def method_missing(method_name, *args, &block)
25
+ PREFIXES.each do |prefix|
26
+ return send("#{prefix}_method_missing", method_name, *args, &block) if method_name.to_s.start_with?("#{prefix}_")
27
+ end
28
+
29
+ super
30
+ end
31
+
32
+ def respond_to_missing?(*)
33
+ true
34
+ end
35
+
36
+ def parse_method_name(method_name)
37
+ match = method_name.to_s.match(/\A(#{PREFIXES.join('|')})_(.+)\z/)
38
+ match ? [match[1], match[2].to_sym] : [nil, nil]
39
+ end
40
+ end
41
+
42
+ RSpec.configure do |config|
43
+ config.include RspecBddStyle, type: :feature
44
+ config.include RspecBddStyle, type: :system
45
+ end
metadata ADDED
@@ -0,0 +1,47 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rspec-bdd-style
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Agustín Serena
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-11-14 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: |2
14
+ RspecBddStyle provides a collection of methods following the BDD (Behavior-Driven Development) style to enhance clarity and readability
15
+ in your RSpec specifications. These methods, such as given_i, when_i, and_i, and then_i, simplify the writing of scenarios and actions in your
16
+ tests. It makes it easier to write more expressive and understandable specifications for your development team.
17
+ email:
18
+ - aserena92@gmail.com
19
+ executables: []
20
+ extensions: []
21
+ extra_rdoc_files: []
22
+ files:
23
+ - lib/rspec_bdd_style.rb
24
+ homepage: https://github.com/unagisoftware/rspec_bdd_style
25
+ licenses:
26
+ - MIT
27
+ metadata: {}
28
+ post_install_message:
29
+ rdoc_options: []
30
+ require_paths:
31
+ - lib
32
+ required_ruby_version: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: '0'
37
+ required_rubygems_version: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ requirements: []
43
+ rubygems_version: 3.4.10
44
+ signing_key:
45
+ specification_version: 4
46
+ summary: A set of utilities to enhance readability in RSpec BDD-style specifications.
47
+ test_files: []