Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/brett-richardson/rspec-situations
Adds a super simple method to describe RSpec situations in terms of smaller situation blocks.
https://github.com/brett-richardson/rspec-situations
Last synced: 12 days ago
JSON representation
Adds a super simple method to describe RSpec situations in terms of smaller situation blocks.
- Host: GitHub
- URL: https://github.com/brett-richardson/rspec-situations
- Owner: brett-richardson
- License: mit
- Created: 2013-07-06T19:32:59.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2013-12-27T00:36:55.000Z (about 11 years ago)
- Last Synced: 2024-11-11T00:28:40.283Z (2 months ago)
- Language: Ruby
- Homepage: http://brett-richardson.github.io/rspec-situations
- Size: 670 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: MIT-LICENSE
Awesome Lists containing this project
README
[![Build Status](https://travis-ci.org/brett-richardson/rspec-situations.png?branch=master)](https://travis-ci.org/brett-richardson/rspec-situations)
Using Rspec Situations
======================Using Rspec Situations is super simple.
In your Gemfile:
```ruby
group :development, :testing do
gem 'rspec-situations'
end
```In your spec_helper.rb:
```ruby
require 'rspec/situations'
```Define a situation with the 'situation' method.
Add a symbol key to identify the situation, and add an optional description if you like, and pass in a block creating the situation.Describe a set of 1 or more situations with the 'describe_situation' method, and treat it just like a normal describe call.
```ruby
describe Apple do
subject( :apple ){ create :apple }situation( :bought ){ subject.bought_by = create :user }
situation( :red ){ subject.color = :red }situation( :one_yr_old, 'a year old' ) do # With optional description
subject.created_at = 1.years.ago
enddescribe_situation :bought, :red do
it{ should be_tasty }
enddesribe_situation :bought, :one_yr_old, 'bought a year ago' do # With optional description
it{ should_not be_tasty }
enddescribe_situation :bought, :one_yr_old do
it{ should_not be_tasty }
end
end
```