Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 29 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
environment:
RAILS_ENV: test
TEST_DATABASE_URL: postgresql://postgres@localhost/mew_etymon_test

# Specify service dependencies here if necessary
# CircleCI maintains a library of pre-built images
# documented at https://circleci.com/docs/2.0/circleci-images/
Expand All @@ -38,7 +38,7 @@ jobs:
paths:
- ./vendor/bundle
key: v1-dependencies-{{ checksum "Gemfile.lock" }}

# Database setup
- run:
name: Database Setup
Expand All @@ -47,18 +47,44 @@ jobs:
bundle exec rake db:create
bundle exec rake db:schema:load

# Test coverage reporter
# Pasted from https://docs.codeclimate.com/docs/circle-ci-test-coverage-example
- run:
name: Download cc-test-reporter
command: |
mkdir -p tmp/
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./tmp/cc-test-reporter
chmod +x ./tmp/cc-test-reporter

- persist_to_workspace:
root: tmp
paths:
- cc-test-reporter

# run tests!
- run:
name: Run specs
command: |
mkdir /tmp/test-results
TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)"

bundle exec rspec --format progress \
--format RspecJunitFormatter \
--out /tmp/test-results/rspec.xml \
--format progress \
$TEST_FILES
./tmp/cc-test-reporter format-coverage -t simplecov -o tmp/codeclimate.backend.json coverage/backend/.resultset.json

- persist_to_workspace:
root: tmp
paths:
- codeclimate.backend.json

- run:
name: Upload coverage results to Code Climate
command: |
./tmp/cc-test-reporter sum-coverage tmp/codeclimate.*.json -p 1 -o tmp/codeclimate.total.json
./tmp/cc-test-reporter upload-coverage -i tmp/codeclimate.total.json

