AutoCommit Don Jul 30 00:03:02 CEST 2015

This commit is contained in:
Andreas Stephanides
2015-07-30 00:03:02 +02:00
parent 068c2a2e55
commit 97df081b33
66 changed files with 1542 additions and 0 deletions

View File

@@ -0,0 +1,159 @@
require 'rails_helper'
# This spec was generated by rspec-rails when you ran the scaffold generator.
# It demonstrates how one might use RSpec to specify the controller code that
# was generated by Rails when you ran the scaffold generator.
#
# It assumes that the implementation code is generated by the rails scaffold
# generator. If you are using any extension libraries to generate different
# controller code, this generated spec may or may not pass.
#
# It only uses APIs available in rails and/or rspec-rails. There are a number
# of tools you can use to make these specs even more expressive, but we're
# sticking to rails and rspec-rails APIs to keep things simple and stable.
#
# Compared to earlier versions of this generator, there is very limited use of
# stubs and message expectations in this spec. Stubs are only used when there
# is no simpler way to get a handle on the object needed for the example.
# Message expectations are only used when there is no simpler way to specify
# that an instance is receiving a specific message.
RSpec.describe Survey::AnswersController, :type => :controller do
# This should return the minimal set of attributes required to create a valid
# Survey::Answer. As you add validations to Survey::Answer, be sure to
# adjust the attributes here as well.
let(:valid_attributes) {
skip("Add a hash of attributes valid for your model")
}
let(:invalid_attributes) {
skip("Add a hash of attributes invalid for your model")
}
# This should return the minimal set of values that should be in the session
# in order to pass any filters (e.g. authentication) defined in
# Survey::AnswersController. Be sure to keep this updated too.
let(:valid_session) { {} }
describe "GET #index" do
it "assigns all survey_answers as @survey_answers" do
answer = Survey::Answer.create! valid_attributes
get :index, {}, valid_session
expect(assigns(:survey_answers)).to eq([answer])
end
end
describe "GET #show" do
it "assigns the requested survey_answer as @survey_answer" do
answer = Survey::Answer.create! valid_attributes
get :show, {:id => answer.to_param}, valid_session
expect(assigns(:survey_answer)).to eq(answer)
end
end
describe "GET #new" do
it "assigns a new survey_answer as @survey_answer" do
get :new, {}, valid_session
expect(assigns(:survey_answer)).to be_a_new(Survey::Answer)
end
end
describe "GET #edit" do
it "assigns the requested survey_answer as @survey_answer" do
answer = Survey::Answer.create! valid_attributes
get :edit, {:id => answer.to_param}, valid_session
expect(assigns(:survey_answer)).to eq(answer)
end
end
describe "POST #create" do
context "with valid params" do
it "creates a new Survey::Answer" do
expect {
post :create, {:survey_answer => valid_attributes}, valid_session
}.to change(Survey::Answer, :count).by(1)
end
it "assigns a newly created survey_answer as @survey_answer" do
post :create, {:survey_answer => valid_attributes}, valid_session
expect(assigns(:survey_answer)).to be_a(Survey::Answer)
expect(assigns(:survey_answer)).to be_persisted
end
it "redirects to the created survey_answer" do
post :create, {:survey_answer => valid_attributes}, valid_session
expect(response).to redirect_to(Survey::Answer.last)
end
end
context "with invalid params" do
it "assigns a newly created but unsaved survey_answer as @survey_answer" do
post :create, {:survey_answer => invalid_attributes}, valid_session
expect(assigns(:survey_answer)).to be_a_new(Survey::Answer)
end
it "re-renders the 'new' template" do
post :create, {:survey_answer => invalid_attributes}, valid_session
expect(response).to render_template("new")
end
end
end
describe "PUT #update" do
context "with valid params" do
let(:new_attributes) {
skip("Add a hash of attributes valid for your model")
}
it "updates the requested survey_answer" do
answer = Survey::Answer.create! valid_attributes
put :update, {:id => answer.to_param, :survey_answer => new_attributes}, valid_session
answer.reload
skip("Add assertions for updated state")
end
it "assigns the requested survey_answer as @survey_answer" do
answer = Survey::Answer.create! valid_attributes
put :update, {:id => answer.to_param, :survey_answer => valid_attributes}, valid_session
expect(assigns(:survey_answer)).to eq(answer)
end
it "redirects to the survey_answer" do
answer = Survey::Answer.create! valid_attributes
put :update, {:id => answer.to_param, :survey_answer => valid_attributes}, valid_session
expect(response).to redirect_to(answer)
end
end
context "with invalid params" do
it "assigns the survey_answer as @survey_answer" do
answer = Survey::Answer.create! valid_attributes
put :update, {:id => answer.to_param, :survey_answer => invalid_attributes}, valid_session
expect(assigns(:survey_answer)).to eq(answer)
end
it "re-renders the 'edit' template" do
answer = Survey::Answer.create! valid_attributes
put :update, {:id => answer.to_param, :survey_answer => invalid_attributes}, valid_session
expect(response).to render_template("edit")
end
end
end
describe "DELETE #destroy" do
it "destroys the requested survey_answer" do
answer = Survey::Answer.create! valid_attributes
expect {
delete :destroy, {:id => answer.to_param}, valid_session
}.to change(Survey::Answer, :count).by(-1)
end
it "redirects to the survey_answers list" do
answer = Survey::Answer.create! valid_attributes
delete :destroy, {:id => answer.to_param}, valid_session
expect(response).to redirect_to(survey_answers_url)
end
end
end

View File

@@ -0,0 +1,159 @@
require 'rails_helper'
# This spec was generated by rspec-rails when you ran the scaffold generator.
# It demonstrates how one might use RSpec to specify the controller code that
# was generated by Rails when you ran the scaffold generator.
#
# It assumes that the implementation code is generated by the rails scaffold
# generator. If you are using any extension libraries to generate different
# controller code, this generated spec may or may not pass.
#
# It only uses APIs available in rails and/or rspec-rails. There are a number
# of tools you can use to make these specs even more expressive, but we're
# sticking to rails and rspec-rails APIs to keep things simple and stable.
#
# Compared to earlier versions of this generator, there is very limited use of
# stubs and message expectations in this spec. Stubs are only used when there
# is no simpler way to get a handle on the object needed for the example.
# Message expectations are only used when there is no simpler way to specify
# that an instance is receiving a specific message.
RSpec.describe Survey::ChoicesController, :type => :controller do
# This should return the minimal set of attributes required to create a valid
# Survey::Choice. As you add validations to Survey::Choice, be sure to
# adjust the attributes here as well.
let(:valid_attributes) {
skip("Add a hash of attributes valid for your model")
}
let(:invalid_attributes) {
skip("Add a hash of attributes invalid for your model")
}
# This should return the minimal set of values that should be in the session
# in order to pass any filters (e.g. authentication) defined in
# Survey::ChoicesController. Be sure to keep this updated too.
let(:valid_session) { {} }
describe "GET #index" do
it "assigns all survey_choices as @survey_choices" do
choice = Survey::Choice.create! valid_attributes
get :index, {}, valid_session
expect(assigns(:survey_choices)).to eq([choice])
end
end
describe "GET #show" do
it "assigns the requested survey_choice as @survey_choice" do
choice = Survey::Choice.create! valid_attributes
get :show, {:id => choice.to_param}, valid_session
expect(assigns(:survey_choice)).to eq(choice)
end
end
describe "GET #new" do
it "assigns a new survey_choice as @survey_choice" do
get :new, {}, valid_session
expect(assigns(:survey_choice)).to be_a_new(Survey::Choice)
end
end
describe "GET #edit" do
it "assigns the requested survey_choice as @survey_choice" do
choice = Survey::Choice.create! valid_attributes
get :edit, {:id => choice.to_param}, valid_session
expect(assigns(:survey_choice)).to eq(choice)
end
end
describe "POST #create" do
context "with valid params" do
it "creates a new Survey::Choice" do
expect {
post :create, {:survey_choice => valid_attributes}, valid_session
}.to change(Survey::Choice, :count).by(1)
end
it "assigns a newly created survey_choice as @survey_choice" do
post :create, {:survey_choice => valid_attributes}, valid_session
expect(assigns(:survey_choice)).to be_a(Survey::Choice)
expect(assigns(:survey_choice)).to be_persisted
end
it "redirects to the created survey_choice" do
post :create, {:survey_choice => valid_attributes}, valid_session
expect(response).to redirect_to(Survey::Choice.last)
end
end
context "with invalid params" do
it "assigns a newly created but unsaved survey_choice as @survey_choice" do
post :create, {:survey_choice => invalid_attributes}, valid_session
expect(assigns(:survey_choice)).to be_a_new(Survey::Choice)
end
it "re-renders the 'new' template" do
post :create, {:survey_choice => invalid_attributes}, valid_session
expect(response).to render_template("new")
end
end
end
describe "PUT #update" do
context "with valid params" do
let(:new_attributes) {
skip("Add a hash of attributes valid for your model")
}
it "updates the requested survey_choice" do
choice = Survey::Choice.create! valid_attributes
put :update, {:id => choice.to_param, :survey_choice => new_attributes}, valid_session
choice.reload
skip("Add assertions for updated state")
end
it "assigns the requested survey_choice as @survey_choice" do
choice = Survey::Choice.create! valid_attributes
put :update, {:id => choice.to_param, :survey_choice => valid_attributes}, valid_session
expect(assigns(:survey_choice)).to eq(choice)
end
it "redirects to the survey_choice" do
choice = Survey::Choice.create! valid_attributes
put :update, {:id => choice.to_param, :survey_choice => valid_attributes}, valid_session
expect(response).to redirect_to(choice)
end
end
context "with invalid params" do
it "assigns the survey_choice as @survey_choice" do
choice = Survey::Choice.create! valid_attributes
put :update, {:id => choice.to_param, :survey_choice => invalid_attributes}, valid_session
expect(assigns(:survey_choice)).to eq(choice)
end
it "re-renders the 'edit' template" do
choice = Survey::Choice.create! valid_attributes
put :update, {:id => choice.to_param, :survey_choice => invalid_attributes}, valid_session
expect(response).to render_template("edit")
end
end
end
describe "DELETE #destroy" do
it "destroys the requested survey_choice" do
choice = Survey::Choice.create! valid_attributes
expect {
delete :destroy, {:id => choice.to_param}, valid_session
}.to change(Survey::Choice, :count).by(-1)
end
it "redirects to the survey_choices list" do
choice = Survey::Choice.create! valid_attributes
delete :destroy, {:id => choice.to_param}, valid_session
expect(response).to redirect_to(survey_choices_url)
end
end
end

