cmdx-rspec 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: c71665a9df22d3f4b31837985f80f468cbc8ca745878f596435d86fa78fc6c09
4
+ data.tar.gz: 0e89b8a0d57347c00c0b4ebff093945ea9286623f843603c838768b83fcc71d4
5
+ SHA512:
6
+ metadata.gz: f8128839bb2cfddf0fb79947354869512e355259391abb337e5bec462feeb29cc81b6831509d115b7534d6d7b24c9d85cb1b23c6ea26b0b324e3540344260d93
7
+ data.tar.gz: 2e4cd45210779381653e3bfbee2c0cf2d5d7da3521169ca75abf43a47be132b9cd02e9b15844e607046718d6972f26b019615bca6505c1fd6987f3c430bbb288
@@ -0,0 +1,12 @@
1
+ You are a senior Ruby developer with expert knowledge of CMDx and writing documentation.
2
+
3
+ Update the active tab using the following guidelines:
4
+
5
+ - Follow best practices and implementation
6
+ - Use a consistent professional voice
7
+ - Examples should be concise, non-repetitive, and realistic
8
+ - Update any pre-existing documentation to match stated rules
9
+ - Examples should not cross boundaries or focus
10
+ - Docs must cover both typical use cases, including invalid inputs and error conditions
11
+ - Use GitHub flavored markdown, including alerts to emphasize critical information (https://github.com/orgs/community/discussions/16925)
12
+ - Optimize for LLM's including coding and AI agents
@@ -0,0 +1,20 @@
1
+ Process the following instructions in the order given:
2
+
3
+ 1. Create an `LLM.md` file
4
+ 2. Append all files within `docs/**/*.md` into @LLM.md
5
+ 2a. Use order outlined in the table of contents of @README.md
6
+ 2b. Process one file at a time faster performance and improved accuracy
7
+ 2c. Remove the table of contents from the chunk
8
+ 2c. Remove the navigations below `---` from the chunk
9
+ 2d. Wrap the chunk the files GitHub url the top and a spacer at the bottom like so:
10
+ ```
11
+
12
+ ---
13
+ url: https://github.com/drexed/cmdx/blob/main/docs/callbacks.md
14
+ ---
15
+
16
+ {{ chunk }}
17
+
18
+ ---
19
+
20
+ ```
@@ -0,0 +1,24 @@
1
+ You are a senior Ruby developer with expert knowledge of RSpec.
2
+
3
+ Add tests for the active tab using the following guidelines:
4
+
5
+ - Expectations should be concise, non-repetitive, and realistic (how it would be used in the real world)
6
+ - Follow best practices and implementation
7
+ - Update any pre-existing specs to match stated rules
8
+ - New tests should be consistent with current `spec/cmdx` specs
9
+ - Use custom matchers available within `lib/cmdx/rspec`
10
+ - Use task helpers available within `spec/support/helpers`
11
+ - Use stubs to return predefined values for specific methods. Isolate the unit being tested, but avoid over-mocking; test real behavior when possible (mocks should be used only when necessary)
12
+ - Ensure each test is independent; avoid shared state between tests
13
+ - Use let and let! to define test data, ensuring minimal and necessary setup
14
+ - Context block descriptions should start with the following words: `when`, `with`, `without`
15
+ - Organize tests logically using describe for classes/modules and context for different scenarios
16
+ - Use subject to define the object under test when appropriate to avoid repetition
17
+ - Ensure test file paths mirror the structure of the files being tested, but within the spec directory (e.g., lib/cmdx/task.rb → spec/cmdx/task_spec.rb)
18
+ - Use clear and descriptive names for describe, context, and it blocks
19
+ - Prefer the expect syntax for assertions to improve readability
20
+ - Keep test code concise; avoid unnecessary complexity or duplication
21
+ - Tests must cover both typical cases and edge cases, including invalid inputs and error conditions
22
+ - Consider all possible scenarios for each method or behavior and ensure they are tested
23
+ - Do NOT include integration or real world examples
24
+ - Verify all specs are passing
@@ -0,0 +1,14 @@
1
+ You are a senior Ruby developer with expert knowledge of YARDoc.
2
+
3
+ Add yardoc to the active tab using the following guidelines:
4
+
5
+ - Follow best practices and implementation
6
+ - New documentation should be consistent with current `lib/cmdx` documentation
7
+ - Examples should be concise, non-repetitive, and realistic
8
+ - Avoid unnecessary complexity or duplication
9
+ - Update any pre-existing documentation to match stated rules
10
+ - Do NOT include `CMDx` module level docs
11
+ - Module level docs description should NOT include `@example`
12
+ - Method level docs should include `@example`, `param`, `@options`, `@return`, and any `@raise`
13
+ - Hash `@params` should expand with possible `@option`
14
+ - Module and method level docs should NOT include `@since`
@@ -0,0 +1,62 @@
1
+ ---
2
+ description:
3
+ globs:
4
+ alwaysApply: true
5
+ ---
6
+
7
+ # Ruby Coding Standards
8
+
9
+ Follow the official Ruby gem guides for best practices.
10
+ Reference the guides outlined in https://guides.rubygems.org
11
+
12
+ ## Project Context
13
+ CMDx::RSpec is a collection of RSpec matchers for the CMDx framework.
14
+ Reference the CMDx documentation in https://github.com/drexed/cmdx/blob/main/LLM.md
15
+ Reference the CMDx::I18n documentation in https://github.com/drexed/cmdx-i18n/blob/main/README.md
16
+
17
+ ## Technology Stack
18
+ - Ruby 3.4+
19
+ - RSpec 3.1+
20
+ - CMDx 1.5+
21
+
22
+ ## Code Style and Structure
23
+ - Write concise, idiomatic Ruby code with accurate examples
24
+ - Follow Ruby conventions and best practices
25
+ - Use object-oriented and functional programming patterns as appropriate
26
+ - Prefer iteration and modularization over code duplication
27
+ - Use descriptive variable and method names (e.g., user_signed_in?, calculate_total)
28
+ - Write comprehensive code documentation using the Yardoc format
29
+
30
+ ## Naming Conventions
31
+ - Use snake_case for file names, method names, and variables
32
+ - Use CamelCase for class and module names
33
+
34
+ ## Syntax and Formatting
35
+ - Follow the Ruby Style Guide (https://rubystyle.guide/)
36
+ - Follow Ruby style conventions (2-space indentation, snake_case methods)
37
+ - Use Ruby's expressive syntax (e.g., unless, ||=, &.)
38
+ - Prefer double quotes for strings
39
+ - Respect my Rubocop options
40
+
41
+ ## Performance Optimization
42
+ - Use memoization for expensive operations
43
+
44
+ ## Testing
45
+ - Follow the RSpec Style Guide (https://rspec.rubystyle.guide/)
46
+ - Write comprehensive tests using RSpec
47
+ - It's ok to put multiple assertions in the same example
48
+ - Include both BDD and TDD based tests
49
+ - Create test objects to share across tests
50
+ - Do NOT make tests for obvious or reflective expectations
51
+ - Prefer real objects over mocks. Use `instance_double` if necessary; never `double`
52
+ - Don't test declarative configuration
53
+ - Use appropriate matchers
54
+ - Update tests and update Yardocs after you write code
55
+
56
+ ## Documentation
57
+ - Utilize the YARDoc format when documenting Ruby code
58
+ - Follow these best practices:
59
+ - Avoid redundant comments that merely restate the code
60
+ - Keep comments up-to-date with code changes
61
+ - Keep documentation consistent
62
+ - Update CHANGELOG.md with any changes
data/.rspec ADDED
@@ -0,0 +1,4 @@
1
+ --backtrace
2
+ --color
3
+ --format progress
4
+ --order random
data/.rubocop.yml ADDED
@@ -0,0 +1,64 @@
1
+ plugins:
2
+ - rubocop-performance
3
+ - rubocop-rake
4
+ - rubocop-rspec
5
+ AllCops:
6
+ NewCops: enable
7
+ DisplayCopNames: true
8
+ DisplayStyleGuide: true
9
+ TargetRubyVersion: 3.1
10
+ Gemspec/DevelopmentDependencies:
11
+ EnforcedStyle: gemspec
12
+ Layout/EmptyLinesAroundAttributeAccessor:
13
+ Enabled: true
14
+ Layout/EmptyLinesAroundClassBody:
15
+ EnforcedStyle: empty_lines_except_namespace
16
+ Layout/EmptyLinesAroundModuleBody:
17
+ EnforcedStyle: empty_lines_except_namespace
18
+ Layout/FirstHashElementIndentation:
19
+ EnforcedStyle: consistent
20
+ Layout/LineLength:
21
+ Enabled: false
22
+ Metrics/AbcSize:
23
+ Enabled: false
24
+ Metrics/BlockLength:
25
+ Enabled: false
26
+ Metrics/CyclomaticComplexity:
27
+ Enabled: false
28
+ Metrics/MethodLength:
29
+ Enabled: false
30
+ Metrics/PerceivedComplexity:
31
+ Enabled: false
32
+ RSpec/DescribeClass:
33
+ Enabled: false
34
+ RSpec/ExampleLength:
35
+ Enabled: false
36
+ RSpec/IndexedLet:
37
+ Enabled: false
38
+ RSpec/MessageSpies:
39
+ EnforcedStyle: receive
40
+ RSpec/MultipleExpectations:
41
+ Enabled: false
42
+ RSpec/MultipleMemoizedHelpers:
43
+ Enabled: false
44
+ RSpec/NestedGroups:
45
+ Enabled: false
46
+ RSpec/SpecFilePathFormat:
47
+ CustomTransform:
48
+ CMDx: cmdx
49
+ RSpec/SubjectStub:
50
+ Enabled: false
51
+ RSpec/StubbedMock:
52
+ Enabled: false
53
+ RSpec/VerifiedDoubleReference:
54
+ Enabled: false
55
+ Style/Documentation:
56
+ Enabled: false
57
+ Style/FrozenStringLiteralComment:
58
+ Enabled: true
59
+ EnforcedStyle: always_true
60
+ SafeAutoCorrect: true
61
+ Style/ModuleFunction:
62
+ EnforcedStyle: extend_self
63
+ Style/StringLiterals:
64
+ EnforcedStyle: double_quotes
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2025-08-24
4
+
5
+ - Initial release
@@ -0,0 +1,132 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of age, body
7
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
8
+ identity and expression, level of experience, education, socio-economic status,
9
+ nationality, personal appearance, race, caste, color, religion, or sexual
10
+ identity and orientation.
11
+
12
+ We pledge to act and interact in ways that contribute to an open, welcoming,
13
+ diverse, inclusive, and healthy community.
14
+
15
+ ## Our Standards
16
+
17
+ Examples of behavior that contributes to a positive environment for our
18
+ community include:
19
+
20
+ * Demonstrating empathy and kindness toward other people
21
+ * Being respectful of differing opinions, viewpoints, and experiences
22
+ * Giving and gracefully accepting constructive feedback
23
+ * Accepting responsibility and apologizing to those affected by our mistakes,
24
+ and learning from the experience
25
+ * Focusing on what is best not just for us as individuals, but for the overall
26
+ community
27
+
28
+ Examples of unacceptable behavior include:
29
+
30
+ * The use of sexualized language or imagery, and sexual attention or advances of
31
+ any kind
32
+ * Trolling, insulting or derogatory comments, and personal or political attacks
33
+ * Public or private harassment
34
+ * Publishing others' private information, such as a physical or email address,
35
+ without their explicit permission
36
+ * Other conduct which could reasonably be considered inappropriate in a
37
+ professional setting
38
+
39
+ ## Enforcement Responsibilities
40
+
41
+ Community leaders are responsible for clarifying and enforcing our standards of
42
+ acceptable behavior and will take appropriate and fair corrective action in
43
+ response to any behavior that they deem inappropriate, threatening, offensive,
44
+ or harmful.
45
+
46
+ Community leaders have the right and responsibility to remove, edit, or reject
47
+ comments, commits, code, wiki edits, issues, and other contributions that are
48
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
49
+ decisions when appropriate.
50
+
51
+ ## Scope
52
+
53
+ This Code of Conduct applies within all community spaces, and also applies when
54
+ an individual is officially representing the community in public spaces.
55
+ Examples of representing our community include using an official email address,
56
+ posting via an official social media account, or acting as an appointed
57
+ representative at an online or offline event.
58
+
59
+ ## Enforcement
60
+
61
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
+ reported to the community leaders responsible for enforcement at
63
+ [INSERT CONTACT METHOD].
64
+ All complaints will be reviewed and investigated promptly and fairly.
65
+
66
+ All community leaders are obligated to respect the privacy and security of the
67
+ reporter of any incident.
68
+
69
+ ## Enforcement Guidelines
70
+
71
+ Community leaders will follow these Community Impact Guidelines in determining
72
+ the consequences for any action they deem in violation of this Code of Conduct:
73
+
74
+ ### 1. Correction
75
+
76
+ **Community Impact**: Use of inappropriate language or other behavior deemed
77
+ unprofessional or unwelcome in the community.
78
+
79
+ **Consequence**: A private, written warning from community leaders, providing
80
+ clarity around the nature of the violation and an explanation of why the
81
+ behavior was inappropriate. A public apology may be requested.
82
+
83
+ ### 2. Warning
84
+
85
+ **Community Impact**: A violation through a single incident or series of
86
+ actions.
87
+
88
+ **Consequence**: A warning with consequences for continued behavior. No
89
+ interaction with the people involved, including unsolicited interaction with
90
+ those enforcing the Code of Conduct, for a specified period of time. This
91
+ includes avoiding interactions in community spaces as well as external channels
92
+ like social media. Violating these terms may lead to a temporary or permanent
93
+ ban.
94
+
95
+ ### 3. Temporary Ban
96
+
97
+ **Community Impact**: A serious violation of community standards, including
98
+ sustained inappropriate behavior.
99
+
100
+ **Consequence**: A temporary ban from any sort of interaction or public
101
+ communication with the community for a specified period of time. No public or
102
+ private interaction with the people involved, including unsolicited interaction
103
+ with those enforcing the Code of Conduct, is allowed during this period.
104
+ Violating these terms may lead to a permanent ban.
105
+
106
+ ### 4. Permanent Ban
107
+
108
+ **Community Impact**: Demonstrating a pattern of violation of community
109
+ standards, including sustained inappropriate behavior, harassment of an
110
+ individual, or aggression toward or disparagement of classes of individuals.
111
+
112
+ **Consequence**: A permanent ban from any sort of public interaction within the
113
+ community.
114
+
115
+ ## Attribution
116
+
117
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118
+ version 2.1, available at
119
+ [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
120
+
121
+ Community Impact Guidelines were inspired by
122
+ [Mozilla's code of conduct enforcement ladder][Mozilla CoC].
123
+
124
+ For answers to common questions about this code of conduct, see the FAQ at
125
+ [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
126
+ [https://www.contributor-covenant.org/translations][translations].
127
+
128
+ [homepage]: https://www.contributor-covenant.org
129
+ [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
130
+ [Mozilla CoC]: https://github.com/mozilla/diversity
131
+ [FAQ]: https://www.contributor-covenant.org/faq
132
+ [translations]: https://www.contributor-covenant.org/translations
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 Juan Gomez
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,121 @@
1
+ <p align="center">
2
+ <img src="./src/cmdx-rspec-logo.png" width="200" alt="CMDx::I18n Logo">
3
+ </p>
4
+
5
+ <p align="center">
6
+ <img alt="Version" src="https://img.shields.io/gem/v/cmdx-rspec">
7
+ <img alt="Build" src="https://github.com/drexed/cmdx-rspec/actions/workflows/ci.yml/badge.svg">
8
+ <img alt="License" src="https://img.shields.io/github/license/drexed/cmdx-rspec">
9
+ </p>
10
+
11
+ # CMDx::I18n
12
+
13
+ Collection of RSpec matchers for [CMDx](https://github.com/drexed/cmdx).
14
+
15
+ ## Installation
16
+
17
+ Add this line to your application's Gemfile:
18
+
19
+ ```ruby
20
+ gem 'cmdx-rspec'
21
+ ```
22
+
23
+ And then execute:
24
+
25
+ $ bundle
26
+
27
+ Or install it yourself as:
28
+
29
+ $ gem install cmdx-rspec
30
+
31
+ ## Usage
32
+
33
+ ### have_been_success
34
+
35
+ Asserts that a CMDx task result indicates successful execution.
36
+
37
+ ```ruby
38
+ it "returns success" do
39
+ result = SomeTask.execute
40
+
41
+ expect(result).to have_been_success
42
+ end
43
+ ```
44
+
45
+ ### have_been_skipped
46
+
47
+ Asserts that a CMDx task result indicates the task was skipped during execution.
48
+
49
+ ```ruby
50
+ it "returns skipped" do
51
+ result = SomeTask.execute
52
+
53
+ expect(result).to have_been_skipped
54
+ end
55
+ ```
56
+
57
+ ### have_been_failure
58
+
59
+ Asserts that a CMDx task result indicates execution failure.
60
+
61
+ ```ruby
62
+ it "returns failure" do
63
+ result = SomeTask.execute
64
+
65
+ expect(result).to have_been_failure
66
+ end
67
+ ```
68
+
69
+ ### have_empty_context
70
+
71
+ Asserts that a CMDx task result has no context data.
72
+
73
+ ```ruby
74
+ it "returns empty context" do
75
+ result = SomeTask.execute
76
+
77
+ expect(result).to have_empty_context
78
+ end
79
+ ```
80
+
81
+ ### have_matching_context
82
+
83
+ Asserts that a CMDx task result contains specific context data.
84
+
85
+ ```ruby
86
+ it "returns matching context" do
87
+ result = SomeTask.execute
88
+
89
+ expect(result).to have_matching_context(stored_result: 123)
90
+ end
91
+ ```
92
+
93
+ ### be_deprecated
94
+
95
+ Asserts that a CMDx task result indicates the task is deprecated.
96
+
97
+ ```ruby
98
+ it "returns deprecated" do
99
+ result = SomeTask.execute
100
+
101
+ expect(result).to be_deprecated
102
+ end
103
+ ```
104
+
105
+ ## Development
106
+
107
+ 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.
108
+
109
+ 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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
110
+
111
+ ## Contributing
112
+
113
+ Bug reports and pull requests are welcome on GitHub at https://github.com/drexed/cmdx-rspec. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/drexed/cmdx-rspec/blob/master/CODE_OF_CONDUCT.md).
114
+
115
+ ## License
116
+
117
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
118
+
119
+ ## Code of Conduct
120
+
121
+ Everyone interacting in the Cmdx::Rspec project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/drexed/cmdx-rspec/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec::Matchers.define :be_deprecated do |expected_behavior = nil|
4
+ description do
5
+ if (behavior = @expected_behavior || expected_behavior)
6
+ "be deprecated with behavior #{behavior}"
7
+ else
8
+ "be deprecated"
9
+ end
10
+ end
11
+
12
+ failure_message do |actual|
13
+ if (behavior = @expected_behavior || expected_behavior)
14
+ "expected #{actual} to be deprecated with behavior #{behavior}, but it wasn't"
15
+ else
16
+ "expected #{actual} to be deprecated, but it wasn't"
17
+ end
18
+ end
19
+
20
+ failure_message_when_negated do |actual|
21
+ if (behavior = @expected_behavior || expected_behavior)
22
+ "expected #{actual} not to be deprecated with behavior #{behavior}, but it was"
23
+ else
24
+ "expected #{actual} not to be deprecated, but it was"
25
+ end
26
+ end
27
+
28
+ match do |actual|
29
+ # Handle both class and instance
30
+ target = actual.is_a?(Class) ? actual : actual.class
31
+
32
+ # Check if deprecate setting exists and is truthy
33
+ deprecate_setting = target.settings[:deprecate]
34
+ return false unless deprecate_setting
35
+
36
+ # If no specific behavior expected, just check if deprecated
37
+ behavior_to_check = @expected_behavior || expected_behavior
38
+ return true unless behavior_to_check
39
+
40
+ # Check specific behavior
41
+ case behavior_to_check
42
+ when :warn, /warn/
43
+ deprecate_setting.to_s.include?("warn")
44
+ when :log, /log/
45
+ deprecate_setting.to_s.include?("log")
46
+ when :raise, /raise/, true
47
+ deprecate_setting == true || deprecate_setting.to_s.include?("raise")
48
+ when :none, false, nil
49
+ !deprecate_setting || deprecate_setting == false
50
+ else
51
+ deprecate_setting == behavior_to_check
52
+ end
53
+ end
54
+
55
+ # Chainable matchers for specific behaviors
56
+ chain(:with_raise) { @expected_behavior = :raise }
57
+ chain(:with_logging) { @expected_behavior = :log }
58
+ chain(:with_warning) { @expected_behavior = :warn }
59
+ chain(:with_behavior) { |behavior| @expected_behavior = behavior }
60
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec::Matchers.define :have_been_failure do |**data|
4
+ description { "have been a failure" }
5
+
6
+ match(notify_expectation_failures: true) do |result|
7
+ raise ArgumentError, "must be a CMDx::Result" unless result.is_a?(CMDx::Result)
8
+
9
+ expect(result.to_h).to include(
10
+ state: CMDx::Result::INTERRUPTED,
11
+ status: CMDx::Result::FAILED,
12
+ outcome: CMDx::Result::FAILED,
13
+ metadata: {},
14
+ reason: CMDx::Locale.t("cmdx.faults.unspecified"),
15
+ cause: be_a(CMDx::FailFault),
16
+ **data
17
+ )
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec::Matchers.define :have_been_skipped do |**data|
4
+ description { "have been skipped" }
5
+
6
+ match(notify_expectation_failures: true) do |result|
7
+ raise ArgumentError, "must be a CMDx::Result" unless result.is_a?(CMDx::Result)
8
+
9
+ expect(result.to_h).to include(
10
+ state: CMDx::Result::INTERRUPTED,
11
+ status: CMDx::Result::SKIPPED,
12
+ outcome: CMDx::Result::SKIPPED,
13
+ metadata: {},
14
+ reason: CMDx::Locale.t("cmdx.faults.unspecified"),
15
+ cause: be_a(CMDx::SkipFault),
16
+ **data
17
+ )
18
+ end
19
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec::Matchers.define :have_been_success do |**data|
4
+ description { "have been a success" }
5
+
6
+ match(notify_expectation_failures: true) do |result|
7
+ raise ArgumentError, "must be a CMDx::Result" unless result.is_a?(CMDx::Result)
8
+
9
+ expect(result.to_h).to include(
10
+ state: CMDx::Result::COMPLETE,
11
+ status: CMDx::Result::SUCCESS,
12
+ outcome: CMDx::Result::SUCCESS,
13
+ metadata: {},
14
+ **data
15
+ )
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec::Matchers.define :have_empty_context do
4
+ description { "have an empty context" }
5
+
6
+ match(notify_expectation_failures: true) do |context|
7
+ ctx =
8
+ case context
9
+ when Hash then context
10
+ when CMDx::Context then context.to_h
11
+ when CMDx::Result then context.context.to_h
12
+ else raise "unknown context type #{context.class}"
13
+ end
14
+
15
+ expect(ctx).to be_empty
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec::Matchers.define :have_matching_context do |**data|
4
+ description { "have matching context" }
5
+
6
+ match(notify_expectation_failures: true) do |context|
7
+ ctx =
8
+ case context
9
+ when Hash then context
10
+ when CMDx::Context then context.to_h
11
+ when CMDx::Result then context.context.to_h
12
+ else raise "unknown context type #{context.class}"
13
+ end
14
+
15
+ expect(ctx).to include(**data)
16
+ end
17
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CMDx
4
+ module RSpec
5
+
6
+ VERSION = "0.1.0"
7
+
8
+ end
9
+ end
data/lib/cmdx/rspec.rb ADDED
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "cmdx"
4
+ require "rspec"
5
+
6
+ require_relative "rspec/be_deprecated"
7
+ require_relative "rspec/have_been_failure"
8
+ require_relative "rspec/have_been_skipped"
9
+ require_relative "rspec/have_been_success"
10
+ require_relative "rspec/have_empty_context"
11
+ require_relative "rspec/have_matching_context"
Binary file
metadata ADDED
@@ -0,0 +1,179 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cmdx-rspec
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Juan Gomez
8
+ bindir: exe
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: cmdx
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: 1.5.0
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: 1.5.0
26
+ - !ruby/object:Gem::Dependency
27
+ name: rspec
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ - !ruby/object:Gem::Dependency
41
+ name: bundler
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ type: :development
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ - !ruby/object:Gem::Dependency
55
+ name: rake
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ type: :development
62
+ prerelease: false
63
+ version_requirements: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ - !ruby/object:Gem::Dependency
69
+ name: rubocop
70
+ requirement: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ type: :development
76
+ prerelease: false
77
+ version_requirements: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ - !ruby/object:Gem::Dependency
83
+ name: rubocop-performance
84
+ requirement: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ type: :development
90
+ prerelease: false
91
+ version_requirements: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ - !ruby/object:Gem::Dependency
97
+ name: rubocop-rake
98
+ requirement: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ type: :development
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: rubocop-rspec
112
+ requirement: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ type: :development
118
+ prerelease: false
119
+ version_requirements: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ description: Simple CMDx task testing via RSpec matchers.
125
+ email:
126
+ - drexed@users.noreply.github.com
127
+ executables: []
128
+ extensions: []
129
+ extra_rdoc_files: []
130
+ files:
131
+ - ".cursor/prompts/docs.md"
132
+ - ".cursor/prompts/llms.md"
133
+ - ".cursor/prompts/rspec.md"
134
+ - ".cursor/prompts/yardoc.md"
135
+ - ".cursor/rules/cursor-instructions.mdc"
136
+ - ".rspec"
137
+ - ".rubocop.yml"
138
+ - CHANGELOG.md
139
+ - CODE_OF_CONDUCT.md
140
+ - LICENSE.txt
141
+ - README.md
142
+ - Rakefile
143
+ - lib/cmdx/rspec.rb
144
+ - lib/cmdx/rspec/be_deprecated.rb
145
+ - lib/cmdx/rspec/have_been_failure.rb
146
+ - lib/cmdx/rspec/have_been_skipped.rb
147
+ - lib/cmdx/rspec/have_been_success.rb
148
+ - lib/cmdx/rspec/have_empty_context.rb
149
+ - lib/cmdx/rspec/have_matching_context.rb
150
+ - lib/cmdx/rspec/version.rb
151
+ - src/cmdx-rspec-logo.png
152
+ homepage: https://github.com/drexed/cmdx-rspec
153
+ licenses:
154
+ - MIT
155
+ metadata:
156
+ homepage_uri: https://github.com/drexed/cmdx-rspec
157
+ source_code_uri: https://github.com/drexed/cmdx-rspec
158
+ changelog_uri: https://github.com/drexed/cmdx-rspec/blob/main/CHANGELOG.md
159
+ bug_tracker_uri: https://github.com/drexed/cmdx-rspec/issues
160
+ documentation_uri: https://github.com/drexed/cmdx-rspec/blob/main/README.md
161
+ rubygems_mfa_required: 'true'
162
+ rdoc_options: []
163
+ require_paths:
164
+ - lib
165
+ required_ruby_version: !ruby/object:Gem::Requirement
166
+ requirements:
167
+ - - ">="
168
+ - !ruby/object:Gem::Version
169
+ version: 3.1.0
170
+ required_rubygems_version: !ruby/object:Gem::Requirement
171
+ requirements:
172
+ - - ">="
173
+ - !ruby/object:Gem::Version
174
+ version: '0'
175
+ requirements: []
176
+ rubygems_version: 3.7.1
177
+ specification_version: 4
178
+ summary: Simple CMDx task testing via RSpec matchers.
179
+ test_files: []