Sha256: 559d863cf70bf04088e915911b678bbca1bf6977f767e8b10843cc7cdd8e3457

Contents?: true

Size: 1.77 KB

Versions: 1

Compression:

Stored size: 1.77 KB

Contents

# RSpec Scaffolding [![Build Status](https://travis-ci.org/ridiculous/rspec-scaffold.svg)](https://travis-ci.org/ridiculous/rspec-scaffold)

Generates RSpec scaffolding for existing code. Helps you write tests by showing you what you should be testing, 
which are conditions and changes to state (at a minimum).

## Installation

Requires Ruby >= 1.9.3

```ruby
gem 'rspec-scaffold'
```

## Usage

Takes either a file or a directory.

```bash
rake rspec:scaffold[lib]
```

## Example

Given:

```ruby
# app/models/ability.rb
class Ability
  include CanCan::Ability

  def initialize(user)
    if user.admin?
      can :manage, :all
    else
      can :read, :all
      can :update, User do |u|
        u.id == user.id
      end
    end
  end
end
```

```bash
rake rspec:scaffold[app/models/ability.rb]
```

Outputs:

```ruby
# spec/models/ability_spec.rb
require "spec_helper"

describe Ability do
  let(:user) {}

  subject { described_class.new user }

  describe "#initialize" do
    context "when user.admin?" do
      before {}
    end

    context "unless user.admin?" do
      before {}
    end
  end
end
```

## Development

After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake false` 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](https://rubygems.org).

## Contributing

Run tests with `bin/test`. Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/rspec-scaffold.

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rspec-scaffold-0.2.1 README.md