English 中文(简体)
Rspec和Capybara物体配对
原标题:Rspec and Capybara object matching

利用铁路3.0.5、RSpec 2和Capybara 0.4.1.2,我正试图为我的会议撰写一个控制器片“冰箱”新行动。

it "assigns the empty session to a variable" do
  get :new
  assigns(:session).should == ActiveRecord::Base::Session.new
end

使用“积极记录”一米:在我不时,“基本名称空间”似乎与Capybara阶级发生冲突。

这里是会议主计长:

class SessionsController < ApplicationController
  def new
     @session = Session.new
  end
end

RSpec似乎没有理解这些物体。 我的检验结果如下:

 Failure/Error: assigns(:session).should == ActiveRecord::Base::Session.new
   expected: #<Session id: nil, session_id: nil, data: nil, created_at: nil, updated_at: nil>
        got: #<Session id: nil, session_id: nil, data: nil, created_at: nil, updated_at: nil> (using ==)
   Diff:
 # ./spec/controllers/sessions_controller_spec.rb:17:in `block (3 levels) in <top (required)> 

任何方面?

最佳回答

问题是,如果是,

ActiveRecord::Base::Session.new == ActiveRecord::Base::Session.new

你会冒犯,因为这两个物体都有单独的<条码>。

为此:

assigns(:session).should be_an(ActiveRecord::Base::Session)
问题回答

暂无回答




相关问题
why the session in iis automatically log out?

I used iis6, and when i called a function Directory.delete(), the all the session relate this website will be logged out. and i debugged the website, i found no exception. any one have ideas on this ? ...

Check session from a view in CodeIgniter

What is the best way to check session from a view in CodeIgniter, it shows no way in their user guide, otherwise I will have to make two views on everything, which is kinda weird...still a newbie to ...

Can I get the size of a Session object in bytes in c#?

Is it possible to get the size(in bytes) of a Session object after storing something such as a datatable inside it? I want to get the size of a particular Session object, such as Session["table1"], ...

提供严格分类的出席会议物体

提供严格分类的与会机会的最佳方式是什么? 我正计划转而选择矩阵,这正在促使汇编者抱怨我的幻觉方案拟订方法......

PHP Session is not destroying after user logout

I m trying to create an authentication mechanism for my PHP Application and I m having difficulty destroying the session. I ve tried unsetting the authentication token which was previously set within ...

热门标签