Permalink
Browse files

ツイートを一覧表示する機能を追加

  • Loading branch information...
utwang committed Mar 7, 2013
1 parent dd66df2 commit 953894f8a11354eaf3cb5e88d597b6dbba3a63af
@@ -1,4 +1,5 @@
class TweetsController < ApplicationController
def index
+ @tweets = Tweet.all
end
end
View
@@ -0,0 +1,3 @@
+class Tweet < ActiveRecord::Base
+ attr_accessible :content
+end
@@ -1,3 +1,11 @@
<h1>Tweets#index</h1>
<p>Find me in app/views/tweets/index.html.erb</p>
-<input type="text" />
+<input type="text" />
+<table>
+ <% @tweets.each do |tweet| %>
+ <tr>
+ <td><%= tweet.content %></td>
+ </tr>
+ <% end %>
+</table>
+
@@ -0,0 +1,9 @@
+class CreateTweets < ActiveRecord::Migration
+ def change
+ create_table :tweets do |t|
+ t.string :content
+
+ t.timestamps
+ end
+ end
+end
View
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20130121062955) do
+ActiveRecord::Schema.define(:version => 20130307114455) do
create_table "tweets", :force => true do |t|
t.string "content"
View
@@ -0,0 +1,5 @@
+FactoryGirl.define do
+ factory :tweet do
+ content "This is TDD study"
+ end
+end
@@ -0,0 +1,5 @@
+require 'spec_helper'
+
+describe Tweet do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
@@ -2,11 +2,23 @@
describe "TweetPages" do
describe "GET /tweet_pages" do
- before {visit tweets_path}
+ let!(:tweet) { create(:tweet) }
+
+ before { visit tweets_path }
subject {page}
context do
its(:status_code) {should == 200}
it {should have_selector 'input'}
end
+
+ context 'show tweet list' do
+ it { should have_content(tweet.content) }
+ end
+
+ # このテストはIntegrationらしくないので消す
+ context 'show tweet list' do
+ before { create_list(:tweet, 3) }
+ it { Tweet.all.count.should == 4 }
+ end
end
end

0 comments on commit 953894f

Please sign in to comment.