# collect reports
- store_test_results:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ config/database.yml
/config/*.production.yml

.gitconfig

# Ignore test coverage
/coverage
7 changes: 4 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,14 @@ gem 'figaro'
gem 'sidekiq'

group :development, :test do
gem 'factory_bot'
gem 'factory_bot_rails'
gem 'graphiql-rails'
gem 'pry'
gem 'pry-rails'
gem 'rspec-rails'
gem 'rspec_junit_formatter'
gem 'factory_bot'
gem 'factory_bot_rails'
gem 'graphiql-rails'
gem 'simplecov', require: false
end

group :development do
Expand Down
54 changes: 31 additions & 23 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.12.2)
concurrent-ruby (1.0.5)
concurrent-ruby (1.1.5)
connection_pool (2.2.1)
crass (1.0.4)
devise (4.4.1)
Expand All @@ -104,6 +104,7 @@ GEM
responders
warden (~> 1.2.3)
diff-lcs (1.3)
docile (1.3.1)
erubis (2.7.0)
execjs (2.7.0)
factory_bot (4.8.2)
Expand All @@ -127,7 +128,7 @@ GEM
has_scope (0.7.2)
actionpack (>= 4.1)
activesupport (>= 4.1)
i18n (1.0.1)
i18n (1.6.0)
concurrent-ruby (~> 1.0)
inherited_resources (1.8.0)
actionpack (>= 4.2, <= 5.2)
Expand All @@ -141,6 +142,7 @@ GEM
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
json (2.2.0)
kaminari (1.1.1)
activesupport (>= 4.1.0)
kaminari-actionview (= 1.1.1)
Expand All @@ -156,22 +158,22 @@ GEM
listen (3.0.8)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
loofah (2.2.2)
loofah (2.2.3)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.0)
mini_mime (>= 0.1.1)
method_source (0.9.0)
method_source (0.9.2)
mini_mime (1.0.0)
mini_portile2 (2.3.0)
mini_portile2 (2.4.0)
minitest (5.11.3)
multi_json (1.13.1)
net-scp (1.2.1)
net-ssh (>= 2.6.5)
net-ssh (4.2.0)
nio4r (2.3.0)
nokogiri (1.8.3)
mini_portile2 (~> 2.3.0)
nokogiri (1.10.2)
mini_portile2 (~> 2.4.0)
orm_adapter (0.5.0)
pg (0.20.0)
polyamorous (1.3.3)
Expand All @@ -182,7 +184,7 @@ GEM
pry-rails (0.3.6)
pry (>= 0.10.4)
puma (3.11.2)
rack (2.0.5)
rack (2.0.7)
rack-protection (2.0.1)
rack
rack-test (0.6.3)
Expand Down Expand Up @@ -210,7 +212,7 @@ GEM
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (12.3.1)
rake (12.3.2)
ransack (1.8.8)
actionpack (>= 3.0)
activerecord (>= 3.0)
Expand All @@ -224,23 +226,23 @@ GEM
responders (2.4.0)
actionpack (>= 4.2.0, < 5.3)
railties (>= 4.2.0, < 5.3)
rspec-core (3.7.1)
rspec-support (~> 3.7.0)
rspec-expectations (3.7.0)
rspec-core (3.8.0)
rspec-support (~> 3.8.0)
rspec-expectations (3.8.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.7.0)
rspec-mocks (3.7.0)
rspec-support (~> 3.8.0)
rspec-mocks (3.8.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.7.0)
rspec-rails (3.7.2)
rspec-support (~> 3.8.0)
rspec-rails (3.8.2)
actionpack (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
rspec-core (~> 3.7.0)
rspec-expectations (~> 3.7.0)
rspec-mocks (~> 3.7.0)
rspec-support (~> 3.7.0)
rspec-support (3.7.1)
rspec-core (~> 3.8.0)
rspec-expectations (~> 3.8.0)
rspec-mocks (~> 3.8.0)
rspec-support (~> 3.8.0)
rspec-support (3.8.0)
rspec_junit_formatter (0.3.0)
rspec-core (>= 2, < 4, != 2.12.0)
sass (3.5.6)
Expand All @@ -259,6 +261,11 @@ GEM
connection_pool (~> 2.2, >= 2.2.0)
rack-protection (>= 1.5.0)
redis (>= 3.3.5, < 5)
simplecov (0.16.1)
docile (~> 1.1)
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.2)
slim (3.0.9)
temple (>= 0.7.6, < 0.9)
tilt (>= 1.3.3, < 2.1)
Expand All @@ -282,7 +289,7 @@ GEM
net-scp (>= 1.1.2)
net-ssh (>= 2.8.0)
temple (0.8.0)
thor (0.20.0)
thor (0.20.3)
thread_safe (0.3.6)
tilt (2.0.8)
tzinfo (1.2.5)
Expand Down Expand Up @@ -335,6 +342,7 @@ DEPENDENCIES
rspec_junit_formatter
sass-rails (~> 5.0)
sidekiq
simplecov
slim-rails
spring
spring-watcher-listen (~> 2.0.0)
Expand All @@ -343,4 +351,4 @@ DEPENDENCIES
web-console (>= 3.3.0)

BUNDLED WITH
1.16.1
1.16.6
2 changes: 1 addition & 1 deletion spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
abort("The Rails environment is running in production mode!") if Rails.env.production?
require 'rspec/rails'
# Add additional requires below this line. Rails is not loaded until this point!

Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
# Requires supporting ruby files with custom matchers and macros, etc, in
# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
# run as spec files by default. This means that files in spec/support that end
Expand Down
45 changes: 45 additions & 0 deletions spec/requests/graphql/etymons_search_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
require 'rails_helper'

RSpec.describe 'Graphql::EtymonsSearch', type: :request do
describe 'search_etymons' do
let(:query_string) do
%|{
etymonsSearch(spelling_cont: "#{q_etymon}") {
id
spelling
meaning
}
}|
end

context 'when it matches some' do
let(:q_etymon) { 'i' }
before do
create :etymon, spelling: 'inter-'
create :etymon, spelling: 'kind-'
create :etymon, spelling: 'para-'
end

it 'returns 200 success' do
post '/graphql', params: { query: query_string }

expect(response).to have_http_status :ok
expect(data.keys).not_to include('errors')
end

it 'lists matched etymons' do
post '/graphql', params: { query: query_string }
expect(data['etymonsSearch'].map { |record| record['spelling'] }).to eq %w(inter- kind-)
end
end

context 'when it matches none' do
let(:q_etymon) { 'az' }

it 'returns an empty array' do
post '/graphql', params: { query: query_string }
expect(data['etymonsSearch'].count).to be_zero
end
end
end
end
10 changes: 4 additions & 6 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
# This file was generated by the `rails generate rspec:install` 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
Expand All @@ -13,6 +7,10 @@
# it.
#
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration

require 'simplecov'
SimpleCov.start

RSpec.configure do |config|
# rspec-expectations config goes here. You can use an alternate
# assertion/expectation library such as wrong or the stdlib/minitest
Expand Down
3 changes: 3 additions & 0 deletions spec/support/factory_bot.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
RSpec.configure do |config|
config.include FactoryBot::Syntax::Methods
end
9 changes: 9 additions & 0 deletions spec/support/request_spec_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module RequestSpecHelper
def data
JSON.parse(response.body)['data']
end
end

RSpec.configure do |config|
config.include RequestSpecHelper, type: :request
end