Hacking on Less Wrong
Clone this wiki locally
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
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
- install pydev or aptana studio 3. I’ve tested plugin, not standalone.
- create a pydev project selecting python2.5 dialect AND interpreter
- import the lesswrong code as a linked entry, but not a virtual folder.
- create a new run configuration
- set the project to the project you just created
- set the main module as /usr/local/bin/paster
- 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
- set the working directory to
now, you can set breakpoints and debug at your leisure.
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
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
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
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 127.0.0.1.
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
Running the full selenium test suite should then be as simple as:
bundle exec rake test:run
This will perform a number of steps:
- Clean out the test db
- Start a server process for testing against
- Run selenium-setup that will launch a browser to do basic site setup, such as creating the admin user
- Run all the spec/*_spec.rb selenium tests
- 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).