Skip to content

bion/superdelegation

Repository files navigation

Build Status

SUPERDELEGATION

Getting Started

  1. Clone the repo and cd into it
  2. Install rbenv or rvm
  3. Install ruby 2.2.2 rbenv install 2.2.2
  4. Install bundler gem install bundler
  5. On OSX brew install libxml2 libxslt libiconv
  6. ON OSX gem install nokogiri -v '1.6.7.2' -- --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/libxml2 --use-system-libraries
  7. Install your gems bundle
  8. Install zeus gem install zeus
  9. Install postgres (I'll leave this as an exercise for the reader)
  10. Create an .envrc file for loading private configuration information cp .envrc.example .envrc
  11. Create your database rake db:create
  12. Perform your migrations rake db:migrate
  13. Seed your data rake db:seed
  14. Prepare your test db rake db:test:prepare

After installation: zeus start From another terminal, run zeus server to start a test server or run zeus test to run tests.

Contributing

  • Fork it and create a branch from master
  • Test the code you contribute.
  • Wrap your delegate test cases in VCR.use_cassette... to avoid spamming delegates every time you run the test.
  • Make a github issue if you have questions or encounter bugs
  • Make a pull request when your contribution is ready

Adding a new delegate

Messages are sent to delegates via webforms. To add a new delegate, find their contact page, then implement a class with two public methods: def initialize(message) and def deliver!. message will be an instance of Message Your class should throw an error if it fails to send the message, and return nil if it succeeds.

All classes for contacting reps must use the def agent method provided by including include Delegates::Agent in your class (unless the page requires JavaScript in which case see below). agent returns a Mechanize instance that can be used to drive interaction with the page. See the Delegates::WA::Murray class as an example and the Mechanize docs for more information.

U.S. Representatives

Reps almost all use basically the same website with a multi-step form requiring zip code confirmation before the user can submit the actual message. For these your class should inherit from Delegates::RepBase and override protected methods as needed — usually just def form_url, def rep_name, and def set_form_fields.

Forms requiring JavaScript

Some delegates have contact forms that are handled using JavaScript. For these your class should inherit from Delegates::JSBase, which provides a Capybara session running in Phantomjs accessible via the def session method. See the Delegates::WA::Cantwell class for an example.

Do not use the JSBase class unless the site you are dealing with necessitates it.

VCR cannot intercept HTTP requests from Phantomjs, so your test will make an actual form submission to the delegate every time it runs (assuming it works properly). For this reason, include the :live_test tag in the describe block of your test for the class, so that it won't run on CI and normal test suite runs. See the cantwell_spec.rb for an example.

Contributors

About

bot and frontend for submitting comments to elected officials

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors