Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 64 lines (41 sloc) 2.178 kB
f47e87b @dchelimsky Don't generate autotest/discover.rb
dchelimsky authored
1 # rspec-rails-2.3.0
2
3 ## autotest integration
4
5 Add a .rspec file to the project's root directory (if not already there) to
6 tell RSpec to tell Autotest to use RSpec's specialized Autotest class.
7
8 NOTE that rspec-core-2.0, 2.1, and 2.2 required an autotest/discover.rb file in
9 the project's root directory. This worked with some, but not all versions of
10 autotest and/or the autotest command that ships with ZenTest. This new approach
11 will work regardless of which version of autotest/ZenTest you are using.
beb9fb9 @dchelimsky doc re: webrat/capybara
dchelimsky authored
12
d2ef593 @dchelimsky Generate stub_model(X).as_new_record in generated "new" view specs
dchelimsky authored
13 ## Webrat and Capybara
beb9fb9 @dchelimsky doc re: webrat/capybara
dchelimsky authored
14
d2ef593 @dchelimsky Generate stub_model(X).as_new_record in generated "new" view specs
dchelimsky authored
15 Earlier 2.0.0.beta versions depended on Webrat. As of
16 rspec-rails-2.0.0.beta.20, this dependency and offers you a choice of using
17 webrat or capybara. Just add the library of your choice to your Gemfile.
e71fe60 @dchelimsky Upgrade.markdown
dchelimsky authored
18
f5732f6 @dchelimsky words
dchelimsky authored
19 ## Controller specs
e71fe60 @dchelimsky Upgrade.markdown
dchelimsky authored
20
61f5bcc @dchelimsky Stub template content in controller specs instead of using NullResolver
dchelimsky authored
21 ### islation from view templates
f5732f6 @dchelimsky words
dchelimsky authored
22
61f5bcc @dchelimsky Stub template content in controller specs instead of using NullResolver
dchelimsky authored
23 By default, controller specs do _not_ render view templates. This keeps
24 controller specs isolated from the content of views and their requirements.
f5732f6 @dchelimsky words
dchelimsky authored
25
61f5bcc @dchelimsky Stub template content in controller specs instead of using NullResolver
dchelimsky authored
26 NOTE that the template must exist, but it will not be rendered. This is
27 different from rspec-rails-1.x, in which the template didn't need to exist, but
28 ActionController makes a number of new decisions in Rails 3 based on the
29 existence of the template. To keep the RSpec code free of monkey patches, and
30 to keep the rspec user experience simpler, we decided that this would be a fair
31 trade-off.
f5732f6 @dchelimsky words
dchelimsky authored
32
33 ## View specs
e71fe60 @dchelimsky Upgrade.markdown
dchelimsky authored
34
012fd22 @dchelimsky update history/upgrade w/ info about stub_template
dchelimsky authored
35 ### view.should render_template
36
61f5bcc @dchelimsky Stub template content in controller specs instead of using NullResolver
dchelimsky authored
37 Rails changed the way it renders partials, so to set an expectation that a
012fd22 @dchelimsky update history/upgrade w/ info about stub_template
dchelimsky authored
38 partial gets rendered, you need
e71fe60 @dchelimsky Upgrade.markdown
dchelimsky authored
39
61f5bcc @dchelimsky Stub template content in controller specs instead of using NullResolver
dchelimsky authored
40 render
41 view.should render_template(:partial => "widget/_row")
e71fe60 @dchelimsky Upgrade.markdown
dchelimsky authored
42
012fd22 @dchelimsky update history/upgrade w/ info about stub_template
dchelimsky authored
43 ### stub_template
44
45 Introduced in rspec-rails-2.2, simulates the presence of view templates on the
46 file system. This supports isolation from partials rendered by the vew template
47 that is the subject of a view example:
48
49 stub_template "widgets/_widget.html.erb" => "This Content"
50
51 ### as_new_record
d2ef593 @dchelimsky Generate stub_model(X).as_new_record in generated "new" view specs
dchelimsky authored
52
53 Earlier versions of the view generators generated stub_model with `:new_record?
012fd22 @dchelimsky update history/upgrade w/ info about stub_template
dchelimsky authored
54 => true`. That is no longer recognized in rspec-rails-2, so you need to change
55 this:
d2ef593 @dchelimsky Generate stub_model(X).as_new_record in generated "new" view specs
dchelimsky authored
56
57 stub_model(Widget, :new_record? => true)
58
59 to this:
60
61 stub_model(Widget).as_new_record
62
63 Generators in 2.0.0 final release will do the latter.
Something went wrong with that request. Please try again.