From 4d7b299027dc6ff86ab0c5c54918b98a858a2556 Mon Sep 17 00:00:00 2001 From: Richard Macklin Date: Tue, 24 Jan 2017 20:22:00 -0800 Subject: Add link to external documentation of rspec-rails feature specs [ci skip] --- doc/development/testing.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'doc/development/testing.md') diff --git a/doc/development/testing.md b/doc/development/testing.md index dbea6b9c9aa..60ba1af089c 100644 --- a/doc/development/testing.md +++ b/doc/development/testing.md @@ -130,7 +130,9 @@ for its feature/integration tests in September 2012. As of March 2016, we are [trying to avoid adding new Spinach tests](https://gitlab.com/gitlab-org/gitlab-ce/issues/14121) going forward, -opting for [RSpec feature](#features-integration) specs. +opting for [RSpec feature specs] as [described above](#features-integration). + +[RSpec feature specs]: https://github.com/rspec/rspec-rails#feature-specs Adding new Spinach scenarios is acceptable _only if_ the new scenario requires no more than one new `step` definition. If more than that is required, the -- cgit v1.2.1 From 8aa66fe65e381e49b1504df024f1bb361f0878f3 Mon Sep 17 00:00:00 2001 From: Richard Macklin Date: Mon, 13 Feb 2017 23:56:18 -0800 Subject: Add more links in the Features/Integration testing documentation - Move the rspec-rails feature spec link to the Features/Integration section - Mention and link to capybara and poltergeist there as well [ci skip] --- doc/development/testing.md | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'doc/development/testing.md') diff --git a/doc/development/testing.md b/doc/development/testing.md index 60ba1af089c..879ee9cc35d 100644 --- a/doc/development/testing.md +++ b/doc/development/testing.md @@ -116,6 +116,10 @@ Here are some things to keep in mind regarding test performance: ### Features / Integration +GitLab uses [rspec-rails feature specs] to test features in a browser +environment. These are [capybara] specs running on the headless [poltergeist] +driver. + - Feature specs live in `spec/features/` and should be named `ROLE_ACTION_spec.rb`, such as `user_changes_password_spec.rb`. - Use only one `feature` block per feature spec file. @@ -123,6 +127,10 @@ Here are some things to keep in mind regarding test performance: - Avoid scenario titles that add no information, such as "successfully." - Avoid scenario titles that repeat the feature title. +[rspec-rails feature specs]: https://github.com/rspec/rspec-rails#feature-specs +[capybara]: https://github.com/teamcapybara/capybara +[poltergeist]: https://github.com/teampoltergeist/poltergeist + ## Spinach (feature) tests GitLab [moved from Cucumber to Spinach](https://github.com/gitlabhq/gitlabhq/pull/1426) @@ -130,9 +138,7 @@ for its feature/integration tests in September 2012. As of March 2016, we are [trying to avoid adding new Spinach tests](https://gitlab.com/gitlab-org/gitlab-ce/issues/14121) going forward, -opting for [RSpec feature specs] as [described above](#features-integration). - -[RSpec feature specs]: https://github.com/rspec/rspec-rails#feature-specs +opting for [RSpec feature](#features-integration) specs. Adding new Spinach scenarios is acceptable _only if_ the new scenario requires no more than one new `step` definition. If more than that is required, the -- cgit v1.2.1 From ec3262549b2e0c86988b3593464c71f176a66128 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Mon, 20 Feb 2017 10:39:51 -0500 Subject: Document Timecop usage for time-sensitive tests --- doc/development/testing.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'doc/development/testing.md') diff --git a/doc/development/testing.md b/doc/development/testing.md index 761847b2bab..b3c19e396d0 100644 --- a/doc/development/testing.md +++ b/doc/development/testing.md @@ -95,6 +95,25 @@ so we need to set some guidelines for their use going forward: [lets-not]: https://robots.thoughtbot.com/lets-not +### Time-sensitive tests + +[Timecop](https://github.com/travisjeffery/timecop) is available in our +Ruby-based tests for verifying things that are time-sensitive. Any test that +exercises or verifies something time-sensitive should make use of Timecop to +prevent transient test failures. + +Example: + +```ruby +it 'is overdue' do + issue = build(:issue, due_date: Date.tomorrow) + + Timecop.freeze(3.days.from_now) do + expect(issue).to be_overdue + end +end +``` + ### Test speed GitLab has a massive test suite that, without parallelization, can take more -- cgit v1.2.1