From 15a49e00af169a73ddbe3ac7c608ab92a6f12b17 Mon Sep 17 00:00:00 2001 From: Nicolae Claudius Date: Thu, 13 Oct 2011 16:07:48 -0700 Subject: [PATCH] spec support --- spec/factories.rb | 10 +++++++--- spec/models/domain_spec.rb | 8 +------- spec/support/application.rb | 12 ++++++++++++ spec/support/shared_context/data.rb | 15 +++++++++++++++ 4 files changed, 35 insertions(+), 10 deletions(-) create mode 100644 spec/support/application.rb create mode 100644 spec/support/shared_context/data.rb diff --git a/spec/factories.rb b/spec/factories.rb index a9436f3..ffd9064 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -18,12 +18,16 @@ FactoryGirl.define do factory :record do end - factory :soa_record, :class => 'SOA' do + factory :soa do contact {Faker::Internet.email} end - factory :ns_record, :class => 'NS' do + factory :ns do content {Settings.ns.sample} end + + factory :a do + content {Faker::Internet.ip_v4_address} + end -end \ No newline at end of file +end diff --git a/spec/models/domain_spec.rb b/spec/models/domain_spec.rb index 64e8e83..f589a6a 100644 --- a/spec/models/domain_spec.rb +++ b/spec/models/domain_spec.rb @@ -1,13 +1,7 @@ require 'spec_helper' describe Domain do - let(:domain){ - domain = Factory.build(:domain) - domain.setup(FactoryGirl.generate(:email)) - domain.save! - domain.soa_record.update_serial! - domain - } + include_context "data" it "has correct soa record" do domain.soa_record.should be_present diff --git a/spec/support/application.rb b/spec/support/application.rb new file mode 100644 index 0000000..3392d9e --- /dev/null +++ b/spec/support/application.rb @@ -0,0 +1,12 @@ +module AngelNest + module TestHelpers + +# def make_user +# end + + end +end + +RSpec.configure do |config| + config.include AngelNest::TestHelpers +end \ No newline at end of file diff --git a/spec/support/shared_context/data.rb b/spec/support/shared_context/data.rb new file mode 100644 index 0000000..a4f13e1 --- /dev/null +++ b/spec/support/shared_context/data.rb @@ -0,0 +1,15 @@ +shared_context "data" do + + let(:user){Factory(:user)} + + let(:domain){ + domain = Factory.build(:domain, :user => user) + domain.setup(FactoryGirl.generate(:email)) + domain.save! + domain.soa_record.update_serial! + domain + } + + let(:a_record){Factory(:a, :content => '127.0.0.1', :domain => domain)} + +end