Permalink
Browse files

Question Presenter spec

  • Loading branch information...
ArturG committed Mar 3, 2014
1 parent 0e3bb4e commit 0cabceeb82b40aceca9e3adb1b6d4c47b40061ea
@@ -22,14 +22,14 @@ def collection_path
end
def edit_resource_path
- edit_question_path
+ edit_question_path(@question)
end
def apply_scope(chain)
chain.no_supports
end
def answers_path
- question_answer_path(@question)
+ question_answers_path(@question)
end
end
@@ -0,0 +1,9 @@
+require 'spec_helper'
+
+describe StaticController do
+ describe "GET root" do
+ it "responds with success" do
+ expect(:get => "/").to route_to(:controller => "static", :action => "root")
+ end
+ end
+end
@@ -1,4 +1,3 @@
Fabricator(:answer) do
description "MyString"
- user ""
end
@@ -1,4 +1,5 @@
Fabricator(:question) do
+ id "RandomID"
title "Title"
description "Description"
user
View
@@ -0,0 +1,14 @@
+require 'spec_helper'
+
+describe Rel do
+
+ before do
+ @rel = Rel.create(:slug => 'text', :description => 'some text')
+ end
+
+ context 'to_param' do
+ it 'returns slug' do
+ @rel.to_param.should == 'text'
+ end
+ end
+end
@@ -0,0 +1,46 @@
+require 'spec_helper'
+
+describe QuestionPresenter do
+
+ let(:question){Fabricate(:question)}
+ let(:another_question){Fabricate(:question, :id => 'AnotherID')}
+ let(:answer){Fabricate(:answer, :question_id => question.id)}
+
+ before do
+ @qp = QuestionPresenter.new(question)
+ end
+
+ context 'collection_path' do
+ it 'returns questions_path' do
+ @qp.collection_path.should == '/questions'
+ end
+ end
+
+ context 'edit_resource_path' do
+ it 'returns edit_question_path' do
+ @qp.edit_resource_path.should == '/questions/RandomID/edit'
+ end
+ end
+
+ context 'new_resource_path' do
+ it 'returns new_question_path' do
+ @qp.new_resource_path.should == '/questions/new'
+ end
+ end
+
+ context 'resource_path' do
+ it 'returns self question path if nil' do
+ @qp.resource_path(nil).should == '/questions/RandomID'
+ end
+
+ it 'returns question path if not nil' do
+ @qp.resource_path(another_question).should == '/questions/AnotherID'
+ end
+ end
+
+ context 'answers_path' do
+ it 'returns questions answer path' do
+ @qp.answers_path.should == '/questions/RandomID/answers'
+ end
+ end
+end

0 comments on commit 0cabcee

Please sign in to comment.