2016-08-05 2 views
1

각도기의 시나리오를 카피 바라에서 가능한 것처럼 그룹화하는 방법이 있는지 궁금합니다.각도기의 시나리오를 컨텍스트로 그룹화하는 방법이 있습니까?

예를 들어 사생활 보호 설정 테스트를 작성한 경우 로그인하지 않은 사용자의 컨텍스트와 사용자 간의 관계에 따라 다른 시나리오로 구분되는 로그인 한 사용자의 컨텍스트를 가질 수 있습니다. 또 다른 예 :

feature 'allows user to share' do 
    let!(:post) { create :post } 

    before do 
    create :feed_post, user: user, post: post 
    app.sign_in user 
    end 

    context 'with comment' do 
    subject { feed.share_modal } 

    before { feed.posts.first.share_post } 

    scenario { is_expected.to have_content t('social_sharing.new.title') } 
    scenario { is_expected.to have_button t('social_sharing.new.action') } 

    context 'sharing with a comment' do 
     before do 
     feed.share_modal.comment_on_share 'a nice comment' 
     feed.share_modal.submit_share_form 
     feed.wait_until_share_modal_invisible 
     end 

     scenario 'closes the modal' do 
     expect(feed).to have_no_share_modal 
     end 

     scenario 'shows shared message' do 
     expect(feed.posts.first) 
     .to have_content "#{user.name} shared #{post.user.name.possessive} post" 
     expect(feed.posts.first).to have_content 'a nice comment' 
     end 
    end 
    end 
end 

상황에 내가 컨텍스트 내 시나리오 반복하는 단계가 포함되어 내부 블록 전에를 추가 할 수 있기 때문에 나를, 사양은 DRY 만들 수 있습니다. 각도기로도 가능합니까?

+0

[specs vs suites] (http://stackoverflow.com/questions/30331018/suites-vs-specs-protractor)를 요청할 수 있습니까? – alecxe

답변

1
질문에

짧은 답변 - 당신은 레일 배경에서 온 나를 각도기에 대한 몇 가지 간단한 통찰력을 제공 할 수 있기 때문에 아니, 같은 카피 바라의 상황으로 각도기의 직접적인 기능이 없습니다 :

  • 각도기가입니다 node.js 프로그램은 webdriver.js 위에 구축되어 있으므로 모든 메소드가 비동기이며 약속을 반환합니다.
  • 각도기의 기본 테스트 프레임 워크는 현재 Jasmine2.0입니다. 당신은 당신이 hooks를 사용하여 사양을 건조 할 수 각도기와 테스트 프레임 워크로 자스민를 계속하려면

    • :

  • 은 이제 사양을 건조하는 두 가지 좋은 옵션이 있습니다. Jeff가 이에 대한 좋은 글을 올렸습니다. http://www.assertselenium.com/angularjs/protractor-jasmine-pre-post-processing-methods/
  • 카피 바라 경험을 각도기에서 사용하려면 테스트 프레임 워크로 CucumberJS으로 전환해야합니다. 나는 이것에 대한 글을 게시했습니다 - http://www.assertselenium.com/bdd/e2e-testing-with-protractor-cucumber-js/ :) 카피 바라에 contexts과 똑같이 작동하는 오이에 background을 사용할 수 있습니다!
관련 문제