Popularity
1.1
Stable
Activity
0.0
Stable
2
11
2

Monthly Downloads: 174
Programming language: Ruby
License: Apache License 2.0
Tags: Testing     RSpec     Extra    
Latest version: v0.2.0

rspec-side_effects alternatives and similar gems

Based on the "Extra" category.
Alternatively, view rspec-side_effects alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of rspec-side_effects or a related project?

Add another 'Extra' Gem

README

Rspec::SideEffects

Gem Version Build Status Code Climate Test Coverage [License](LICENSE)

Inline docs RubyDoc

RSpec extension for checking the side effects of your specifications.

Installation

Add this line to your application's Gemfile:

gem 'rspec-side_effects'

And then execute:

$ bundle

Or install it yourself as:

$ gem install rspec-side_effects

Usage

This gem is intended to replace explicitly calling the subject before checking its side effects. It might be used when testing things like:

  • method which works directly with a database
  • method which works directly with a file system
  • method which only integrates mocked objects

There are several aliases for it_has_side_effects_are which can be used to communicate different things to the reader.

subject { test_class.test }

its_side_effects_are do
  # Check a side effect, such as writing to the file system.
  # Check a have_received expectation
end

Or leave out the block and only check expectations which are already setup.

subject { test_class.test }

before do
  # Setup an expecation for the method call
end

end

it_has_side_effects

Both of these examples are testing methods where you do not care about the return value. When you do care about the return value and the side effects, you can do that too.

subject { test_class.test }

it { is_expected.to eq(:result) }
its_side_effects_are do
  # Check a side effect, such as writing to the file system.
  # Check a have_received expectation
end

Exceptions are also rescued by the helper, so you can still check side effects which also expecting an exception to be raised.

subject { test_class.test }

it { expect { subject }.to raise_error(StandardError) }
its_side_effects_are do
  # Check what might have happened before the exception.
  # Or confirm things which should not have happend with an error.
end

Development

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.

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.

Elsewhere on the web

Links to other places on the web where this projects exists:

Contributing

See [CONTRIBUTING](CONTRIBUTING.md) for how you can contribute changes back into this project.

Acknowledgments

Copyright 2019 SugarCRM Inc., released under the Apache2 License.


*Note that all licence references and agreements mentioned in the rspec-side_effects README section above are relevant to that project's source code only.