{"id":22282596,"url":"https://github.com/carbonfive/specs-rails","last_synced_at":"2026-03-19T22:18:29.941Z","repository":{"id":9593942,"uuid":"11513382","full_name":"carbonfive/specs-rails","owner":"carbonfive","description":"Strategies for writing specs for ruby on rails apps","archived":false,"fork":false,"pushed_at":"2013-10-28T21:42:26.000Z","size":116,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":74,"default_branch":"master","last_synced_at":"2025-01-30T17:36:56.552Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/carbonfive.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-07-18T20:46:18.000Z","updated_at":"2022-04-05T13:23:00.000Z","dependencies_parsed_at":"2022-09-07T07:51:25.899Z","dependency_job_id":null,"html_url":"https://github.com/carbonfive/specs-rails","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carbonfive%2Fspecs-rails","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carbonfive%2Fspecs-rails/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carbonfive%2Fspecs-rails/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carbonfive%2Fspecs-rails/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/carbonfive","download_url":"https://codeload.github.com/carbonfive/specs-rails/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245534528,"owners_count":20631285,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-03T16:33:49.945Z","updated_at":"2026-01-05T23:02:59.829Z","avatar_url":"https://github.com/carbonfive.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Strategies for writing specs\n## For a Rails App\n---\nThis document outlines different spec'ing strategies that can be considered for different situations.\n\nFirst, lets point out the common techniques (best practices) for writing specs.\n\nCombining these techniques in various ways, and in varying degrees, will yield different strategies.\n---\n\n## Spec Techniques\n\n### Feature Specs\n\t* Definition:\n\t  specs that define what user experience is provided by a feature\n\t* Tech:\n\t  Capybara\n\t* Technique:\n\t* Pressure Points to Focus on:\n\t* Current Conventions:\n\t* example:\n\t  todo (Use request specs with capybara?)\n[how to write a user experience spec]()\n\n### Request Specs /app/controllers\n\t* Definition:\n\t  specs for an ApplicationController\n\t* Technique:\n\t* Pressure Points to Focus on:\n\t* Current Conventions:\n\t* example: (requires test_response_data.rb spec helper)\n      require 'spec_helper'\n\n      describe \"Natural Search\" do\n        context \"given different levels of profile completeness\" do\n          let!(:empty_thing)    {create :thing}\n          let!(:partial_thing)  {create :partial_thing}\n          let!(:complete_thing) {create :complete_thing}\n          let (:expected_order) {[ complete_thing, partial_thing, empty_thing] }\n\n          it 'returns the most complete things first' do\n            get search_path\n            thing_ids = response.data_for('thing-id')\n            expect(thing_ids.length).to eq 3\n            expect(thing_ids).to eq expected_order.map {|u| u.id.to_s}\n          end\n        end\n      end\n[how to write a request specs for a web app]()\n[how to write a request specs for an api]()\n\n### View Specs /app/views\n\t* Definition:\n\t  Design how data is rendered to a User\n\t* Technique:\n\t* Pressure Points to Focus on:\n\t* Current Conventions:\n\t* example:\n\t  todo\n[how to write a view spec]()\n\n### Controller Specs /app/controllers\n\t* Intention:\n\t  Design each of the incomming requests to your your app\n\t* Technique:\n\t  Isolate the controller\n\t  Provide doubles for models and services.\n\t  No view is rendered either.\n\t* Pressure Points to Focus on:\n\t* Current Conventions:\n\t* example:\n\t  todo\n[how to write a controller spec]()\n\n### Model Specs: /app/models\n\t* Definition:\n\t  Design the public interfaces of your Domain Model classes (or single purpose classes)\n\t* Watch:\n\t  [how to write a model spec](http://www.confreaks.com/videos/2452-railsconf2013-the-magic-tricks-of-testing)\n\t* Technique: \n\t  Isolate the model from other objects\n\t  For ActiveRecord models: use build instead of create to setup your tests where possible\n\t* Pressure Points to Focus on:\n\t  write expectations for messages sent to a public class methods\n\t  write expectations for messages sent to public instance methods\n\t  write expectations for outgoing commands\n\t  No need to write expectations for private methods\n\t* Current Conventions:\n\t  describe '#instance_method' do\n\t  describe '.class_method' do\n\n### Ambiguous Terms\nThe following terms mean different things to different people and won't be used in this document:\n\n    Unit Test\n    Functional Test\n    Integration Test\n    Acceptance Test\n\n## The Strategies\nWe can combine the of the above Spec Techniques\n\n### Developing an API\n\n### Developing a Lean MVAP\n\n### Developing a Personal WebApp\n\n### Developing an Enterprise App\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcarbonfive%2Fspecs-rails","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcarbonfive%2Fspecs-rails","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcarbonfive%2Fspecs-rails/lists"}