Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 86 lines (60 sloc) 3.4 kb
a1ed544 @eric1234 Initial checking
authored
1 = DESCRIPTION
2
3 Allows you to easily implement testing for a Rails engine.
4
5 = USAGE
6
7 Add test_engine as a development dependency to your gemspec
8
9 s.add_development_dependency 'test_engine'
10
11 If you are using Test::Unit then add the following to your Rakefile. This will
12 define standard test tasks (test:units, test:functionals, test:integration):
13
14 require 'test_engine/test_unit'
15
16 Other test frameworks are not supported but this library is structured so that
17 support can be easily added. I welcome patches.
18
19 By default your tests are run against the latest version of Rails installed
20 on your machine. But if you wish to run against an earlier version, use the
21 environment variable RAILS_VERSION
22
23 RAILS_VERSION=3.1.3 bundle exec rake test
24
25 If you need to include a library for your testing add it as a development
26 dependency in your gemspec. For example if you need Capybara for your
27 integration tests just add the following to your engine's gemspec.
28
29 s.add_development_dependency 'capybara'
30 s.add_development_dependency 'database_cleaner'
31
32 Only Rails 3 and greater is supported. This library assumes the tmp directory
33 in your project is ok to stick temp files and you should have this directory
34 ignored by your SCM.
35
36 == test:engine:clean
37
38 To test your engine a dummy app is generated so your tests run in a real Rails
39 environment. These dummy apps are re-used between test runs to keep things
40 moving faster. If you need these dummy apps to be re-generated you can use
41 this task to clean out the unwanted apps. This removes all dummy apps. If you
42 just wish to remove a specific version you can use the RAILS_VERSION environment
43 variable.
44
45 == Bundler sudo prompt
46
47 Since a real Rails app is being generated bundler is being run on that app to
48 ensure you have all the necessary dependencies. This means you may get a sudo
49 prompt so the gems can be installed system-wide (just like as if you ran bundler
50 manually on the app). If you do just enter the password and it will happily
51 continue on.
52
ae69db1 @eric1234 Add some examples for people to look at
authored
53 = Examples
54
55 If you want to see some real engines that use this library check out the
56 following:
57
7d8e0bd @eric1234 I evidently cannot write rdoc
authored
58 * logmein[https://github.com/eric1234/logmein] - An engine for allowing users
59 to login and logout.
60 * remindme[https://github.com/eric1234/logmein] - An engine to allow a user
61 to request a password reset, be sent a token link in e-mail which takes the
62 user to a form so they can enter a new password.
ae69db1 @eric1234 Add some examples for people to look at
authored
63
a1ed544 @eric1234 Initial checking
authored
64 = Testing This Library
65
66 bundler exec rake test
67
68 Since the tests need to generate an old version of a Rails app you need
69 a version of Rails >= 3.0 that is NOT the latest version installed.
70
71 = Alternatives
72
73 The two main alternatives to this libary are:
74
75 * Including a dummy app in the engine:
76 We are actually doing this but instead of having you setup this manually
77 and check it into your repo, this library is generating it at test time.
78 * Faking a stripped down version of rails:
79 This tries to avoid generating a full Rails app. A good example of this is
80 https://github.com/freelancing-god/combustion. While interesting, it seems
81 very fragile (i.e. new versions of Rails could break easy) and since it isn't
82 a normal Rails setup you might not have the same test results as you would
83 have running it in a real app. I think this is where we should move to as
84 generating an app is a crutch. But I think it should be something natively
85 supported by Rails not hacked on.
Something went wrong with that request. Please try again.