-
Notifications
You must be signed in to change notification settings - Fork 0
/
events_controller_spec.rb
128 lines (98 loc) · 3.01 KB
/
events_controller_spec.rb
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
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
describe Api::EventsController do
def setup
@controller = Api::EventsController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
end
#The index action finds all events, assigns the resulting array to @events, and renders the index template:
######### INDEX #######
describe Api::EventsController do
before :each do
@event = mock_model(Event)
Event.stub!(:new).and_return(@event)
end
describe "GET: index" do
before :each do
@events = Array.new { mock_model(Event) }
Event.stub!(:find).and_return(@events)
end
it "should be successful" do
get :index,:format=>:xml
should respond_to(:index)
end
it "should load a list of all events" do
#~ Event.should_receive(:find).and_return(@events)
Event.should_receive(:find).any_number_of_times
get :index,:format=>:xml
end
it "should assign @events" do
get :index,:format=>:xml
assigns[:events].should == @events
end
it "should render the index template" do
get :index,:format=>:html
#~ @response.should render_template(:index)
#~ @response.should redirect_to(events_url(@events))
end
end
end
######### INDEX END #######
############ SHOW ########
describe "GET: show" do
before :each do
Event.stub!(:find).and_return(@events)
end
it "should load the requested events" do
Event.should_receive(:find).and_return(@events)
get :show,:format=>:xml, :id => 1
end
it "should assign @event" do
get :show, :format=>:xml,:id => 1
assigns[:events].should == @events
end
it "should render the show template" do
get :show,:format=>:xml,:id => 1
#~ @response.should render_template(:show)
end
end
############# SHOW END ########
############ Map ########
describe "GET: map" do
before :each do
Event.stub!(:find).and_return(@events)
end
it "should load the requested event maps" do
Event.should_receive(:find).any_number_of_times
get :map, :format=>:xml
end
it "should assign @event" do
get :map, :format=>:xml
assigns[:events].should == @events
end
it "should render the show template" do
get :map,:format=>:xml
#~ @response.should render_template(:show)
end
end
############# Map END ########
############ In ########
describe "GET: In" do
before :each do
Event.stub!(:find).and_return(@events)
end
it "should load the requested event maps" do
Event.should_receive(:find).any_number_of_times
get :in, :format=>:xml
end
it "should assign @event" do
get :in, :format=>:xml
assigns[:events].should == @events
end
it "should render the show template" do
get :in,:format=>:xml
#~ @response.should render_template(:show)
end
end
############# In END ########
end