Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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.

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
end

describe_situation :bought, :red do
it{ should be_tasty }
end

desribe_situation :bought, :one_yr_old, 'bought a year ago' do # With optional description
it{ should_not be_tasty }
end

describe_situation :bought, :one_yr_old do
it{ should_not be_tasty }
end
end
```