Sha256: d02a4a1dc36a3d78b5e2b382bb4a377e195de5e6af5874fce2822eae5746759b

Contents?: true

Size: 1.41 KB

Versions: 1

Compression:

Stored size: 1.41 KB

Contents

# RSpec::Scaffold

Generates RSpec scaffolding for existing code. Takes either a file or a directory.

## Installation

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

## Usage

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

## Example

```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
```

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

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.1.0 README.md