This commit is contained in:
2014-07-30 10:15:40 +05:30
parent f5beed1264
commit 1871c64e6c
35 changed files with 429 additions and 12 deletions

View File

@@ -0,0 +1,6 @@
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :comment do
end
end

View File

@@ -0,0 +1,15 @@
require 'spec_helper'
# Specs in this file have access to a helper object that includes
# the CommentsHelper. For example:
#
# describe CommentsHelper 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
describe CommentsHelper do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@@ -0,0 +1,5 @@
require 'spec_helper'
describe Comment do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@@ -0,0 +1,11 @@
require 'spec_helper'
describe "Comments" do
describe "GET /comments" do
it "works! (now write some real specs)" do
# Run the generator again with the --webrat flag if you want to use webrat methods/matchers
get comments_path
response.status.should be(200)
end
end
end

View File

@@ -0,0 +1,35 @@
require "spec_helper"
describe CommentsController do
describe "routing" do
it "routes to #index" do
get("/comments").should route_to("comments#index")
end
it "routes to #new" do
get("/comments/new").should route_to("comments#new")
end
it "routes to #show" do
get("/comments/1").should route_to("comments#show", :id => "1")
end
it "routes to #edit" do
get("/comments/1/edit").should route_to("comments#edit", :id => "1")
end
it "routes to #create" do
post("/comments").should route_to("comments#create")
end
it "routes to #update" do
put("/comments/1").should route_to("comments#update", :id => "1")
end
it "routes to #destroy" do
delete("/comments/1").should route_to("comments#destroy", :id => "1")
end
end
end

View File

@@ -0,0 +1,15 @@
require 'spec_helper'
describe "comments/edit" do
before(:each) do
@comment = assign(:comment, stub_model(Comment))
end
it "renders the edit comment form" do
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
assert_select "form[action=?][method=?]", comment_path(@comment), "post" do
end
end
end

View File

@@ -0,0 +1,15 @@
require 'spec_helper'
describe "comments/index" do
before(:each) do
assign(:comments, [
stub_model(Comment),
stub_model(Comment)
])
end
it "renders a list of comments" do
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
end
end

View File

@@ -0,0 +1,15 @@
require 'spec_helper'
describe "comments/new" do
before(:each) do
assign(:comment, stub_model(Comment).as_new_record)
end
it "renders new comment form" do
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
assert_select "form[action=?][method=?]", comments_path, "post" do
end
end
end

View File

@@ -0,0 +1,12 @@
require 'spec_helper'
describe "comments/show" do
before(:each) do
@comment = assign(:comment, stub_model(Comment))
end
it "renders attributes in <p>" do
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
end
end