questions_controller_spec.rb
1.32 KB
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
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe QuestionsController do
# integrate_views
#
def sign_in_as(user)
@controller.current_user = user
return user
end
#
before(:each) do
@user = Factory.create(:user, :email => "pius@alum.mit.edu", :password => "password", :password_confirmation => "password", :id => 8)
sign_in_as(@user = Factory(:email_confirmed_user))
@question = @user.create_question("foobarbaz", {:name => 'foo'})
end
it "responds with basic question information" do
get :show, :id => @question.id, :format => "xml"
assigns[:question].should == @question
@response.body.should have_tag("question")
end
it "responds with question with prompt and appearance and visitor information" do
get :show, :id => @question.id, :format => "xml", :with_appearance => true, :with_prompt => true, :with_visitor_stats => true, :visitor_identifier => "jim"
assigns[:question].should == @question
#@response.body.should be_nil
@response.body.should have_tag("question")
@response.body.should have_tag("picked_prompt_id")
@response.body.should have_tag("appearance_id")
@response.body.should have_tag("visitor_votes")
@response.body.should have_tag("visitor_ideas")
end
end