Rspec Rails 3 Specification Nesting Scenarios

I use Rspec Rails with Capybara for testing, and I want to use the new specification in RSpec Rails 3, because they are read more as customer tests and acceptance tests, however, one thing that I think is missing in the older style (Describe / Not) is nesting . When I try to nest scenariosor use backgroundinside any block scenario, I get an error undefined method. Anyway, I could get an attachment with specification functions to get something like this (from Michael Hartl Ruby On Rails Tutorial :

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

Or should I think differently about integration tests?

+4
2

https://www.relishapp.com/rspec/rspec-rails/docs/feature-specs/feature-spec, feature describe, scenario it. , feature, scenario scenario, , it it.

+11

feature scenarios Capybara version 2.2.1

Gemfile

gem "capybara", "~> 2.2.1"

bundle install

Capybara

...,: type = > : feature, - , /* !* let/* let! * .

, 2.2.1

+5

Source: https://habr.com/ru/post/1532218/


All Articles