Coggle requires JavaScript to display documents.
group :development, :test do gem 'rspec-rails', '~> 3.7' end
rails generate rspec:install
bundle exec rspec
bundle exec rspec spec/models/book_spec.rb
it 'has 200 status code if logged in' do expect(response).to respond_with 200 end it 'has 401 status code if not logged in' do expect(response).to respond_with 401 end
context 'when logged in' do it { expect(response).to respond_with 200 } end context 'when logged out' do it { expect(response).to respond_with 401 } end
expect(5).to be >= 3 expect { a += 1 }.to change { a }.by(1) // a thay đổi 1 đơn vị expect { a += 3 }.to change { a }.from(2).to(5) // Ban đầu a = 2
rspec-expectations