Commit 2d068d29 by tady

spec devise macros

parent 083a28fd
...@@ -11,12 +11,12 @@ ...@@ -11,12 +11,12 @@
= render partial: 'posts/large_item', locals: { post: _post } = render partial: 'posts/large_item', locals: { post: _post }
.col-xs-4 .col-xs-4
.panel.panel-default / .panel.panel-default
.panel-heading / .panel-heading
h2.panel-title この1週間で閲覧の多かった投稿(調整中) / h2.panel-title この1週間で閲覧の多かった投稿(調整中)
.panel-body.list-group / .panel-body.list-group
- Post.limit(5).each do |_post| / - Post.limit(5).each do |_post|
= render partial: 'posts/small_item', locals: { post: _post } / = render partial: 'posts/small_item', locals: { post: _post }
.panel.panel-default .panel.panel-default
.panel-heading .panel-heading
......
...@@ -2,16 +2,10 @@ require 'spec_helper' ...@@ -2,16 +2,10 @@ require 'spec_helper'
describe FlowController do describe FlowController do
before :each do
@post = create(:post)
end
describe "GET 'show'" do describe "GET 'show'" do
login_user
it "returns http success" do it "returns http success" do
get 'show' get 'show'
puts '+++++++++++++++++++++++++++++'
p response.body
puts '+++++++++++++++++++++++++++++'
response.should be_success response.should be_success
end end
end end
......
...@@ -3,6 +3,7 @@ require 'spec_helper' ...@@ -3,6 +3,7 @@ require 'spec_helper'
describe SearchController do describe SearchController do
describe "GET 'show'" do describe "GET 'show'" do
login_user
it "returns http success" do it "returns http success" do
get 'show' get 'show'
response.should be_success response.should be_success
......
# require 'spec_helper' require 'spec_helper'
# describe StockController do describe StockController do
# describe "GET 'show'" do describe "GET 'show'" do
# it "returns http success" do login_user
# get 'show' it "returns http success" do
# response.should be_success get 'show'
# end response.should be_success
# end end
end
# end end
...@@ -94,6 +94,9 @@ RSpec.configure do |config| ...@@ -94,6 +94,9 @@ RSpec.configure do |config|
DatabaseRewinder.clean DatabaseRewinder.clean
end end
config.include Devise::TestHelpers, :type => :controller
config.extend ControllerMacros, :type => :controller
# Capybara.app_host = "http://127.0.0.1/" # Capybara.app_host = "http://127.0.0.1/"
register_poltergeist(config) register_poltergeist(config)
......
module ControllerMacros
def login_user
before(:each) do
controller.stub(:authenticate_user!).and_return true
@request.env["devise.mapping"] = Devise.mappings[:user]
sign_in FactoryGirl.create(:alice)
end
end
end
RSpec.configure do |config| # RSpec.configure do |config|
config.include Devise::TestHelpers, type: :controller # config.include Devise::TestHelpers, type: :controller
end # end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment