improve tests

This commit is contained in:
Torsten Ruger 2016-11-05 12:34:06 +02:00
parent 6f5d7a4908
commit 3f7e6b6175
9 changed files with 61 additions and 61 deletions

View File

@ -27,8 +27,10 @@ $(document).ready ->
return
$(document).ready ->
$.ajax(url: "/resume/progress").done (html) ->
$("#progress").html html
bar = jQuery("#progress")
if(bar.length > 0)
$.ajax(url: "/resume/progress").done (html) ->
bar.html html
$(document).ready ->
$('.best_in_place').bind 'ajax:success', ->

View File

@ -1,7 +1,11 @@
FactoryGirl.define do
factory :course do
name "First Course"
sequence :name do |n|
"Course #{n}"
end
extra "With Extras"
start "2016-06-17"
sequence :start do |n|
Time.now - 2.weeks + (n*2).weeks
end
end
end

View File

@ -0,0 +1,26 @@
feature 'Applies' do
before(:each) do
sign_new
create_list( :course , 3)
visit application_path
end
after(:each) do
Warden.test_reset!
end
scenario 'Send Application' do
within "#apply_primary_choice_course_id" do
courses = page.find_all("option")
expect(courses.length).to be 3
end
end
scenario "has plan select" do
within "#apply_plan" do
courses = page.find_all("option")
expect(courses.length).to be 3
end
end
end

View File

@ -1,5 +1,3 @@
include Warden::Test::Helpers
Warden.test_mode!
# Feature: User profile page
# As a user

View File

@ -1,5 +1,3 @@
include Warden::Test::Helpers
Warden.test_mode!
# Feature: User edit
# As a user

View File

@ -1,5 +1,3 @@
include Warden::Test::Helpers
Warden.test_mode!
feature 'Resume edit' do

View File

@ -6,4 +6,22 @@ RSpec.describe Course, type: :model do
course = build :course
expect(course.save).to eq true
end
it "names course not the same" do
course1 = create :course
course2 = create :course
expect(course1.name).not_to eq course2.name
end
it "creates courses that don't start at the same time" do
course1 = create :course
course2 = create :course
expect(course1.start).not_to eq course2.start
end
it "the second course is in the future" do
create :course
course2 = create :course
expect((course2.start - DateTime.now).to_i).to be < 250
end
end

View File

@ -7,51 +7,20 @@ require 'spec_helper'
require 'rspec/rails'
# Add additional requires below this line. Rails is not loaded until this point!
# 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
# in _spec.rb will both be required and run as specs, causing the specs to be
# run twice. It is recommended that you do not name files matching this glob to
# end with _spec.rb. You can configure this pattern with the --pattern
# option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
#
# The following line is provided for convenience purposes. It has the downside
# of increasing the boot-up time by auto-requiring all files in the support
# directory. Alternatively, in the individual `*_spec.rb` files, manually
# require only the support files necessary.
#
Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
# Checks for pending migration and applies them before tests are run.
# If you are not using ActiveRecord, you can remove this line.
ActiveRecord::Migration.maintain_test_schema!
RSpec.configure do |config|
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
config.fixture_path = "#{::Rails.root}/spec/fixtures"
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
config.use_transactional_fixtures = false
# RSpec Rails can automatically mix in different behaviours to your tests
# based on their file location, for example enabling you to call `get` and
# `post` in specs under `spec/controllers`.
#
# You can disable this behaviour by removing the line below, and instead
# explicitly tag your specs with their type, e.g.:
#
# RSpec.describe UsersController, :type => :controller do
# # ...
# end
#
# The different available types are documented in the features, such as in
# https://relishapp.com/rspec/rspec-rails/docs
config.infer_spec_type_from_file_location!
# Filter lines from Rails gems in backtraces.
config.filter_rails_from_backtrace!
# arbitrary gems may also be filtered via:
# config.filter_gems_from_backtrace("gem name")
config.include Warden::Test::Helpers, type: :feature
# config.include Devise::Test::IntegrationHelpers, type: :feature
Warden.test_mode!
end

View File

@ -1,18 +1,5 @@
ENV["RAILS_ENV"] = 'test'
# 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
# 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.
#
# The `.rspec` file also contains a few flags that are not defaults but that
# users commonly want.