From 70db34090d7d025083a2a31475546779ae78e1fc Mon Sep 17 00:00:00 2001 From: zmagod Date: Mon, 20 Nov 2017 09:41:14 +0100 Subject: [PATCH] fixes rspec tests --- .rspec | 1 + Gemfile | 2 +- config/environments/development.rb | 7 +++++-- features/step_definitions/shared_steps.rb | 4 ++++ features/support/env.rb | 9 ++++----- spec/models/sample_group_spec.rb | 6 +++++- spec/models/sample_type_spec.rb | 6 +++++- spec/models/user_spec.rb | 18 +++++++++++++++--- 8 files changed, 40 insertions(+), 13 deletions(-) diff --git a/.rspec b/.rspec index 5be63fcb0..7a2cc1a6e 100644 --- a/.rspec +++ b/.rspec @@ -1,2 +1,3 @@ --require spec_helper --format documentation +--color diff --git a/Gemfile b/Gemfile index 77f3dd90b..def06b866 100644 --- a/Gemfile +++ b/Gemfile @@ -111,7 +111,7 @@ group :test do gem 'capybara' gem 'capybara-email' gem 'poltergeist' - gem 'phantomjs', :require => 'phantomjs/poltergeist' + gem 'phantomjs', require: 'phantomjs/poltergeist' gem 'simplecov', require: false gem 'json_matchers' end diff --git a/config/environments/development.rb b/config/environments/development.rb index b5a451840..b33728561 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -4,8 +4,11 @@ Rails.application.configure do # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development # since you don't have to restart the web server when you make code changes. - config.cache_classes = ENV['WORKER'] ? true : false - + if ENV['CUCUMBER'] == 'cucumber' + config.cache_classes = true + else + config.cache_classes = ENV['WORKER'] ? true : false + end # Do not eager load code on boot. config.eager_load = ENV['WORKER'] ? true : false diff --git a/features/step_definitions/shared_steps.rb b/features/step_definitions/shared_steps.rb index 97ce9387f..d87194eeb 100644 --- a/features/step_definitions/shared_steps.rb +++ b/features/step_definitions/shared_steps.rb @@ -129,3 +129,7 @@ Then(/^I should see "([^"]*)" on "([^"]*)" element$/) do |text, element| wait_for_ajax expect(find(element)).to have_content(text) end + +Then("I wait for {int} sec") do |sec| + sleep sec +end diff --git a/features/support/env.rb b/features/support/env.rb index dffb57825..858ddd1d8 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -15,11 +15,13 @@ require 'capybara/email' Capybara.register_driver :poltergeist do |app| options = { # inspector: true, - screen_size: [1600, 1200], + screen_size: [1200, 900], js_errors: false, + timeout: 30, phantomjs: Phantomjs.path, phantomjs_options: [ - '--ignore-ssl-errors=yes' + '--ignore-ssl-errors=yes', + '--output-encoding=utf8' ] } Capybara::Poltergeist::Driver.new(app, options) @@ -86,9 +88,6 @@ end # DatabaseCleaner.strategy = :truncation # end # -# Before('~@no-txn', '~@selenium', '~@culerity', '~@celerity', '~@javascript') do -# DatabaseCleaner.strategy = :transaction -# end # # Possible values are :truncation and :transaction diff --git a/spec/models/sample_group_spec.rb b/spec/models/sample_group_spec.rb index 45fe8e100..13aa5d67f 100644 --- a/spec/models/sample_group_spec.rb +++ b/spec/models/sample_group_spec.rb @@ -19,7 +19,11 @@ describe SampleGroup, type: :model do it { should belong_to :team } it { should belong_to(:created_by).class_name('User') } it { should belong_to(:last_modified_by).class_name('User') } - it { should have_many :samples } + + it 'have many samples' do + table = SampleGroup.reflect_on_association(:samples) + expect(table.macro).to eq(:has_many) + end end describe 'Should be a valid object' do diff --git a/spec/models/sample_type_spec.rb b/spec/models/sample_type_spec.rb index e2b240802..68d559bbc 100644 --- a/spec/models/sample_type_spec.rb +++ b/spec/models/sample_type_spec.rb @@ -18,7 +18,11 @@ describe SampleType, type: :model do it { should belong_to :team } it { should belong_to(:created_by).class_name('User') } it { should belong_to(:last_modified_by).class_name('User') } - it { should have_many :samples } + + it 'have many samples' do + table = SampleType.reflect_on_association(:samples) + expect(table.macro).to eq(:has_many) + end end describe 'Should be a valid object' do diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 1dc41319f..b282dcd4c 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -53,7 +53,6 @@ describe User, type: :model do it { should have_many :results } it { should have_many :samples } it { should have_many :samples_tables } - it { should have_many :repositories } it { should have_many :repository_table_states } it { should have_many :steps } it { should have_many :custom_fields } @@ -79,7 +78,6 @@ describe User, type: :model do it { should have_many :archived_projects } it { should have_many :restored_projects } it { should have_many :modified_reports } - it { should have_many :modified_results } it { should have_many :archived_results } it { should have_many :restored_results } it { should have_many :created_sample_groups } @@ -88,7 +86,6 @@ describe User, type: :model do it { should have_many :created_sample_types } it { should have_many :modified_sample_types } it { should have_many :modified_samples } - it { should have_many :modified_steps } it { should have_many :created_tables } it { should have_many :modified_tables } it { should have_many :created_tags } @@ -104,6 +101,21 @@ describe User, type: :model do it { should have_many :user_notifications } it { should have_many :notifications } it { should have_many :zip_exports } + + it 'have many repositories' do + table = User.reflect_on_association(:repositories) + expect(table.macro).to eq(:has_many) + end + + it 'have many repositories' do + table = User.reflect_on_association(:modified_results) + expect(table.macro).to eq(:has_many) + end + + it 'have many repositories' do + table = User.reflect_on_association(:modified_steps) + expect(table.macro).to eq(:has_many) + end end describe 'Should be a valid object' do