Skip to content

Add extra strings to Rspec Documentation format? #34

@DaveSanders

Description

@DaveSanders

This is cross posted on stack overflow too:

http://stackoverflow.com/questions/13049841/add-extra-documentation-to-rspec-output

So, while I like Cucumber for its readability for integration testing and its ability to give us documentation we can share with the client easily, I also find it cumbersome from the development and testing speed standpoints.

I got to thinking today that if I could just print out messages to the RSpec documentation format that documented the "steps", then I could easily replicate the business features of Gherkin but in the simplicity of RSpec. But I can't figure out a way to do this.

What I want is to take something like this:

describe "Login and Authorization Tests" do
  before (:each) do
    docs "Given I have a user"
    @user = FactoryGirl.create(:user)
  end

  it "A user can belong to one or more user roles" do
    docs "And the user has no roles assigned"
    @user.roles.length.should eq 0
    docs "When I add two roles"
    @user.roles << FactoryGirl.create(:role)
    @user.roles << FactoryGirl.create(:role)

    @user.reload
    docs "Then the user should have two roles assigned"
    @user.roles.length.should eq 2        
  end
end

and get this in the documentation

User
  Login and Authorization Tests
    A user can belong to one or more user roles
      Given I have a user
      And the user has no roles assigned"
      When I add two roles
      Then the user should have two roles assigned

Note that the message from "before" shows up in the docs too, and would show up with that line in every test below it.

I'm thinking of forking to see if I can add something like this in, but before I did that, does anyone know if something like this is possible already?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions