English 中文(简体)
如果职能有的话,对nes进行检测
原标题:rspec testing a nested if function

IM非常新颖,可以进行子宫测试,需要一线帮助。

在我的时间表上测试一名控制员,并试图测试这一法典。

if params[:user_id] == nil
      if current_user == nil
        redirect_to new_user_session_path
      else
        @user_id = current_user.id
      end
    else
      @user_id = params[:user_id]
    end

im not sure if its even worth testing but it seems theres a lack of tutorials for the beginner out there, so i wouldnt know. thanks in advance

最佳回答

你们可以通过描述声明和(或)确定每一种假设情景和检验方式来做。

describe "test the controller" do

    before(:each) do
        @user = Factory(:user)
    end

    describe "for non signed in users" do

        it "should redirect to sign in page" do
            get :action
            response.should redirect_to(new_user_session_path)
        end

    end

    describe "for signed in users" do

        before(:each) do
            sign_in(@user)
        end

        it "should be successful" do
            get :action
            response.should be_success
        end

    end

end

仅用不同术语描述发言和每次测试,然后(即:每个)进行。

问题回答

暂无回答




相关问题
Selenium not working with Firefox 3.x on linux

I am using selenium-server , selenium rc for UI testing in my application . My dev box is Windows with FireFox 3.5 and every thing is running fine and cool. But when i try to run selenium tests on my ...

Best browser for testing under Safari Mobile on Linux?

I have an iPhone web app I m producing on a Linux machine. What s the best browser I can use to most closely mimic the feature-limited version of Safari present on the iPhone? (It s a "slimmed down" ...

Code Coverage Tools & Visual Studio 2008 Pro

Just wondering what people are using for code coverage tools when using MS Visual Studio 2008 Pro. We are using the built-in MS test project and unit testing tool (the one that come pre-installed ...

Is there any error checking web app cralwers out there?

Wondering if there was some sort of crawler we could use to test and re-test everything when changes are made to the web app so we know some new change didn t error out any existing pages. Or maybe a ...

热门标签