View File

@@ -0,0 +1,159 @@
require 'rails_helper'
# This spec was generated by rspec-rails when you ran the scaffold generator.
# It demonstrates how one might use RSpec to specify the controller code that
# was generated by Rails when you ran the scaffold generator.
#
# It assumes that the implementation code is generated by the rails scaffold
# generator. If you are using any extension libraries to generate different
# controller code, this generated spec may or may not pass.
#
# It only uses APIs available in rails and/or rspec-rails. There are a number
# of tools you can use to make these specs even more expressive, but we're
# sticking to rails and rspec-rails APIs to keep things simple and stable.
#
# Compared to earlier versions of this generator, there is very limited use of
# stubs and message expectations in this spec. Stubs are only used when there
# is no simpler way to get a handle on the object needed for the example.
# Message expectations are only used when there is no simpler way to specify
# that an instance is receiving a specific message.
RSpec.describe Survey::QuestionsController, :type => :controller do
# This should return the minimal set of attributes required to create a valid
# Survey::Question. As you add validations to Survey::Question, be sure to
# adjust the attributes here as well.
let(:valid_attributes) {
skip("Add a hash of attributes valid for your model")
}
let(:invalid_attributes) {
skip("Add a hash of attributes invalid for your model")
}
# This should return the minimal set of values that should be in the session
# in order to pass any filters (e.g. authentication) defined in
# Survey::QuestionsController. Be sure to keep this updated too.
let(:valid_session) { {} }
describe "GET #index" do
it "assigns all survey_questions as @survey_questions" do
question = Survey::Question.create! valid_attributes
get :index, {}, valid_session
expect(assigns(:survey_questions)).to eq([question])
end
end
describe "GET #show" do
it "assigns the requested survey_question as @survey_question" do
question = Survey::Question.create! valid_attributes
get :show, {:id => question.to_param}, valid_session
expect(assigns(:survey_question)).to eq(question)
end
end
describe "GET #new" do
it "assigns a new survey_question as @survey_question" do
get :new, {}, valid_session
expect(assigns(:survey_question)).to be_a_new(Survey::Question)
end
end
describe "GET #edit" do
it "assigns the requested survey_question as @survey_question" do
question = Survey::Question.create! valid_attributes
get :edit, {:id => question.to_param}, valid_session
expect(assigns(:survey_question)).to eq(question)
end
end
describe "POST #create" do
context "with valid params" do
it "creates a new Survey::Question" do
expect {
post :create, {:survey_question => valid_attributes}, valid_session
}.to change(Survey::Question, :count).by(1)
end
it "assigns a newly created survey_question as @survey_question" do
post :create, {:survey_question => valid_attributes}, valid_session
expect(assigns(:survey_question)).to be_a(Survey::Question)
expect(assigns(:survey_question)).to be_persisted
end
it "redirects to the created survey_question" do
post :create, {:survey_question => valid_attributes}, valid_session
expect(response).to redirect_to(Survey::Question.last)
end
end
context "with invalid params" do
it "assigns a newly created but unsaved survey_question as @survey_question" do
post :create, {:survey_question => invalid_attributes}, valid_session
expect(assigns(:survey_question)).to be_a_new(Survey::Question)
end
it "re-renders the 'new' template" do
post :create, {:survey_question => invalid_attributes}, valid_session
expect(response).to render_template("new")
end
end
end
describe "PUT #update" do
context "with valid params" do
let(:new_attributes) {
skip("Add a hash of attributes valid for your model")
}
it "updates the requested survey_question" do
question = Survey::Question.create! valid_attributes
put :update, {:id => question.to_param, :survey_question => new_attributes}, valid_session
question.reload
skip("Add assertions for updated state")
end
it "assigns the requested survey_question as @survey_question" do
question = Survey::Question.create! valid_attributes
put :update, {:id => question.to_param, :survey_question => valid_attributes}, valid_session
expect(assigns(:survey_question)).to eq(question)
end
it "redirects to the survey_question" do
question = Survey::Question.create! valid_attributes
put :update, {:id => question.to_param, :survey_question => valid_attributes}, valid_session
expect(response).to redirect_to(question)
end
end
context "with invalid params" do
it "assigns the survey_question as @survey_question" do
question = Survey::Question.create! valid_attributes
put :update, {:id => question.to_param, :survey_question => invalid_attributes}, valid_session
expect(assigns(:survey_question)).to eq(question)
end
it "re-renders the 'edit' template" do
question = Survey::Question.create! valid_attributes
put :update, {:id => question.to_param, :survey_question => invalid_attributes}, valid_session
expect(response).to render_template("edit")
end
end
end
describe "DELETE #destroy" do
it "destroys the requested survey_question" do
question = Survey::Question.create! valid_attributes
expect {
delete :destroy, {:id => question.to_param}, valid_session
}.to change(Survey::Question, :count).by(-1)
end
it "redirects to the survey_questions list" do
question = Survey::Question.create! valid_attributes
delete :destroy, {:id => question.to_param}, valid_session
expect(response).to redirect_to(survey_questions_url)
end
end
end

View File

@@ -0,0 +1,7 @@
FactoryGirl.define do
factory :survey_answer, :class => 'Survey::Answer' do
choice nil
user nil
end
end

View File

@@ -0,0 +1,9 @@
FactoryGirl.define do
factory :survey_choice, :class => 'Survey::Choice' do
text "MyString"
question nil
sort 1
picture "MyString"
end
end

View File

@@ -0,0 +1,8 @@
FactoryGirl.define do
factory :survey_question, :class => 'Survey::Question' do
title "MyString"
text "MyText"
typ 1
end
end

View File

@@ -0,0 +1,15 @@
require 'rails_helper'
# Specs in this file have access to a helper object that includes
# the Survey::AnswersHelper. For example:
#
# describe Survey::AnswersHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
# expect(helper.concat_strings("this","that")).to eq("this that")
# end
# end
# end
RSpec.describe Survey::AnswersHelper, :type => :helper do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@@ -0,0 +1,15 @@
require 'rails_helper'
# Specs in this file have access to a helper object that includes
# the Survey::ChoicesHelper. For example:
#
# describe Survey::ChoicesHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
# expect(helper.concat_strings("this","that")).to eq("this that")
# end
# end
# end
RSpec.describe Survey::ChoicesHelper, :type => :helper do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@@ -0,0 +1,15 @@
require 'rails_helper'
# Specs in this file have access to a helper object that includes
# the Survey::QuestionsHelper. For example:
#
# describe Survey::QuestionsHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
# expect(helper.concat_strings("this","that")).to eq("this that")
# end
# end
# end
RSpec.describe Survey::QuestionsHelper, :type => :helper do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe Survey::Answer, :type => :model do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe Survey::Choice, :type => :model do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe Survey::Question, :type => :model do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@@ -0,0 +1,10 @@
require 'rails_helper'
RSpec.describe "Survey::Answers", :type => :request do
describe "GET /survey_answers" do
it "works! (now write some real specs)" do
get survey_answers_path
expect(response).to have_http_status(200)
end
end
end

View File

@@ -0,0 +1,10 @@
require 'rails_helper'
RSpec.describe "Survey::Choices", :type => :request do
describe "GET /survey_choices" do
it "works! (now write some real specs)" do
get survey_choices_path
expect(response).to have_http_status(200)
end
end
end

View File

@@ -0,0 +1,10 @@
require 'rails_helper'
RSpec.describe "Survey::Questions", :type => :request do
describe "GET /survey_questions" do
it "works! (now write some real specs)" do
get survey_questions_path
expect(response).to have_http_status(200)
end
end
end

View File

@@ -0,0 +1,35 @@
require "rails_helper"
RSpec.describe Survey::AnswersController, :type => :routing do
describe "routing" do
it "routes to #index" do
expect(:get => "/survey/answers").to route_to("survey/answers#index")
end
it "routes to #new" do
expect(:get => "/survey/answers/new").to route_to("survey/answers#new")
end
it "routes to #show" do
expect(:get => "/survey/answers/1").to route_to("survey/answers#show", :id => "1")
end
it "routes to #edit" do
expect(:get => "/survey/answers/1/edit").to route_to("survey/answers#edit", :id => "1")
end
it "routes to #create" do
expect(:post => "/survey/answers").to route_to("survey/answers#create")
end
it "routes to #update" do
expect(:put => "/survey/answers/1").to route_to("survey/answers#update", :id => "1")
end
it "routes to #destroy" do
expect(:delete => "/survey/answers/1").to route_to("survey/answers#destroy", :id => "1")
end
end
end

View File

@@ -0,0 +1,35 @@
require "rails_helper"
RSpec.describe Survey::ChoicesController, :type => :routing do
describe "routing" do
it "routes to #index" do
expect(:get => "/survey/choices").to route_to("survey/choices#index")
end
it "routes to #new" do
expect(:get => "/survey/choices/new").to route_to("survey/choices#new")
end
it "routes to #show" do
expect(:get => "/survey/choices/1").to route_to("survey/choices#show", :id => "1")
end
it "routes to #edit" do
expect(:get => "/survey/choices/1/edit").to route_to("survey/choices#edit", :id => "1")
end
it "routes to #create" do
expect(:post => "/survey/choices").to route_to("survey/choices#create")
end
it "routes to #update" do
expect(:put => "/survey/choices/1").to route_to("survey/choices#update", :id => "1")
end
it "routes to #destroy" do
expect(:delete => "/survey/choices/1").to route_to("survey/choices#destroy", :id => "1")
end
end
end

View File

@@ -0,0 +1,35 @@
require "rails_helper"
RSpec.describe Survey::QuestionsController, :type => :routing do
describe "routing" do
it "routes to #index" do
expect(:get => "/survey/questions").to route_to("survey/questions#index")
end
it "routes to #new" do
expect(:get => "/survey/questions/new").to route_to("survey/questions#new")
end
it "routes to #show" do
expect(:get => "/survey/questions/1").to route_to("survey/questions#show", :id => "1")
end
it "routes to #edit" do
expect(:get => "/survey/questions/1/edit").to route_to("survey/questions#edit", :id => "1")
end
it "routes to #create" do
expect(:post => "/survey/questions").to route_to("survey/questions#create")
end
it "routes to #update" do
expect(:put => "/survey/questions/1").to route_to("survey/questions#update", :id => "1")
end
it "routes to #destroy" do
expect(:delete => "/survey/questions/1").to route_to("survey/questions#destroy", :id => "1")
end
end
end

View File

@@ -0,0 +1,21 @@
require 'rails_helper'
RSpec.describe "survey/answers/edit", :type => :view do
before(:each) do
@survey_answer = assign(:survey_answer, Survey::Answer.create!(
:choice => nil,
:user => nil
))
end
it "renders the edit survey_answer form" do
render
assert_select "form[action=?][method=?]", survey_answer_path(@survey_answer), "post" do
assert_select "input#survey_answer_choice[name=?]", "survey_answer[choice]"
assert_select "input#survey_answer_user[name=?]", "survey_answer[user]"
end
end
end

View File

@@ -0,0 +1,22 @@
require 'rails_helper'
RSpec.describe "survey/answers/index", :type => :view do
before(:each) do
assign(:survey_answers, [
Survey::Answer.create!(
:choice => nil,
:user => nil
),
Survey::Answer.create!(
:choice => nil,
:user => nil
)
])
end
it "renders a list of survey/answers" do
render
assert_select "tr>td", :text => nil.to_s, :count => 2
assert_select "tr>td", :text => nil.to_s, :count => 2
end
end

View File

@@ -0,0 +1,21 @@
require 'rails_helper'
RSpec.describe "survey/answers/new", :type => :view do
before(:each) do
assign(:survey_answer, Survey::Answer.new(
:choice => nil,
:user => nil
))
end
it "renders new survey_answer form" do
render
assert_select "form[action=?][method=?]", survey_answers_path, "post" do
assert_select "input#survey_answer_choice[name=?]", "survey_answer[choice]"
assert_select "input#survey_answer_user[name=?]", "survey_answer[user]"
end
end
end

View File

