Kar*_*bol 4 integration-testing rspec ruby-on-rails capybara ruby-on-rails-4
我正在使用带有Capybara的Rspec Rails 进行测试,我想在RSpec Rails 3中使用新的功能规范read more as customer tests and acceptance tests.然而,我发现旧的(Describe/It)风格中缺少的一件事是嵌套.当尝试在任何块内嵌套scenarios或使用时,我收到错误.无论如何,我可以通过功能规范来实现嵌套来获得这样的东西(来自Michael Hartl的Ruby On Rails教程:backgroundscenarioundefined method
describe "Authentication" do
subject { page }
describe "authorization" do
let(:user) { FactoryGirl.create(:user) }
describe "for non-signed in users" do
describe "when attempting to visit a protected page" do
before { visit edit_user_path(user) }
it "should redirect_to to the signin page" do
expect(page).to have_title('Sign in')
end
describe "after signing in" do
before do
valid_signin user, no_visit: true
end
it "should render the desired protected page" do
expect(page).to have_title('Edit user')
end
Run Code Online (Sandbox Code Playgroud)
或者我应该以不同的方式思考集成测试?
Pet*_*vin 11
如https://www.relishapp.com/rspec/rspec-rails/docs/feature-specs/feature-spec中所述,feature对应describe并scenario对应it.所以,你可以嵌套实例feature,但是你不能scenario在a中嵌套scenario,就像你不能it在a中嵌套一样it.
嵌套feature有scenarios可在Capybara version 2.2.1
在Gemfile中包括
gem "capybara", "~> 2.2.1"
Run Code Online (Sandbox Code Playgroud)
和 bundle install
根据Capybara的官方文档
功能其实只是一个别名描述 ...:类型=>:功能, 背景是一个别名之前,场景的它,并给出/*给出!*let/*let的别名!*, 分别.
| 归档时间: |
|
| 查看次数: |
4416 次 |
| 最近记录: |