Permalink
Browse files

Tweak specs

  • Loading branch information...
1 parent 0d8f07f commit c6ca062dc686294805c87db0636583928f71c72a @mattyoho mattyoho committed Jun 21, 2012
View
@@ -31,7 +31,7 @@ group :development, :test do
gem 'guard'
gem 'guard-rspec'
gem 'growl'
- gem 'factory_girl'
+ gem 'factory_girl_rails'
end
group :production do
View
@@ -1,7 +1,7 @@
PATH
remote: ../simple_feed_client
specs:
- simple_feed (0.0.2)
+ simple_feed (0.0.3)
faraday
GEM
@@ -62,6 +62,9 @@ GEM
multi_json (~> 1.0)
factory_girl (3.4.2)
activesupport (>= 3.0.0)
+ factory_girl_rails (3.4.0)
+ factory_girl (~> 3.4.0)
+ railties (>= 3.0.0)
faraday (0.8.0)
multipart-post (~> 1.1)
ffi (1.0.11)
@@ -233,7 +236,7 @@ PLATFORMS
DEPENDENCIES
capybara
coffee-rails (~> 3.2.1)
- factory_girl
+ factory_girl_rails
growl
guard
guard-rspec
View
@@ -11,6 +11,8 @@ def feed_item_of(kind)
send(kind.tableize.to_sym)
end
+ def refeed(foo)
+ end
def items_page_count(page_size=10)
@items_page_count ||= begin
pages, rem = feed_items.count.divmod(page_size)
View
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20120522125411) do
+ActiveRecord::Schema.define(:version => 20120523193054) do
create_table "authentications", :force => true do |t|
t.integer "user_id"
@@ -50,6 +50,7 @@
t.string "salt"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
+ t.string "api_token"
end
add_index "users", ["username"], :name => "index_users_on_username", :unique => true
@@ -0,0 +1,23 @@
+require 'spec_helper'
+
+describe RefeedsController do
+ let!(:user) { FactoryGirl.create(:user) }
+ let!(:feed) { user.feed }
+ let!(:item) { FactoryGirl.create(:text_item) }
+
+ before { controller.stub(:current_user => user) }
+
+ describe "#create" do
+
+ it "refeeds the item onto the user's feed" do
+ feed.should_receive(:refeed).with(item)
+ post :create, feed_item_id: item.id
+ end
+
+ pending "redirects to the user's feed" do
+ post :create, feed_item_id: item.id
+ response.should redirect_to(feed)
+ end
+ end
+end
+
@@ -0,0 +1,5 @@
+FactoryGirl.define do
+ factory :text_item do
+ sequence(:body) {|n| "Text Item #{n}" }
+ end
+end
@@ -0,0 +1,16 @@
+FactoryGirl.define do
+ factory :user do
+ sequence(:username) {|n| "User_#{n}" }
+ email { "#{username}@example.com" }
+ password "hungry"
+ password_confirmation { password }
+
+ factory(:jeff) do
+ username "j3"
+ end
+
+ factory(:matt) do
+ username "mattyoho"
+ end
+ end
+end
@@ -1,27 +1,12 @@
require 'spec_helper'
describe "Refeeding an item" do
- let!(:jeff) do
- if jeff = User.find_by_username('j3')
- jeff
- else
- User.create(:username => 'j3', :email => 'jeff@jumpstartlab.com')
- end
- end
- let!(:matt) do
- if matt = User.find_by_username('mattyoho')
- matt
- else
- User.create(:username => 'mattyoho', :email => 'matt@jumpstartlab.com', :password => 'hungry', :password_confirmation => 'hungry')
- end
- end
+ let!(:jeff) { FactoryGirl.create(:jeff) }
+ let!(:matt) { FactoryGirl.create(:matt) }
context "when I am logged in" do
before do
- visit login_path
- fill_in 'username', :with => 'mattyoho'
- fill_in 'password', :with => 'hungry'
- click_button 'Login'
+ login('mattyoho', 'hungry')
end
context "when there is an item belonging to another user" do
@@ -32,7 +17,7 @@
context "when I view that user's feed" do
before do
- visit feed_path('j3')
+ visit feed_path(jeff.feed)
end
it "I see a refeed button" do
@@ -49,7 +34,7 @@
end
it "shows up in my feed" do
- visit feed_path('mattyoho')
+ visit feed_path(matt.feed)
page.should have_content "This is an item"
end
end
View
@@ -10,8 +10,8 @@
module Sorcery
module TestHelpers
- def login_user(username, password)
- page.driver.post(sessions_url, { username: username, password: password, remember_me: false})
+ def login(username, password)
+ page.driver.post(sessions_url, { username: username, password: password})
end
end
end

0 comments on commit c6ca062

Please sign in to comment.