diff --git a/.rspec b/.rspec new file mode 100644 index 00000000..c99d2e73 --- /dev/null +++ b/.rspec @@ -0,0 +1 @@ +--require spec_helper diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 00000000..6b55fc17 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,489 @@ +# _____ ____ ____ __ _ __ +# / ___/ _____ ____ _ / __// __/____ / / (_)____ / /_ +# \__ \ / ___// __ `// /_ / /_ / __ \ / / / // __ \ / __/ +# ___/ // /__ / /_/ // __// __// /_/ // /___ / // / / // /_ +# /____/ \___/ \__,_//_/ /_/ 1 \____//_____//_//_/ /_/ \__/ +# +# The linter file that doesn't lead junior developers to bad habits. +# https://github.com/makersacademy/scaffolint +# +# Problems (eg obselete names) may be due to an incompatible version. +# Check your Rubocop version with `rubocop -v` in the command line. +# +# Tested with Rubocop version 0.79.0 +# +# Introduction +# ============ +# +# Our order of priorities: +# +# 1. Conforming your code to the styleguide. +# 2. The styleguide being thorough and complete. +# +# This file relaxes Rubocop a bit so you can learn about code quality rather +# than just following the rules. Some guidelines can result in worse code if you +# don't know why they are there. For instance, if a line is too long, you might +# be tempted to simply abbreviate your variable names - making your code harder +# to read. +# +# We prioritize rules that offer good, easily incorporated feedback on improving +# your code, without being overwhelming or requiring experienced judgement. +# +# As you become a better developer you will remove or amend this file according +# to what you think good code should look like. +# +# Physical Code Size +# ================== +# +# Sometimes beginner devs interpret line or block length restrictions as a +# reason to make things so abbreviated as to be unreadable. These messages are +# designed to make you write more readable code - not less. +# +# We want to encourage testing, but it can be verbose in the early stages. +# So we'll give you a break. As you learn, try removing the next two sections. + +Layout/LineLength: + Exclude: + - 'spec/**/*' + - 'test/**/*' + Max: 100 + +Metrics/BlockLength: + Exclude: + - 'spec/**/*' + - 'test/**/*' + +# Code Style +# ========== +# +# Many devs, upon running a linter for the first time, see a big wall of errors +# of dubious necessity and put it in the 'way too much trouble' box. Beginners +# usually have far more pressing concerns than which sort of quotes they use. +# +# This makes Rubocop have a bigger 'payoff' for beginners without so much of +# the punishment. We focus our linting on things that significantly impact +# readability, expressiveness, or teach a dev new things. For example: +# +# * Indentation & whitespace (inconsistency, really gross stuff like `a=1`) +# * Easy wins in expressiveness (e.g. guard clauses — nice opportunity to +# inject concretes) +# * Egregious non-idiomatic ruby like `def getFilename` + +Layout/IndentationConsistency: + Enabled: true +Layout/IndentationWidth: + Enabled: true +Naming/AccessorMethodName: + Enabled: true +Layout/BlockEndNewline: + Enabled: true +Style/DefWithParentheses: + Enabled: true +Layout/EmptyLineBetweenDefs: + Enabled: true +Layout/EmptyLines: + Enabled: true +Layout/ExtraSpacing: + Enabled: true +Style/GuardClause: + Enabled: true +Style/IdenticalConditionalBranches: + Enabled: true +Style/InverseMethods: + Enabled: true +Layout/LeadingCommentSpace: + Enabled: true +Style/NegatedIf: + Enabled: true +Style/NegatedWhile: + Enabled: true +Style/NilComparison: + Enabled: true +Style/Not: + Enabled: true +Style/NumericLiterals: + Enabled: true +Style/NumericPredicate: + Enabled: true +Style/OneLineConditional: + Enabled: true +Style/RedundantParentheses: + Enabled: true +Style/RedundantSelf: + Enabled: true +Style/SafeNavigation: + Enabled: true +Style/SelfAssignment: + Enabled: true +Layout/SpaceAfterColon: + Enabled: true +Layout/SpaceAfterComma: + Enabled: true +Layout/SpaceAfterMethodName: + Enabled: true +Layout/SpaceAfterNot: + Enabled: true +Layout/SpaceAfterSemicolon: + Enabled: true +Layout/SpaceAroundBlockParameters: + Enabled: true +Layout/SpaceAroundEqualsInParameterDefault: + Enabled: true +Layout/SpaceAroundKeyword: + Enabled: true +Layout/SpaceAroundOperators: + Enabled: true +Layout/SpaceBeforeBlockBraces: + Enabled: true +Layout/SpaceBeforeComma: + Enabled: true +Layout/SpaceBeforeComment: + Enabled: true +Layout/SpaceBeforeFirstArg: + Enabled: true +Layout/SpaceBeforeSemicolon: + Enabled: true +Layout/SpaceInLambdaLiteral: + Enabled: true +Layout/SpaceInsideArrayPercentLiteral: + Enabled: true +Layout/SpaceInsideBlockBraces: + Enabled: true +Layout/SpaceInsideReferenceBrackets: + Enabled: true +Layout/SpaceInsideArrayLiteralBrackets: + Enabled: true +Layout/SpaceInsideHashLiteralBraces: + Enabled: true +Layout/SpaceInsideParens: + Enabled: true +Layout/SpaceInsidePercentLiteralDelimiters: + Enabled: true +Layout/SpaceInsideRangeLiteral: + Enabled: true +Layout/SpaceInsideStringInterpolation: + Enabled: true +Style/SymbolLiteral: + Enabled: true +Layout/TrailingEmptyLines: + Enabled: true +Style/TrivialAccessors: + Enabled: true + +# Rubocop doesn't make disabling all cops in a given group easy, so we list... +Layout/AccessModifierIndentation: + Enabled: false +Style/Alias: + Enabled: false +Layout/ArrayAlignment: + Enabled: false +Layout/HashAlignment: + Enabled: false +Layout/ParameterAlignment: + Enabled: false +Style/AndOr: + Enabled: false +Style/ArrayJoin: + Enabled: false +Style/AsciiComments: + Enabled: false +Naming/AsciiIdentifiers: + Enabled: false +Style/Attr: + Enabled: false +Style/AutoResourceCleanup: + Enabled: false +Style/BarePercentLiterals: + Enabled: false +Style/BeginBlock: + Enabled: false +Style/BlockComments: + Enabled: false +Style/BlockDelimiters: + Enabled: false +Style/BracesAroundHashParameters: + Enabled: false +Style/CaseEquality: + Enabled: false +Layout/CaseIndentation: + Enabled: false +Style/CharacterLiteral: + Enabled: false +Style/ClassAndModuleChildren: + Enabled: false +Style/ClassCheck: + Enabled: false +Style/ClassMethods: + Enabled: false +Style/ClassVars: + Enabled: false +Layout/ClosingParenthesisIndentation: + Enabled: false +Style/CollectionMethods: + Enabled: false +Style/ColonMethodCall: + Enabled: false +Style/CommandLiteral: + Enabled: false +Style/CommentAnnotation: + Enabled: false +Layout/CommentIndentation: + Enabled: false +Style/ConditionalAssignment: + Enabled: false +Style/Copyright: + Enabled: false +Style/Documentation: + Enabled: false +Style/DocumentationMethod: + Enabled: false +Layout/DotPosition: + Enabled: false +Style/DoubleNegation: + Enabled: false +Style/EachForSimpleLoop: + Enabled: false +Style/EachWithObject: + Enabled: false +Layout/ElseAlignment: + Enabled: false +Style/EmptyCaseCondition: + Enabled: false +Style/EmptyElse: + Enabled: false +Layout/EmptyLineAfterMagicComment: + Enabled: false +Layout/EmptyLinesAroundAccessModifier: + Enabled: false +Layout/EmptyLinesAroundBeginBody: + Enabled: false +Layout/EmptyLinesAroundBlockBody: + Enabled: false +Layout/EmptyLinesAroundClassBody: + Enabled: false +Layout/EmptyLinesAroundExceptionHandlingKeywords: + Enabled: false +Layout/EmptyLinesAroundMethodBody: + Enabled: false +Layout/EmptyLinesAroundModuleBody: + Enabled: false +Style/EmptyLiteral: + Enabled: false +Style/EmptyMethod: + Enabled: false +Style/Encoding: + Enabled: false +Style/EndBlock: + Enabled: false +Layout/EndOfLine: + Enabled: false +Style/EvenOdd: + Enabled: false +Layout/FirstArrayElementLineBreak: + Enabled: false +Layout/FirstHashElementLineBreak: + Enabled: false +Layout/FirstMethodArgumentLineBreak: + Enabled: false +Layout/FirstMethodParameterLineBreak: + Enabled: false +Layout/FirstArgumentIndentation: + Enabled: false +Lint/FlipFlop: + Enabled: false +Style/For: + Enabled: false +Style/FormatString: + Enabled: false +Style/FrozenStringLiteralComment: + Enabled: false +Style/GlobalVars: + Enabled: false +Style/HashSyntax: + Enabled: false +Style/IfInsideElse: + Enabled: false +Style/IfUnlessModifier: + Enabled: false +Style/IfUnlessModifierOfIfUnless: + Enabled: false +Style/IfWithSemicolon: + Enabled: false +Style/ImplicitRuntimeError: + Enabled: false +Layout/FirstArrayElementIndentation: + Enabled: false +Layout/AssignmentIndentation: + Enabled: false +Layout/FirstHashElementIndentation: + Enabled: false +Layout/HeredocIndentation: + Enabled: false +Style/InfiniteLoop: + Enabled: false +Layout/InitialIndentation: + Enabled: false +Style/InlineComment: + Enabled: false +Style/Lambda: + Enabled: false +Style/LambdaCall: + Enabled: false +Style/LineEndConcatenation: + Enabled: false +Style/MethodCallWithArgsParentheses: + Enabled: false +Style/MethodCallWithoutArgsParentheses: + Enabled: false +Style/MethodCalledOnDoEndBlock: + Enabled: false +Style/MethodDefParentheses: + Enabled: false +Style/MethodMissingSuper: + Enabled: false +Style/MissingRespondToMissing: + Enabled: false +Style/MissingElse: + Enabled: false +Style/MixinGrouping: + Enabled: false +Style/ModuleFunction: + Enabled: false +Layout/MultilineArrayBraceLayout: + Enabled: false +Layout/MultilineAssignmentLayout: + Enabled: false +Style/MultilineBlockChain: + Enabled: false +Layout/MultilineBlockLayout: + Enabled: false +Layout/MultilineHashBraceLayout: + Enabled: false +Style/MultilineIfModifier: + Enabled: false +Style/MultilineIfThen: + Enabled: false +Style/MultilineMemoization: + Enabled: false +Layout/MultilineMethodCallBraceLayout: + Enabled: false +Layout/MultilineMethodCallIndentation: + Enabled: false +Layout/MultilineMethodDefinitionBraceLayout: + Enabled: false +Layout/MultilineOperationIndentation: + Enabled: false +Style/MultilineTernaryOperator: + Enabled: false +Style/MutableConstant: + Enabled: false +Style/NestedModifier: + Enabled: false +Style/NestedParenthesizedCalls: + Enabled: false +Style/NestedTernaryOperator: + Enabled: false +Style/Next: + Enabled: false +Style/NonNilCheck: + Enabled: false +Style/NumericLiteralPrefix: + Enabled: false +Naming/BinaryOperatorParameterName: + Enabled: false +Style/OptionHash: + Enabled: false +Style/OptionalArguments: + Enabled: false +Style/ParallelAssignment: + Enabled: false +Style/ParenthesesAroundCondition: + Enabled: false +Style/PercentLiteralDelimiters: + Enabled: false +Style/PercentQLiterals: + Enabled: false +Style/PerlBackrefs: + Enabled: false +Style/PreferredHashMethods: + Enabled: false +Style/Proc: + Enabled: false +Style/RaiseArgs: + Enabled: false +Style/RedundantBegin: + Enabled: false +Style/RedundantException: + Enabled: false +Style/RedundantFreeze: + Enabled: false +Style/RedundantReturn: + Enabled: false +Style/RegexpLiteral: + Enabled: false +Layout/RescueEnsureAlignment: + Enabled: false +Style/RescueModifier: + Enabled: false +Style/Semicolon: + Enabled: false +Style/Send: + Enabled: false +Style/SignalException: + Enabled: false +Style/SingleLineBlockParams: + Enabled: false +Style/SingleLineMethods: + Enabled: false +Style/SpecialGlobalVars: + Enabled: false +Style/StabbyLambdaParentheses: + Enabled: false +Style/StringLiterals: + Enabled: false +Style/StringLiteralsInInterpolation: + Enabled: false +Style/StringMethods: + Enabled: false +Style/StructInheritance: + Enabled: false +Style/SymbolArray: + Enabled: false +Style/SymbolProc: + Enabled: false +Layout/Tab: + Enabled: false +Style/TernaryParentheses: + Enabled: false +Style/TrailingCommaInArguments: + Enabled: false +Style/TrailingCommaInArrayLiteral: + Enabled: false +Style/TrailingCommaInHashLiteral: + Enabled: false +Style/TrailingUnderscoreVariable: + Enabled: false +Layout/TrailingWhitespace: + Enabled: false +Style/UnlessElse: + Enabled: false +Style/RedundantCapitalW: + Enabled: false +Style/RedundantInterpolation: + Enabled: false +Style/RedundantPercentQ: + Enabled: false +Style/VariableInterpolation: + Enabled: false +Naming/VariableNumber: + Enabled: false +Style/WhenThen: + Enabled: false +Style/WhileUntilDo: + Enabled: false +Style/WhileUntilModifier: + Enabled: false +Style/WordArray: + Enabled: false +Style/ZeroLengthPredicate: + Enabled: false diff --git a/Gemfile b/Gemfile new file mode 100644 index 00000000..efd6e401 --- /dev/null +++ b/Gemfile @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +source "https://rubygems.org" + +git_source(:github) {|repo_name| "https://github.com/#{repo_name}" } + +gem 'sinatra' +group :test do + gem 'rspec' + gem 'capybara' + gem 'rubocop', '0.71.0' + gem 'simplecov', require: false + gem 'simplecov-console', require: false +end diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 00000000..1cb5f7f7 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,90 @@ +GEM + remote: https://rubygems.org/ + specs: + addressable (2.7.0) + public_suffix (>= 2.0.2, < 5.0) + ansi (1.5.0) + ast (2.4.0) + capybara (3.31.0) + addressable + mini_mime (>= 0.1.3) + nokogiri (~> 1.8) + rack (>= 1.6.0) + rack-test (>= 0.6.3) + regexp_parser (~> 1.5) + xpath (~> 3.2) + diff-lcs (1.3) + docile (1.3.2) + jaro_winkler (1.5.4) + mini_mime (1.0.2) + mini_portile2 (2.4.0) + mustermann (1.1.1) + ruby2_keywords (~> 0.0.1) + nokogiri (1.10.9) + mini_portile2 (~> 2.4.0) + parallel (1.19.1) + parser (2.7.0.4) + ast (~> 2.4.0) + public_suffix (4.0.3) + rack (2.2.2) + rack-protection (2.0.8.1) + rack + rack-test (1.1.0) + rack (>= 1.0, < 3) + rainbow (3.0.0) + regexp_parser (1.7.0) + rspec (3.9.0) + rspec-core (~> 3.9.0) + rspec-expectations (~> 3.9.0) + rspec-mocks (~> 3.9.0) + rspec-core (3.9.1) + rspec-support (~> 3.9.1) + rspec-expectations (3.9.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.9.0) + rspec-mocks (3.9.1) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.9.0) + rspec-support (3.9.2) + rubocop (0.71.0) + jaro_winkler (~> 1.5.1) + parallel (~> 1.10) + parser (>= 2.6) + rainbow (>= 2.2.2, < 4.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 1.4.0, < 1.7) + ruby-progressbar (1.10.1) + ruby2_keywords (0.0.2) + simplecov (0.18.5) + docile (~> 1.1) + simplecov-html (~> 0.11) + simplecov-console (0.7.2) + ansi + simplecov + terminal-table + simplecov-html (0.12.2) + sinatra (2.0.8.1) + mustermann (~> 1.0) + rack (~> 2.0) + rack-protection (= 2.0.8.1) + tilt (~> 2.0) + terminal-table (1.8.0) + unicode-display_width (~> 1.1, >= 1.1.1) + tilt (2.0.10) + unicode-display_width (1.6.1) + xpath (3.2.0) + nokogiri (~> 1.8) + +PLATFORMS + ruby + +DEPENDENCIES + capybara + rspec + rubocop (= 0.71.0) + simplecov + simplecov-console + sinatra + +BUNDLED WITH + 2.1.4 diff --git a/README.md b/README.md new file mode 100644 index 00000000..f9638b66 --- /dev/null +++ b/README.md @@ -0,0 +1,66 @@ +## Chitter Challenge + +* Challenge time: until the end of the day +* Feel free to use google, your notes, books etc but please work on your own +* Please raise a pull request when you start this challenge, and keep pushing updates as and when you make commits throughout the day +* There is _no expectation_ to finish all or any of the user stories, please use this time to reflect on where you feel you are with the skill and what may support your learning. +* If you get blocked, please reflect on what blocked you and any strategies you adopted that helped you make progress. + +We are going to write a small Twitter clone that will allow the users to post messages to a public stream. + +## Set up + +To setup the database: + +* Connect to psql +* Create the database using the psql command `CREATE DATABASE chitter;` +* Connect to the database using the psql command `\c chitter`; +* Run the query we have saved in the file 01_create_chitter_table.sql +* Populate your table with a row by running `INSERT INTO peeps (message) values ('This is a peep!');` + +To check you have everything set up ok, please take a look at the peeps table inside the chitter database. You should see one row in there. + +To setup the test database: +* Connect to psql +* Create the database using the psql +command `CREATE DATABASE chitter_test;`; +* Connect to the database using the psql command `\c chitter_test` +* Run the query we have saved in the file 01_create_chitter_table.sql + +* `bundle install` +* `rspec` + +You should see 1 passing test. + +## User stories + +``` +As a Maker +So that I can see what people are doing +I want to see all the messages (peeps) +in a browser +``` + +``` +As a Maker +So that I can let people know what I am doing +I want to post a message (peep) to chitter +``` + +``` +As a Maker +So that I can see when people are doing things +I want to see the date the message was posted +``` +(Hint the database table will need to change to store the date too) + +``` +As a Maker +So that I can easily see the latest peeps +I want to see a list of peeps in reverse chronological order +``` +``` +As a Maker +So that I can find relevant peeps +I want to filter on a specific keyword +``` diff --git a/app.rb b/app.rb new file mode 100644 index 00000000..2450fb92 --- /dev/null +++ b/app.rb @@ -0,0 +1,9 @@ +require 'sinatra/base' + +class Chitter < Sinatra::Base + get '/test' do + 'Test page' + end + + run! if app_file == $0 +end diff --git a/config.ru b/config.ru new file mode 100644 index 00000000..5b0eadb7 --- /dev/null +++ b/config.ru @@ -0,0 +1,3 @@ +require_relative "./app" + +run Chitter diff --git a/coverage/.last_run.json b/coverage/.last_run.json new file mode 100644 index 00000000..3cb5e70c --- /dev/null +++ b/coverage/.last_run.json @@ -0,0 +1,5 @@ +{ + "result": { + "covered_percent": 100.0 + } +} diff --git a/coverage/.resultset.json b/coverage/.resultset.json new file mode 100644 index 00000000..f029f271 --- /dev/null +++ b/coverage/.resultset.json @@ -0,0 +1,17 @@ +{ + "RSpec": { + "coverage": { + "/Users/lindseydew/chitter-challenge-apprenticeships/spec/features/test_page_spec.rb": { + "lines": [ + 1, + 1, + 1, + 1, + null, + null + ] + } + }, + "timestamp": 1584032705 + } +} diff --git a/coverage/.resultset.json.lock b/coverage/.resultset.json.lock new file mode 100644 index 00000000..e69de29b diff --git a/db/migrations/01_create_chitter_table.sql b/db/migrations/01_create_chitter_table.sql new file mode 100644 index 00000000..6e077248 --- /dev/null +++ b/db/migrations/01_create_chitter_table.sql @@ -0,0 +1 @@ +CREATE TABLE peeps(id SERIAL PRIMARY KEY, message VARCHAR(60)); diff --git a/spec/features/test_page_spec.rb b/spec/features/test_page_spec.rb new file mode 100644 index 00000000..b65ac196 --- /dev/null +++ b/spec/features/test_page_spec.rb @@ -0,0 +1,6 @@ +feature 'Viewing test page' do + scenario 'visiting the test page' do + visit('/test') + expect(page).to have_content "Test page" + end +end diff --git a/spec/setup_test_database.rb b/spec/setup_test_database.rb new file mode 100644 index 00000000..af832f7d --- /dev/null +++ b/spec/setup_test_database.rb @@ -0,0 +1,11 @@ +require 'pg' + +def setup_test_database + connection = PG.connect(dbname: 'chitter_test') + connection.exec("TRUNCATE peeps;") +end + +def add_row_to_test_database + connection = PG.connect(dbname: 'chitter_test') + connection.exec("INSERT INTO peeps (message) values ('This is a peep!');") +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 00000000..058db3c5 --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,128 @@ +# This file was generated by the `rspec --init` command. Conventionally, all +# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. +# The generated `.rspec` file contains `--require spec_helper` which will cause +# this file to always be loaded, without a need to explicitly require it in any +# files. +# +# Given that it is always loaded, you are encouraged to keep this file as +# light-weight as possible. Requiring heavyweight dependencies from this file +# will add to the boot time of your test suite on EVERY test run, even for an +# individual file that may not need all of that loaded. Instead, consider making +# a separate helper file that requires the additional dependencies and performs +# the additional setup, and require it from the spec files that actually need +# it. +# +# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration +ENV['RACK_ENV'] = 'test' +ENV['ENVIRONMENT'] = 'test' +# Bring in the contents of the `app.rb` file. The below is equivalent to: require_relative '../app.rb' +require File.join(File.dirname(__FILE__), '..', 'app.rb') +require_relative './setup_test_database' +# Require all the testing gems +require 'capybara' +require 'capybara/rspec' +require 'rspec' + +require 'simplecov' +require 'simplecov-console' + +SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([ + SimpleCov::Formatter::Console, + # Want a nice code coverage website? Uncomment this next line! + # SimpleCov::Formatter::HTMLFormatter +]) +SimpleCov.start + +# Tell Capybara to talk to BookmarkManager +Capybara.app = Chitter + +RSpec.configure do |config| + config.before(:each) do + setup_test_database + end +end +RSpec.configure do |config| + # rspec-expectations config goes here. You can use an alternate + # assertion/expectation library such as wrong or the stdlib/minitest + # assertions if you prefer. + config.expect_with :rspec do |expectations| + # This option will default to `true` in RSpec 4. It makes the `description` + # and `failure_message` of custom matchers include text for helper methods + # defined using `chain`, e.g.: + # be_bigger_than(2).and_smaller_than(4).description + # # => "be bigger than 2 and smaller than 4" + # ...rather than: + # # => "be bigger than 2" + expectations.include_chain_clauses_in_custom_matcher_descriptions = true + end + + # rspec-mocks config goes here. You can use an alternate test double + # library (such as bogus or mocha) by changing the `mock_with` option here. + config.mock_with :rspec do |mocks| + # Prevents you from mocking or stubbing a method that does not exist on + # a real object. This is generally recommended, and will default to + # `true` in RSpec 4. + mocks.verify_partial_doubles = true + end + + # This option will default to `:apply_to_host_groups` in RSpec 4 (and will + # have no way to turn it off -- the option exists only for backwards + # compatibility in RSpec 3). It causes shared context metadata to be + # inherited by the metadata hash of host groups and examples, rather than + # triggering implicit auto-inclusion in groups with matching metadata. + config.shared_context_metadata_behavior = :apply_to_host_groups + +# The settings below are suggested to provide a good initial experience +# with RSpec, but feel free to customize to your heart's content. +=begin + # This allows you to limit a spec run to individual examples or groups + # you care about by tagging them with `:focus` metadata. When nothing + # is tagged with `:focus`, all examples get run. RSpec also provides + # aliases for `it`, `describe`, and `context` that include `:focus` + # metadata: `fit`, `fdescribe` and `fcontext`, respectively. + config.filter_run_when_matching :focus + + # Allows RSpec to persist some state between runs in order to support + # the `--only-failures` and `--next-failure` CLI options. We recommend + # you configure your source control system to ignore this file. + config.example_status_persistence_file_path = "spec/examples.txt" + + # Limits the available syntax to the non-monkey patched syntax that is + # recommended. For more details, see: + # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/ + # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ + # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode + config.disable_monkey_patching! + + # This setting enables warnings. It's recommended, but in some cases may + # be too noisy due to issues in dependencies. + config.warnings = true + + # Many RSpec users commonly either run the entire suite or an individual + # file, and it's useful to allow more verbose output when running an + # individual spec file. + if config.files_to_run.one? + # Use the documentation formatter for detailed output, + # unless a formatter has already been configured + # (e.g. via a command-line flag). + config.default_formatter = "doc" + end + + # Print the 10 slowest examples and example groups at the + # end of the spec run, to help surface which specs are running + # particularly slow. + config.profile_examples = 10 + + # Run specs in random order to surface order dependencies. If you find an + # order dependency and want to debug it, you can fix the order by providing + # the seed, which is printed after each run. + # --seed 1234 + config.order = :random + + # Seed global randomization in this process using the `--seed` CLI option. + # Setting this allows you to use `--seed` to deterministically reproduce + # test failures related to randomization by passing the same `--seed` value + # as the one that triggered the failure. + Kernel.srand config.seed +=end +end