Skip to content
Browse files

Improve README

  • Loading branch information...
1 parent b5eecd4 commit 34c959e94d509078572ec7933359c76f4b6a0899 @narwen committed with Hashrocket Workstation Apr 3, 2012
Showing with 41 additions and 21 deletions.
  1. +41 −21 README.md
View
62 README.md
@@ -4,9 +4,11 @@ A simple interface for the state of objects under test. Useful as an interface a
## Installation
-Add this line to your application's Gemfile:
+Add this line to your application's `Gemfile`:
- gem 'statefulton'
+```ruby
+gem 'statefulton'
+```
And then execute:
@@ -16,7 +18,7 @@ Or install it yourself as:
$ gem install statefulton
-## Usage
+## How does it work
Defined DSL methods:
@@ -26,43 +28,61 @@ Defined DSL methods:
Accessing the state of something:
-* StateOf(:name, "context")
+```ruby
+StateOf(:name, "context")
+```
Creating a statefulton:
-* Statefulton(:name) { # a block of calls to the DSL methods }
+```ruby
+Statefulton(:name) { # a block of calls to the DSL methods }
+```
Reset state between tests:
-* Statefulton::Reset.all
+```ruby
+Statefulton::Reset.all
+```
-To define a new statefulton:
+## Cucumber Usage
- Statefulton(:user) do
- builder { User.new }
+To define a new statefulton on `features/support/statefulton.rb`:
- make "an"
+```ruby
+Statefulton(:user) do
+ builder { User.new }
+
+ make "an"
+
+ expects "that" # Calling "that" will return the singular instance
+end
+```
- expects "that" # Calling "that" will return the singular instance
- end
StateOf(:user, "that") #raise error: instance not created
StateOf(:user, "an") #build the object
StateOf(:user, "an") #raise error: instance already created
StateOf(:user, "that") #get the object
-Cucumber Usage:
- Given a user
- When I activate that user
+Define your cucumber feature on `features` or a subdirectory.
+
+```ruby
+Given a user
+When I activate that user
+```
+
+Define your steps on `features/steps`
- Transform /^(a|that) user$/ do |state|
- StateOf(:user, state)
- end
+```ruby
+Transform /^(a|that) user$/ do |state|
+ StateOf(:user, state)
+end
- When /^I activate (that user)$/ do |user|
- user.activate!
- end
+When /^I activate (that user)$/ do |user|
+ user.activate!
+end
+```
## Contributing

0 comments on commit 34c959e

Please sign in to comment.
Something went wrong with that request. Please try again.