Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 149 lines (99 sloc) 4.297 kB
919e6a7 @dchelimsky prep for 1.3.2
authored
1 = Upgrade to 1.2.8 - 1.3.2
cab8757 @dchelimsky spec_server is dead! Long live spork!
authored
2
c74cd2e @dchelimsky history/upgrade
authored
3 == What's new
4
5 === route_to and be_routable matchers
6
7 Stop using route_for and params_from today! These new matchers from Randy
8 Harmon are more expressive and more reliable. Here's how you use them:
9
10 { :put => "/projects/37" }.should route_to(:controller => 'projects', :action => 'update', :id => '37')
11
12 { :get => "/nonexisting_route" }.should_not be_routable
13
cab8757 @dchelimsky spec_server is dead! Long live spork!
authored
14 == What's changed
15
16 === spec_server has been removed
17
18 spec_server was deprecated in 1.2.7 and has now been removed. Admittedly, this
19 was a short deprecation cycle, but spec server never quite worked right in all
20 situations and spork is a great solution that you can use today! This is all
21 you need to do:
22
23 [sudo] gem install spork
24 cd path/to/project
25 spork --bootsrap
26
27 Now open up spec/spec_helper.rb and follow the directions at the top. You'll
28 be up and running in no time.
29
30 For more info:
31
32 * http://github.com/timcharper/spork
33 * http://groups.google.com/group/sporkgem
34
38f7ad9 @dchelimsky bump to 1.2.7 final
authored
35 = Upgrade to 1.2.7
fc5cf35 @dchelimsky deprecate spec_server (recommend using spork instead)
authored
36
37 == What's changed
38
39 === spec_server is deprecated
40
41 spec_server is deprecated in favor of Tim Harper's new spork library
42 (http://github.com/timcharper/spork). Get it. Use it. Love it.
43
44 gem install spork
45
c2b097f @dchelimsky bump version to 1.2.6
authored
46 = Upgrade to 1.2.0-1.2.6
2e8cedd @dchelimsky words
authored
47
e612b64 @dchelimsky .rdoc
authored
48 == What's changed
4b30e32 @dchelimsky words
authored
49
e612b64 @dchelimsky .rdoc
authored
50 === Supported Rails Versions
6e5e5eb @dchelimsky words
authored
51
52 This release supports the following versions of rails:
53
54 * 2.0.5
55 * 2.1.2
56 * 2.2.2
93c54cc @dchelimsky words
authored
57 * 2.3.2
6e5e5eb @dchelimsky words
authored
58
e612b64 @dchelimsky .rdoc
authored
59 === update generated files
2e8cedd @dchelimsky words
authored
60
61 Be sure to run "script/generate rspec" and allow the following files to be overwritten:
62
63 * lib/tasks/rspec.rake
17181d6 @dchelimsky words
authored
64 * script/spec
2e8cedd @dchelimsky words
authored
65 * script/spec_server
66
e612b64 @dchelimsky .rdoc
authored
67 === controller.use_rails_error_handling! is deprecated
2e8cedd @dchelimsky words
authored
68
e612b64 @dchelimsky .rdoc
authored
69 Use <tt>rescue_action_in_public!</tt> instead. It comes directly from rails and does
6e5e5eb @dchelimsky words
authored
70 exactly the same thing
2e8cedd @dchelimsky words
authored
71
e612b64 @dchelimsky .rdoc
authored
72 === route_for
2e8cedd @dchelimsky words
authored
73
e612b64 @dchelimsky .rdoc
authored
74 After a change to edge rails broke our monkey-patched <tt>route_for</tt> method, I
75 decided to just delegate to rails' <tt>assert_generates</tt> method. For most cases,
2e8cedd @dchelimsky words
authored
76 this will not present a problem, but for some it might. You'll know if you
77 upgrade and see any newly failing, route-related examples. Here are the things
78 that you might need to change.
79
e612b64 @dchelimsky .rdoc
authored
80 ==== Make sure IDs are strings
2e8cedd @dchelimsky words
authored
81
82 If you had :id => 1 before, you need to change that to :id => "1"
83
4b30e32 @dchelimsky words
authored
84 #old
85 route_for(:controller => 'things', :action => 'show', :id => 1).should == "/things/1"
2e8cedd @dchelimsky words
authored
86
4b30e32 @dchelimsky words
authored
87 #new
88 route_for(:controller => 'things', :action => 'show', :id => "1").should == "/things/1"
2e8cedd @dchelimsky words
authored
89
e612b64 @dchelimsky .rdoc
authored
90 ==== Convert paths for non-get methods to hashes
2e8cedd @dchelimsky words
authored
91
92 If you had an example with a route that requires post, put, or delete, you'll
93 need to declare that explicitly.
94
4b30e32 @dchelimsky words
authored
95 #old
96 route_for(:controller => 'things', :action => 'create').should == "/things"
97
98 #new
99 route_for(:controller => 'things', :action => 'create').should == {:path => "/things", :method => :post}
2e8cedd @dchelimsky words
authored
100
e612b64 @dchelimsky .rdoc
authored
101 === Controller/template isolation
4b30e32 @dchelimsky words
authored
102
103 Even though controller specs do not render views by default (use
e612b64 @dchelimsky .rdoc
authored
104 <tt>integrate_views</tt> to get them to render views), the way this works has
4b30e32 @dchelimsky words
authored
105 changed in this version.
106
107 It used to be that the view template need not even exist, but due to changes
108 in rails it became much more difficult to manage that for all the different
109 versions of rails that rspec-rails supports. So now the template must exist,
e612b64 @dchelimsky .rdoc
authored
110 but it still won't be rendered unless you declare <tt>integrate_views</tt>.
4b30e32 @dchelimsky words
authored
111
e612b64 @dchelimsky .rdoc
authored
112 == What's new
4b30e32 @dchelimsky words
authored
113
e612b64 @dchelimsky .rdoc
authored
114 === render no longer requires a path
4b30e32 @dchelimsky words
authored
115
e612b64 @dchelimsky .rdoc
authored
116 The <tt>render()</tt> method in view specs will infer the path from the
117 first argument passed to <tt>describe()</tt>.
4b30e32 @dchelimsky words
authored
118
119 describe "players/show" do
120 it "does something" do
121 render
122 response.should have_tag("....")
123 end
124 end
125
e612b64 @dchelimsky .rdoc
authored
126 === routing specs live in spec/routing
f49f7e1 @dchelimsky more words
authored
127
e612b64 @dchelimsky .rdoc
authored
128 <tt>script/generate rspec_scaffold</tt> now generates its routing spec in
129 <tt>spec/routing/</tt>.
f49f7e1 @dchelimsky more words
authored
130
e612b64 @dchelimsky .rdoc
authored
131 === bypass_rescue
f49f7e1 @dchelimsky more words
authored
132
e612b64 @dchelimsky .rdoc
authored
133 Added a new <tt>bypass_rescue()</tt> declaration for controller specs. Use this
f49f7e1 @dchelimsky more words
authored
134 when you want to specify that an error is raised by an action, even if that
e612b64 @dchelimsky .rdoc
authored
135 error is later captured by a <tt>rescue_from()</tt> declaration.
f49f7e1 @dchelimsky more words
authored
136
137 describe AccountController do
138 describe "GET @account" do
139 context "requested by anonymous user" do
140 it "denies access" do
141 bypass_rescue
142 lambda do
143 get :show, :id => "37"
144 end.should raise_error(AccessDenied)
145 end
146 end
147 end
148 end
Something went wrong with that request. Please try again.