Introduction
Introduction Statistics Contact Development Disclaimer Help
added rspec model tests for user and call leveraging factories and FactoryGirl …
Log
Files
Refs
README
---
commit db2897631ed5f274157ae7c5c807bf012ed94ca4
parent 26c325678af4c1cdcb43b50f8535b146a2653258
Author: zeknox <[email protected]>
Date: Fri, 23 Oct 2015 16:42:53 -0500
added rspec model tests for user and call leveraging factories and FactoryGirl
Diffstat:
A spec/factories/calls.rb | 32 +++++++++++++++++++++++++++++…
M spec/factories/users.rb | 6 +++++-
A spec/models/call_spec.rb | 38 +++++++++++++++++++++++++++++…
M spec/models/user_spec.rb | 8 +++++++-
M spec/rails_helper.rb | 3 +++
5 files changed, 85 insertions(+), 2 deletions(-)
---
diff --git a/spec/factories/calls.rb b/spec/factories/calls.rb
@@ -0,0 +1,32 @@
+# == Schema Information
+#
+# Table name: calls
+#
+# id :integer not null, primary key
+# created_at :datetime
+# updated_at :datetime
+# number :text not null
+# project_id :integer not null
+# job_id :integer not null
+# provider_id :integer not null
+# answered :boolean
+# busy :boolean
+# error :text
+# audio_length :integer
+# ring_length :integer
+# caller_id :text
+# analysis_job_id :integer
+# analysis_started_at :datetime
+# analysis_completed_at :datetime
+# peak_freq :float
+# peak_freq_data :text
+# line_type :text
+# fprint :integer is an Array
+#
+
+FactoryGirl.define do
+ factory :call do
+ number { Faker::PhoneNumber.phone_number }
+ end
+
+end
diff --git a/spec/factories/users.rb b/spec/factories/users.rb
@@ -25,7 +25,11 @@
FactoryGirl.define do
factory :user do
-
+ login { Faker::Internet.user_name }
+ password 'RandomPass'
+ password_confirmation 'RandomPass'
+ enabled true
+ admin true
end
end
diff --git a/spec/models/call_spec.rb b/spec/models/call_spec.rb
@@ -0,0 +1,38 @@
+# == Schema Information
+#
+# Table name: calls
+#
+# id :integer not null, primary key
+# created_at :datetime
+# updated_at :datetime
+# number :text not null
+# project_id :integer not null
+# job_id :integer not null
+# provider_id :integer not null
+# answered :boolean
+# busy :boolean
+# error :text
+# audio_length :integer
+# ring_length :integer
+# caller_id :text
+# analysis_job_id :integer
+# analysis_started_at :datetime
+# analysis_completed_at :datetime
+# peak_freq :float
+# peak_freq_data :text
+# line_type :text
+# fprint :integer is an Array
+#
+
+require 'rails_helper'
+
+RSpec.describe Call, type: :model do
+ it { should belong_to(:project) }
+ it { should belong_to(:provider) }
+ it { should belong_to(:job) }
+ it { should have_one(:call_medium).dependent(:delete) }
+
+ it "valid record" do
+ expect(build(:call)).to be_valid
+ end
+end
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
@@ -26,5 +26,11 @@
require 'rails_helper'
RSpec.describe User, type: :model do
- pending "add some examples to (or delete) #{__FILE__}"
+ it { should validate_length_of(:password).is_at_least(8) }
+ it { should validate_length_of(:password_confirmation).is_at_least(8) }
+
+ it 'valid record' do
+ user = build(:user)
+ expect(user).to be_valid
+ end
end
diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb
@@ -27,6 +27,9 @@ require 'rspec/rails'
ActiveRecord::Migration.maintain_test_schema!
RSpec.configure do |config|
+ # FactoryGirl Syntax
+ config.include FactoryGirl::Syntax::Methods
+
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
config.fixture_path = "#{::Rails.root}/spec/fixtures"
You are viewing proxied material from jay.scot. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.