README.md in click_session-0.0.1 vs README.md in click_session-0.1.0
- old
+ new
@@ -5,17 +5,21 @@
Modern web apps rely more and more on html to be loaded asyncronously after the page has been loaded. The current solutions for automating a series of clicks, form posts and navigation changes relies on all html being rendered at once.
The Capybara team has put a lot of thought into how these web apps can be tested and because of this, it also makes a good tool for scraping these web sites.
## Installation
+Add to `Gemfile`
+```gem "click_session"```
-## How to set up
+Run `bundle install`
### Generate a migration
-`rails generate click_session:install`
+`rails generate click_session:install`
This will create a migration and generate an initializer with configuration parameters needed for click_session
+## How to set up
+
### Define the steps in a class
Name the class ```ClickSessionRunner``` and add a method called ```run```.
This class must extend the ```WebRunner``` class
@@ -57,28 +61,56 @@
# --> saves the User
# --> run the steps in the ClickSessionRunner
# --> result contains the serialized user data
```
+Example of result hash:
+```
+{
+ id: 1234,
+ status: {
+ success: true, # Boolean
+ },
+ data: { # This is the output of the Serialized model
+ name: "Joe",
+ facebook_avatar: "http://fb.com/i/joe.png"
+ }
+}
+```
+
### Run session asyncronously
+__1__ Create a new session
```ruby
user = User.new
async_click_session = ClickSession::Async.new(user)
result = async_click_session.run
# --> saves the User
# --> saves the SessionState
# --> result contains the ID of the saved SessionState
+```
+Example of result
+```
+{
+ id: 1234,
+ status: {
+ success: true, # Boolean
+ }
+}
+```
+__2__ Run the rake task to process all the session that has not yet been executed
+```
# $ rake click_session:process_active
# --> run the steps in the ClickSessionRunner
+```
+__3__ Run the rake task that reports all the successful sessions
+```
# $ rake click_session:report_successful
# --> the request sent contains the serialized user data
```
-
-### result hash
-Example:
+Example of payload posted to your webhook
```
{
id: 1234,
status: {
success: true, # Boolean
@@ -87,10 +119,12 @@
name: "Joe",
facebook_avatar: "http://fb.com/i/joe.png"
}
}
```
+
+
The only optional part of the result is the ```data```.
### Example of how to use it in a rails controller action
```ruby
def show
@@ -106,10 +140,15 @@
end
end
```
+### Additional methods available to use in the specified steps
+Method | Description
+------ | -----------
+`point_of_no_return`| This step prevents the processor running your steps to __NOT__ retry the steps if an error is raised. This is especially useful if you are automating a payment and you don't want the payment to be processed more than once.
+
## Mandatory configurations
```ruby
ClickSession.configure do | config |
config.model_class = YourModel
end
@@ -117,11 +156,11 @@
## Optional configurations and extentions
```ruby
ClickSession.configure do | config |
- config.processor_class = MyCustomProcessor
+ config.runner_class = MyCustomRunner
config.notifier_class = MyCustomNotifier
config.serializer_class = MyCustomSerializer
config.success_callback_url = "https://my.domain.com/webhook_success"
config.failure_callback_url = "https://my.domain.com/webhook_failure"
config.enable_screenshot = false # true
@@ -215,9 +254,15 @@
__Note:__ This requires you to add the S3 credentials and bucket name to the configuration
## Rake tasks
+In order to run the included rake tasks, you need to load them in your applications `Rakefile`
+```
+spec = Gem::Specification.find_by_name 'click_session'
+load "#{spec.gem_dir}/lib/tasks/click_session.rake"
+```
+
### click_session:process_active
Processes all the active click sessions, meaning the ones that are ready to be run.
__Note:__ Only needed for ```ClickSession::Async```