-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME
130 lines (79 loc) · 2.31 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
copyright 2008 Paul Cortens
see the presentations directory for more helpful documents
A basic example of TDD with Cucumber and RSpec
Steps in this document correspond to tags in my git repository
rails cuc_demo
cd cuc_demo
script/generate cucumber
script/generate rspec
*Step 0*
Add the feature
*Step 1*
rake db:migrate
rake db:test:prepare
(to create db/schema.rb)
rake features
or
AUTOFEATURE=true autospec
add some matchers
*Step 2*
script/generate rspec_model Postie name:string body:text
rake db:migrate
db:test:prepare
rake features
*Step 3*
Need to require webrat (so we get the nice stuff like visits '/')
*Step 4*
Set up a root route (it doesn't load the static page)
script/generate rspec_controller Posties new create show
in routes.rb
map.resources :posties
map.root :controller => 'posties', :action => 'new'
*Step 5*
describe PostiesController do
describe "GET 'new'" do
it "should assign a new postie to the view" do
make it pass
*Step 6*
add the new postie form to app/views/posties/new.html.erb
remove view specs
- I will let cucumber test the views
*Step 7*
still fails - Webrat uses label (i.e. what the customer sees)
update form to have 'nice' labels
*Step 8*
We forgot the button
Update feature
Update view
*Step 9*
Implement create action
Rails has the singular of posties as posty
inflect.irregular 'postie', 'posties'
describe PostiesController do
describe "POST 'create'" do
describe "with valid attributes" do
it "should redirect to the show pastie page" do
This feature doesn't have the negative, so I didn't implement it
*Step 10*
Note how cucumber is rendering Posties#show now (instead of Posties#create)
add our fields to app/views/pasties/show.html.erb
describe PostiesController do
describe "GET 'show'" do
it "should assign a the postie to the view" do
*Step 11*
Need to fix our routes
I also did some messing around with the model to get the pretty urls
*Step 12*
Bug in my routes. I was using PUT instead of POST (for create)
*Step 13*
A few more bugs with the params
Need to have Postie#to_params use the pretty_id
*Step 14*
git rm public/index.html
*Step 15*
Fire up the browser (for the first time)
Add more examples to the feature
*Step 16*
They fail because my code escapes the HTML, but the matchers don't.
*Step 17*
That's it :)