From 52b4785161a505915f06d41eec6ec90b5beac75a Mon Sep 17 00:00:00 2001 From: Washington Botelho Date: Tue, 17 May 2022 23:33:23 -0300 Subject: [PATCH] doc --- .rspec | 1 + README.md | 10 ++++++++++ spec/support/mysql.rb | 10 ++++++++++ 3 files changed, 21 insertions(+) create mode 100644 .rspec create mode 100644 spec/support/mysql.rb diff --git a/.rspec b/.rspec new file mode 100644 index 0000000..4cc180c --- /dev/null +++ b/.rspec @@ -0,0 +1 @@ +--require common_helper diff --git a/README.md b/README.md index fc51122..b789383 100644 --- a/README.md +++ b/README.md @@ -423,6 +423,16 @@ author.rate resource, 5, extra_scope: { approved: true } As you can see, now, only the rate with value `5` will be included on the final rating. +### Specs + +To run all specs, run the following rakes: + +```sh +bundle exec rake spec +bundle exec rake spec_config +bundle exec rake spec_config_with_extra_scopes +``` + ### References - [Evan Miller](http://www.evanmiller.org/ranking-items-with-star-ratings.html) diff --git a/spec/support/mysql.rb b/spec/support/mysql.rb new file mode 100644 index 0000000..7efd9e1 --- /dev/null +++ b/spec/support/mysql.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +require 'mysql2' + +client = Mysql2::Client.new(host: '127.0.0.1', username: :root) + +client.query('DROP DATABASE IF EXISTS rating_test;') +client.query('CREATE DATABASE IF NOT EXISTS rating_test;') + +ActiveRecord::Base.establish_connection(adapter: :mysql2, database: :rating_test, username: :root, host: '127.0.0.1')