Hacking on Less Wrong

Jack Kelly edited this page Nov 12, 2013 · 44 revisions

Less Wrong development is done from within a virtual machine. Running it natively is unsupported, but if you really want to give it a go, have a look at the chef recipes under cookbooks/.

Getting Started

Set up the VM

Follow the instructions here.

Create some content

To test everything is set up properly create a new article. If that works then you’re good to go.


Can’t register user in Less Wrong

If user registration fails and you keep being presented with new captchas then ensure that memcached is running. You will not be able to register a user if memcached is not running.

Debugging LessWrong in Eclipse

  1. install pydev or aptana studio 3. I’ve tested plugin, not standalone.
  2. create a pydev project selecting python2.5 dialect AND interpreter
  3. import the lesswrong code as a linked entry, but not a virtual folder.
  4. create a new run configuration
  5. set the project to the project you just created
  6. set the main module as /usr/local/bin/paster
  7. set the arguments to point to the development.ini you created. Critically note that reload is not present.
    serve /home/keefe/lib/lesswrong/r2/development.ini port=8080
  8. set the working directory to

now, you can set breakpoints and debug at your leisure.


Setting up

vagrant ssh into the box and install rake and bundler, then pull in the gems and mocktest:

sudo apt-get install rake
sudo gem install bundler
bundle install
sudo easy_install mocktest

Automated Tests

Whilst a bit limited at the moment there are some tests in the r2/r2/tests/unit directory. To run these you will need a test database and the mocktest python package installed. Currently the test files must be run explicitly with nosetests. E.g.

cd /vagrant/r2
nosetests r2/tests/unit

Manual Tests

There is also a manual test script that will step you through a manual test of the site. To run it you will need `ruby` and `rake` installed on the box:

cd /vagrant
bundle exec rake test:manual

Selenium tests

There are some selenium tests for automated, full browser testing. To run these tests you will need ruby installed on your system, which, will in turn, use rspec and capybara. A Gemfile is included in the repo that defines the necessary ruby gems for testing.

Running the tests

The environment for testing is defined in r2/test.ini. If you use this as is, it will run a server for testing on port 8743, and expect to be able to connect to it with the hostname ‘lesswrong.local’. It is recommended that you setup your hosts file so ‘lesswrong.local’ resolves to

Ensure you have set up the reddit_test database as described earlier and that the login creditianals are defined for main_db_user and main_db_pass in r2/test.ini.

Running the full selenium test suite should then be as simple as:

cd /vagrant
bundle exec rake test:run

This will perform a number of steps:

  1. Clean out the test db
  2. Start a server process for testing against
  3. Run selenium-setup that will launch a browser to do basic site setup, such as creating the admin user
  4. Run all the spec/*_spec.rb selenium tests
  5. Stop the server process

To create more selenium tests create a new file in the spec/ directory with the suffix ‘_spec.rb’, for example, spec/commenting_spec.rb. Look at the current tests in spec/main_spec.rb, and the helper methods in spec/spec_helper.rb. When developing new tests, it is possible to run each of the above steps individually (use rake -T to list the available rake tasks).