代码之家  ›  专栏  ›  技术社区  ›  server info

authlogic flash[:notice]不会出现在webrat步骤中

  •  0
  • server info  · 技术社区  · 14 年前

     Scenario: log in
    Given a registered user: "test@test.com" with password: "p@ssword" exists
    And I am on the homepage
    When I follow "Log in"
    And I fill in "Username" with "test@test.com"
    And I fill in "Password" with "p@ssword"
    And I open the page
    And I press "Login"
    And I open the page
    Then I should see "Login successful!"
    And I should see "Logout"
    

    这是我的场景,当我击中

    Then I should see "Login successful!"
    

     def create
    @user_session = UserSession.new(params[:user_session])
      if @user_session.save
        flash[:notice] = "Login successful!"
       redirect_to root_url
      else
        render :action => 'new'
      end
    

    结束

    是的,我看到了 http://github.com/binarylogic/authlogic/issuesearch?state=open&q=cucumber+flash#issue/142 而这也无济于事

    Rails/Cucumber/Webrat: redirect_to, flash[:notice] not working

    *** LOCAL GEMS ***
    

    actionmailer(2.3.8)

    actionpack(2.3.8)

    activerecord(2.3.8)

    主动支持(2.3.8)

    建造商(2.1.2)

    黄瓜(0.8.4,0.8.3)

    黄瓜轨(0.3.2)

    声明性授权(0.4.1)

    差异lcs(1.1.2)

    小黄瓜(2.1.2,2.0.2)

    mysql(2.8.1)

    nokogiri(1.4.2)

    泡菜(0.3.0)

    机架(1.2.1、1.1.0)

    轨道(2.3.8)

    耙(0.8.7)

    rspec(1.3.0)

    rspec轨道(1.3.2)

    术语ansicolor(1.0.5)

    思想工厂女孩(1.2.2)

    特罗洛普(1.16.2)

    网鼠(0.7.1)

    ruby 1.8.7(2010-01-10 patchlevel 249)[i486 linux] 创业板1.3.7 在Ubuntu上运行

    我该怎么做才能让我的黄瓜步通过!

    4 回复  |  直到 8 年前
        1
  •  1
  •   dfear    14 年前

    flash[:notice] = "Login successful!"   
    redirect_to root_url
    

    只是尝试渲染它而不是重定向它。

    flash[:notice] = "Login successful!"   
    render :action => :root_url
    

    在这样做时,它似乎记得flash[:notice]

    我找不到-->重定向到根url,:flash=>{:注意=>'找不到'},:notice=>登录成功!'<--根本不工作

        2
  •  0
  •   Rabbott    14 年前

    redirect_to(root_url, :notice => 'Login successful!')
    

    可能就是你要找的。

        3
  •  0
  •   ryanb    14 年前

    我相信这个问题会在Rails2.3.9中得到解决。它与在同一请求中设置cookie和会话有关。看到了吗 this ticket 详情。

    this gist 作为暂时的解决办法。

        4
  •  0
  •   server info    14 年前

    多亏雷恩给我指出了正确的方向。但是这个解决方案没有成功,但是我发现这个页面把所有的东西都放在cucumber.rb。。。它现在在跑。。。

    https://webrat.lighthouseapp.com/projects/10503-webrat/tickets/383-reset_session-and-webrat-dont-play-nicely-with-one-another

    推荐文章