@@ -0,0 +1,16 @@
require 'rails_helper'
RSpec.describe "survey/answers/show", :type => :view do
before(:each) do
@survey_answer = assign(:survey_answer, Survey::Answer.create!(
:choice => nil,
:user => nil
))
end
it "renders attributes in <p>" do
render
expect(rendered).to match(//)
expect(rendered).to match(//)
end
end

View File

@@ -0,0 +1,27 @@
require 'rails_helper'
RSpec.describe "survey/choices/edit", :type => :view do
before(:each) do
@survey_choice = assign(:survey_choice, Survey::Choice.create!(
:text => "MyString",
:question => nil,
:sort => 1,
:picture => "MyString"
))
end
it "renders the edit survey_choice form" do
render
assert_select "form[action=?][method=?]", survey_choice_path(@survey_choice), "post" do
assert_select "input#survey_choice_text[name=?]", "survey_choice[text]"
assert_select "input#survey_choice_question[name=?]", "survey_choice[question]"
assert_select "input#survey_choice_sort[name=?]", "survey_choice[sort]"
assert_select "input#survey_choice_picture[name=?]", "survey_choice[picture]"
end
end
end

View File

@@ -0,0 +1,28 @@
require 'rails_helper'
RSpec.describe "survey/choices/index", :type => :view do
before(:each) do
assign(:survey_choices, [
Survey::Choice.create!(
:text => "Text",
:question => nil,
:sort => 1,
:picture => "Picture"
),
Survey::Choice.create!(
:text => "Text",
:question => nil,
:sort => 1,
:picture => "Picture"
)
])
end
it "renders a list of survey/choices" do
render
assert_select "tr>td", :text => "Text".to_s, :count => 2
assert_select "tr>td", :text => nil.to_s, :count => 2
assert_select "tr>td", :text => 1.to_s, :count => 2
assert_select "tr>td", :text => "Picture".to_s, :count => 2
end
end

View File

@@ -0,0 +1,27 @@
require 'rails_helper'
RSpec.describe "survey/choices/new", :type => :view do
before(:each) do
assign(:survey_choice, Survey::Choice.new(
:text => "MyString",
:question => nil,
:sort => 1,
:picture => "MyString"
))
end
it "renders new survey_choice form" do
render
assert_select "form[action=?][method=?]", survey_choices_path, "post" do
assert_select "input#survey_choice_text[name=?]", "survey_choice[text]"
assert_select "input#survey_choice_question[name=?]", "survey_choice[question]"
assert_select "input#survey_choice_sort[name=?]", "survey_choice[sort]"
assert_select "input#survey_choice_picture[name=?]", "survey_choice[picture]"
end
end
end

View File

@@ -0,0 +1,20 @@
require 'rails_helper'
RSpec.describe "survey/choices/show", :type => :view do
before(:each) do
@survey_choice = assign(:survey_choice, Survey::Choice.create!(
:text => "Text",
:question => nil,
:sort => 1,
:picture => "Picture"
))
end
it "renders attributes in <p>" do
render
expect(rendered).to match(/Text/)
expect(rendered).to match(//)
expect(rendered).to match(/1/)
expect(rendered).to match(/Picture/)
end
end

View File

@@ -0,0 +1,24 @@
require 'rails_helper'
RSpec.describe "survey/questions/edit", :type => :view do
before(:each) do
@survey_question = assign(:survey_question, Survey::Question.create!(
:title => "MyString",
:text => "MyText",
:typ => 1
))
end
it "renders the edit survey_question form" do
render
assert_select "form[action=?][method=?]", survey_question_path(@survey_question), "post" do
assert_select "input#survey_question_title[name=?]", "survey_question[title]"
assert_select "textarea#survey_question_text[name=?]", "survey_question[text]"
assert_select "input#survey_question_typ[name=?]", "survey_question[typ]"
end
end
end

View File

@@ -0,0 +1,25 @@
require 'rails_helper'
RSpec.describe "survey/questions/index", :type => :view do
before(:each) do
assign(:survey_questions, [
Survey::Question.create!(
:title => "Title",
:text => "MyText",
:typ => 1
),
Survey::Question.create!(
:title => "Title",
:text => "MyText",
:typ => 1
)
])
end
it "renders a list of survey/questions" do
render
assert_select "tr>td", :text => "Title".to_s, :count => 2
assert_select "tr>td", :text => "MyText".to_s, :count => 2
assert_select "tr>td", :text => 1.to_s, :count => 2
end
end

View File

@@ -0,0 +1,24 @@
require 'rails_helper'
RSpec.describe "survey/questions/new", :type => :view do
before(:each) do
assign(:survey_question, Survey::Question.new(
:title => "MyString",
:text => "MyText",
:typ => 1
))
end
it "renders new survey_question form" do
render
assert_select "form[action=?][method=?]", survey_questions_path, "post" do
assert_select "input#survey_question_title[name=?]", "survey_question[title]"
assert_select "textarea#survey_question_text[name=?]", "survey_question[text]"
assert_select "input#survey_question_typ[name=?]", "survey_question[typ]"
end
end
end

View File

@@ -0,0 +1,18 @@
require 'rails_helper'
RSpec.describe "survey/questions/show", :type => :view do
before(:each) do
@survey_question = assign(:survey_question, Survey::Question.create!(
:title => "Title",
:text => "MyText",
:typ => 1
))
end
it "renders attributes in <p>" do
render
expect(rendered).to match(/Title/)
expect(rendered).to match(/MyText/)
expect(rendered).to match(/1/)
end
end