Fix specs in the presence of fixture_builder
This commit is contained in:
parent
345d346224
commit
fdc9534fc7
5 changed files with 55 additions and 67 deletions
1
Gemfile
1
Gemfile
|
|
@ -56,6 +56,7 @@ end
|
||||||
|
|
||||||
group :test do
|
group :test do
|
||||||
gem 'factory_girl_rails'
|
gem 'factory_girl_rails'
|
||||||
|
gem 'fixture_builder', '~> 0.2.0'
|
||||||
gem 'capybara', '~> 0.3.9'
|
gem 'capybara', '~> 0.3.9'
|
||||||
gem 'cucumber-rails', '0.3.2'
|
gem 'cucumber-rails', '0.3.2'
|
||||||
gem 'rspec', '>= 2.0.0'
|
gem 'rspec', '>= 2.0.0'
|
||||||
|
|
|
||||||
|
|
@ -162,6 +162,7 @@ GEM
|
||||||
fastthread (1.0.7)
|
fastthread (1.0.7)
|
||||||
ffi (0.6.3)
|
ffi (0.6.3)
|
||||||
rake (>= 0.8.7)
|
rake (>= 0.8.7)
|
||||||
|
fixture_builder (0.2.0)
|
||||||
fog (0.3.25)
|
fog (0.3.25)
|
||||||
builder
|
builder
|
||||||
excon (>= 0.2.4)
|
excon (>= 0.2.4)
|
||||||
|
|
@ -371,6 +372,7 @@ DEPENDENCIES
|
||||||
em-websocket!
|
em-websocket!
|
||||||
factory_girl_rails
|
factory_girl_rails
|
||||||
fastercsv (= 1.5.4)
|
fastercsv (= 1.5.4)
|
||||||
|
fixture_builder (~> 0.2.0)
|
||||||
fog
|
fog
|
||||||
haml (= 3.0.25)
|
haml (= 3.0.25)
|
||||||
http_accept_language!
|
http_accept_language!
|
||||||
|
|
|
||||||
|
|
@ -31,15 +31,13 @@ describe DataConversion::ImportToMysql do
|
||||||
@migrator.import_raw_users
|
@migrator.import_raw_users
|
||||||
end
|
end
|
||||||
it "imports data into the users table" do
|
it "imports data into the users table" do
|
||||||
Mongo::User.count.should == 6
|
lambda {
|
||||||
User.count.should == 0
|
@migrator.process_raw_users
|
||||||
@migrator.process_raw_users
|
}.should change(User, :count).by(Mongo::User.count)
|
||||||
User.count.should == 6
|
|
||||||
end
|
end
|
||||||
it "imports all the columns" do
|
it "imports all the columns" do
|
||||||
@migrator.process_raw_users
|
@migrator.process_raw_users
|
||||||
bob = User.first
|
bob = User.where(:mongo_id => "4d2b6eb6cc8cb43cc2000007").first
|
||||||
bob.mongo_id.should == "4d2b6eb6cc8cb43cc2000007"
|
|
||||||
bob.username.should == "bob1d2f837"
|
bob.username.should == "bob1d2f837"
|
||||||
bob.email.should == "bob1a25dee@pivotallabs.com"
|
bob.email.should == "bob1a25dee@pivotallabs.com"
|
||||||
bob.serialized_private_key.should_not be_nil
|
bob.serialized_private_key.should_not be_nil
|
||||||
|
|
@ -64,21 +62,19 @@ describe DataConversion::ImportToMysql do
|
||||||
@migrator.import_raw_aspects
|
@migrator.import_raw_aspects
|
||||||
end
|
end
|
||||||
it "imports data into the aspects table" do
|
it "imports data into the aspects table" do
|
||||||
Mongo::Aspect.count.should == 4
|
lambda {
|
||||||
Aspect.count.should == 0
|
@migrator.process_raw_aspects
|
||||||
@migrator.process_raw_aspects
|
}.should change(Aspect, :count).by(Mongo::Aspect.count)
|
||||||
Aspect.count.should == 4
|
|
||||||
end
|
end
|
||||||
it "imports all the columns" do
|
it "imports all the columns" do
|
||||||
@migrator.process_raw_aspects
|
@migrator.process_raw_aspects
|
||||||
aspect = Aspect.first
|
aspect = Aspect.where(:mongo_id => "4d2b6eb6cc8cb43cc2000008").first
|
||||||
aspect.name.should == "generic"
|
aspect.name.should == "generic"
|
||||||
aspect.mongo_id.should == "4d2b6eb6cc8cb43cc2000008"
|
|
||||||
aspect.user_mongo_id.should == "4d2b6eb6cc8cb43cc2000007"
|
aspect.user_mongo_id.should == "4d2b6eb6cc8cb43cc2000007"
|
||||||
end
|
end
|
||||||
it "sets the relation column" do
|
it "sets the relation column" do
|
||||||
@migrator.process_raw_aspects
|
@migrator.process_raw_aspects
|
||||||
aspect = Aspect.first
|
aspect = Aspect.where(:mongo_id => "4d2b6eb6cc8cb43cc2000008").first
|
||||||
aspect.user.should == User.where(:mongo_id => aspect.user_mongo_id).first
|
aspect.user.should == User.where(:mongo_id => aspect.user_mongo_id).first
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -91,18 +87,16 @@ describe DataConversion::ImportToMysql do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "imports data into the services table" do
|
it "imports data into the services table" do
|
||||||
Mongo::Service.count.should == 2
|
lambda {
|
||||||
Service.count.should == 0
|
@migrator.process_raw_services
|
||||||
@migrator.process_raw_services
|
}.should change(Service, :count).by(Mongo::Service.count)
|
||||||
Service.count.should == 2
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it "imports all the columns" do
|
it "imports all the columns" do
|
||||||
@migrator.process_raw_services
|
@migrator.process_raw_services
|
||||||
service = Service.first
|
service = Service.where(:mongo_id => "4d2b6ec4cc8cb43cc200003e").first
|
||||||
service.type_before_type_cast.should == "Services::Facebook"
|
service.type_before_type_cast.should == "Services::Facebook"
|
||||||
service.user_mongo_id.should == "4d2b6eb7cc8cb43cc2000014"
|
service.user_mongo_id.should == "4d2b6eb7cc8cb43cc2000014"
|
||||||
service.mongo_id.should == "4d2b6ec4cc8cb43cc200003e"
|
|
||||||
service.provider.should be_nil
|
service.provider.should be_nil
|
||||||
service.uid.should be_nil
|
service.uid.should be_nil
|
||||||
service.access_token.should == "yeah"
|
service.access_token.should == "yeah"
|
||||||
|
|
@ -111,7 +105,7 @@ describe DataConversion::ImportToMysql do
|
||||||
end
|
end
|
||||||
it 'sets the relation column' do
|
it 'sets the relation column' do
|
||||||
@migrator.process_raw_services
|
@migrator.process_raw_services
|
||||||
service = Service.first
|
service = Service.where(:mongo_id => "4d2b6ec4cc8cb43cc200003e").first
|
||||||
service.user_id.should == User.where(:mongo_id => service.user_mongo_id).first.id
|
service.user_id.should == User.where(:mongo_id => service.user_mongo_id).first.id
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -182,18 +176,16 @@ describe DataConversion::ImportToMysql do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "imports data into the people table" do
|
it "imports data into the people table" do
|
||||||
Mongo::Person.count.should == 10
|
lambda {
|
||||||
Person.count.should == 0
|
@migrator.process_raw_people
|
||||||
@migrator.process_raw_people
|
}.should change(Person, :count).by(Mongo::Person.count)
|
||||||
Person.count.should == 10
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it "imports all the columns of a non-owned person" do
|
it "imports all the columns of a non-owned person" do
|
||||||
@migrator.process_raw_people
|
@migrator.process_raw_people
|
||||||
mongo_person = Mongo::Person.first
|
mongo_person = Mongo::Person.where(:mongo_id => "4d2b6eb6cc8cb43cc2000001").first
|
||||||
person = Person.first
|
person = Person.where(:mongo_id => "4d2b6eb6cc8cb43cc2000001").first
|
||||||
person.owner_id.should be_nil
|
person.owner_id.should be_nil
|
||||||
person.mongo_id.should == "4d2b6eb6cc8cb43cc2000001"
|
|
||||||
person.guid.should == person.mongo_id
|
person.guid.should == person.mongo_id
|
||||||
person.url.should == "http://google-1b05052.com/"
|
person.url.should == "http://google-1b05052.com/"
|
||||||
person.diaspora_handle.should == "bob-person-1fe12fb@aol.com"
|
person.diaspora_handle.should == "bob-person-1fe12fb@aol.com"
|
||||||
|
|
@ -203,9 +195,8 @@ describe DataConversion::ImportToMysql do
|
||||||
|
|
||||||
it "imports all the columns of an owned person" do
|
it "imports all the columns of an owned person" do
|
||||||
@migrator.process_raw_people
|
@migrator.process_raw_people
|
||||||
person = Person.where(:owner_id => User.first.id).first
|
mongo_person = Mongo::Person.first
|
||||||
mongo_person = Mongo::Person.where(:mongo_id => person.mongo_id).first
|
person = Person.where(:mongo_id => mongo_person.mongo_id).first
|
||||||
person.mongo_id.should == mongo_person.mongo_id
|
|
||||||
person.guid.should == mongo_person.mongo_id
|
person.guid.should == mongo_person.mongo_id
|
||||||
person.url.should == mongo_person.url
|
person.url.should == mongo_person.url
|
||||||
person.diaspora_handle.should == mongo_person.diaspora_handle
|
person.diaspora_handle.should == mongo_person.diaspora_handle
|
||||||
|
|
@ -214,8 +205,9 @@ describe DataConversion::ImportToMysql do
|
||||||
end
|
end
|
||||||
it 'sets the relational column of an owned person' do
|
it 'sets the relational column of an owned person' do
|
||||||
@migrator.process_raw_people
|
@migrator.process_raw_people
|
||||||
person = Person.where(:owner_id => User.first.id).first
|
mongo_person = Mongo::Person.where("mongo_people.owner_mongo_id IS NOT NULL").first
|
||||||
person.should_not be_nil
|
person = Person.where(:mongo_id => mongo_person.mongo_id).first
|
||||||
|
person.owner.should_not be_nil
|
||||||
person.diaspora_handle.should include(person.owner.username)
|
person.diaspora_handle.should include(person.owner.username)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -229,17 +221,15 @@ describe DataConversion::ImportToMysql do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "imports data into the mongo_contacts table" do
|
it "imports data into the mongo_contacts table" do
|
||||||
Mongo::Contact.count.should == 6
|
lambda {
|
||||||
Contact.count.should == 0
|
@migrator.process_raw_contacts
|
||||||
@migrator.process_raw_contacts
|
}.should change(Contact, :count).by(Mongo::Contact.count)
|
||||||
Contact.count.should == 6
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it "imports all the columns" do
|
it "imports all the columns" do
|
||||||
@migrator.process_raw_contacts
|
@migrator.process_raw_contacts
|
||||||
contact = Contact.first
|
mongo_contact = Mongo::Contact.first
|
||||||
mongo_contact = Mongo::Contact.where(:mongo_id => contact.mongo_id).first
|
contact = Contact.where(:mongo_id => mongo_contact.mongo_id).first
|
||||||
contact.mongo_id.should == "4d2b6eb7cc8cb43cc200000f"
|
|
||||||
contact.user_id.should == User.where(:mongo_id => mongo_contact.user_mongo_id).first.id
|
contact.user_id.should == User.where(:mongo_id => mongo_contact.user_mongo_id).first.id
|
||||||
contact.person_id.should == Person.where(:mongo_id => mongo_contact.person_mongo_id).first.id
|
contact.person_id.should == Person.where(:mongo_id => mongo_contact.person_mongo_id).first.id
|
||||||
contact.pending.should be_false
|
contact.pending.should be_false
|
||||||
|
|
@ -257,18 +247,18 @@ describe DataConversion::ImportToMysql do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "imports data into the mongo_aspect_memberships table" do
|
it "imports data into the mongo_aspect_memberships table" do
|
||||||
Mongo::AspectMembership.count.should == 6
|
lambda {
|
||||||
AspectMembership.count.should == 0
|
@migrator.process_raw_aspect_memberships
|
||||||
@migrator.process_raw_aspect_memberships
|
}.should change(AspectMembership, :count).by(Mongo::AspectMembership.count)
|
||||||
AspectMembership.count.should == 6
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it "imports all the columns" do
|
it "imports all the columns" do
|
||||||
@migrator.process_raw_aspect_memberships
|
@migrator.process_raw_aspect_memberships
|
||||||
aspectm = AspectMembership.first
|
|
||||||
mongo_aspectm = Mongo::AspectMembership.first
|
mongo_aspectm = Mongo::AspectMembership.first
|
||||||
aspectm.contact_id.should == Contact.where(:mongo_id => mongo_aspectm.contact_mongo_id).first.id
|
aspectm = AspectMembership.where(
|
||||||
aspectm.aspect_id.should == Aspect.where(:mongo_id => mongo_aspectm.aspect_mongo_id).first.id
|
:contact_id => Contact.where(:mongo_id => mongo_aspectm.contact_mongo_id).first.id,
|
||||||
|
:aspect_id => Aspect.where(:mongo_id => mongo_aspectm.aspect_mongo_id).first.id).first
|
||||||
|
aspectm.should_not be_nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
describe "profiles" do
|
describe "profiles" do
|
||||||
|
|
@ -280,19 +270,17 @@ describe DataConversion::ImportToMysql do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "processs data into the mongo_profiles table" do
|
it "processs data into the mongo_profiles table" do
|
||||||
Mongo::Profile.count.should == 10
|
lambda {
|
||||||
Profile.count.should == 0
|
@migrator.process_raw_profiles
|
||||||
@migrator.process_raw_profiles
|
}.should change(Profile, :count).by(Mongo::Profile.count)
|
||||||
Profile.count.should == 10
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it "processs all the columns" do
|
it "processs all the columns" do
|
||||||
@migrator.process_raw_profiles
|
@migrator.process_raw_profiles
|
||||||
profile = Profile.first
|
profile = Profile.where(:mongo_id => "4d2b6eb6cc8cb43cc2000001").first
|
||||||
profile.image_url_medium.should be_nil
|
profile.image_url_medium.should be_nil
|
||||||
profile.searchable.should == true
|
profile.searchable.should == true
|
||||||
profile.image_url.should be_nil
|
profile.image_url.should be_nil
|
||||||
profile.mongo_id.should == "4d2b6eb6cc8cb43cc2000001"
|
|
||||||
profile.gender.should be_nil
|
profile.gender.should be_nil
|
||||||
profile.diaspora_handle.should == profile.person.diaspora_handle
|
profile.diaspora_handle.should == profile.person.diaspora_handle
|
||||||
profile.last_name.should == 'weinstien'
|
profile.last_name.should == 'weinstien'
|
||||||
|
|
@ -315,10 +303,9 @@ describe DataConversion::ImportToMysql do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "imports data into the posts table" do
|
it "imports data into the posts table" do
|
||||||
Mongo::Post.count.should == 6
|
lambda {
|
||||||
Post.count.should == 0
|
@migrator.process_raw_posts
|
||||||
@migrator.process_raw_posts
|
}.should change(Post, :count).by(Mongo::Post.count)
|
||||||
Post.count.should == 6
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it "imports all the columns" do
|
it "imports all the columns" do
|
||||||
|
|
@ -374,11 +361,10 @@ describe DataConversion::ImportToMysql do
|
||||||
@migrator.import_raw_comments
|
@migrator.import_raw_comments
|
||||||
end
|
end
|
||||||
|
|
||||||
it "imports data into the mongo_comments table" do
|
it "imports data into the comments table" do
|
||||||
Mongo::Comment.count.should == 2
|
lambda {
|
||||||
Comment.count.should == 0
|
@migrator.process_raw_comments
|
||||||
@migrator.process_raw_comments
|
}.should change(Comment, :count).by(Mongo::Comment.count)
|
||||||
Comment.count.should == 2
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it "processes all the columns" do
|
it "processes all the columns" do
|
||||||
|
|
|
||||||
|
|
@ -28,12 +28,11 @@ describe RakeHelpers do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should make a user with 10 invites' do
|
it 'should make a user with 10 invites' do
|
||||||
User.count.should == 0
|
lambda {
|
||||||
|
process_emails(@csv, 1, 1, 10, false)
|
||||||
|
}.should change(User, :count).by(1)
|
||||||
|
|
||||||
process_emails(@csv, 1, 1, 10, false)
|
User.last.invites.should == 10
|
||||||
|
|
||||||
User.count.should == 1
|
|
||||||
User.first.invites.should == 10
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -13,11 +13,11 @@ require 'factory_girl'
|
||||||
|
|
||||||
include Devise::TestHelpers
|
include Devise::TestHelpers
|
||||||
include WebMock::API
|
include WebMock::API
|
||||||
|
include HelperMethods
|
||||||
#
|
#
|
||||||
# Requires supporting files with custom matchers and macros, etc,
|
# Requires supporting files with custom matchers and macros, etc,
|
||||||
# in ./support/ and its subdirectories.
|
# in ./support/ and its subdirectories.
|
||||||
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
||||||
include HelperMethods
|
|
||||||
|
|
||||||
RSpec.configure do |config|
|
RSpec.configure do |config|
|
||||||
config.mock_with :mocha
|
config.mock_with :mocha
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue