rails g scaffold Comment

This commit is contained in:
gnattery committed 2013-02-06 14:49:49 +11:00
1 parent 7beaf4afa4
commit 3cff543184
21 files changed
+493 -1

No files matched your search

@@ -0,0 +1,22 @@
require 'spec_helper'
describe "comments/edit" do
before(:each) do
@comment = assign(:comment, stub_model(Comment,
:post_id => 1,
:author_id => 1,
:body => "MyText"
))
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 => comments_path(@comment), :method => "post" do
assert_select "input#comment_post_id", :name => "comment[post_id]"
assert_select "input#comment_author_id", :name => "comment[author_id]"
assert_select "textarea#comment_body", :name => "comment[body]"
end
end
end
@@ -0,0 +1,26 @@
require 'spec_helper'
describe "comments/index" do
before(:each) do
assign(:comments, [
stub_model(Comment,
:post_id => 1,
:author_id => 2,
:body => "MyText"
),
stub_model(Comment,
:post_id => 1,
:author_id => 2,
:body => "MyText"
)
])
end
it "renders a list of comments" do
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
assert_select "tr>td", :text => 1.to_s, :count => 2
assert_select "tr>td", :text => 2.to_s, :count => 2
assert_select "tr>td", :text => "MyText".to_s, :count => 2
end
end
+22
View File
@@ -0,0 +1,22 @@
require 'spec_helper'
describe "comments/new" do
before(:each) do
assign(:comment, stub_model(Comment,
:post_id => 1,
:author_id => 1,
:body => "MyText"
).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 => comments_path, :method => "post" do
assert_select "input#comment_post_id", :name => "comment[post_id]"
assert_select "input#comment_author_id", :name => "comment[author_id]"
assert_select "textarea#comment_body", :name => "comment[body]"
end
end
end
@@ -0,0 +1,19 @@
require 'spec_helper'
describe "comments/show" do
before(:each) do
@comment = assign(:comment, stub_model(Comment,
:post_id => 1,
:author_id => 2,
:body => "MyText"
))
end
it "renders attributes in <p>" do
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
rendered.should match(/1/)
rendered.should match(/2/)
rendered.should match(/MyText/)
end
end