remove random string spec helper function in favour of factory girl sequences
This commit is contained in:
parent
96ec672779
commit
7ea91273c8
5 changed files with 11 additions and 18 deletions
|
@ -1,6 +1,6 @@
|
||||||
FactoryGirl.define do
|
FactoryGirl.define do
|
||||||
factory :map do
|
factory :map do
|
||||||
name { random_string(10) }
|
sequence(:name) { |n| "Cool Map ##{n}" }
|
||||||
permission :commons
|
permission :commons
|
||||||
arranged { false }
|
arranged { false }
|
||||||
user
|
user
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
FactoryGirl.define do
|
FactoryGirl.define do
|
||||||
factory :synapse do
|
factory :synapse do
|
||||||
desc { random_string(10) }
|
sequence(:desc) { |n| "Cool synapse ##{n}" }
|
||||||
category :to
|
category :to
|
||||||
permission :commons
|
permission :commons
|
||||||
association :topic1, factory: :topic
|
association :topic1, factory: :topic
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
FactoryGirl.define do
|
FactoryGirl.define do
|
||||||
factory :topic do
|
factory :topic do
|
||||||
name { random_string(10) }
|
sequence(:name) { |n| "Cool Topic ##{n}" }
|
||||||
permission :commons
|
permission :commons
|
||||||
user
|
user
|
||||||
metacode
|
metacode
|
||||||
|
|
|
@ -1,12 +1,15 @@
|
||||||
FactoryGirl.define do
|
FactoryGirl.define do
|
||||||
factory :user do
|
factory :user do
|
||||||
name { random_string(10) }
|
sequence(:name) { |n| "Cool User ##{n}" }
|
||||||
email { random_string(10) + '@' + random_string(10) + '.com' }
|
sequence(:email) { |n| "cooluser#{n}@cooldomain.com" }
|
||||||
code { random_string(8) }
|
joinedwithcode { "qwertyui" }
|
||||||
joinedwithcode { code }
|
|
||||||
password 'omgwtfbbq'
|
password 'omgwtfbbq'
|
||||||
|
|
||||||
|
transient do
|
||||||
|
validate false
|
||||||
|
end
|
||||||
|
|
||||||
# bypass validation of the joinedwithcode
|
# bypass validation of the joinedwithcode
|
||||||
to_create { |instance| instance.save(validate: false) }
|
to_create { |instance| instance.save(validate: instance.validate) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,14 +6,4 @@ RSpec.configure do |config|
|
||||||
config.mock_with :rspec do |mocks|
|
config.mock_with :rspec do |mocks|
|
||||||
mocks.verify_partial_doubles = true
|
mocks.verify_partial_doubles = true
|
||||||
end
|
end
|
||||||
|
|
||||||
# Print the 10 slowest examples and example groups at the
|
|
||||||
# end of the spec run, to help surface which specs are running
|
|
||||||
# particularly slow.
|
|
||||||
config.profile_examples = 10
|
|
||||||
end
|
|
||||||
|
|
||||||
def random_string(length = 10)
|
|
||||||
o = [('a'..'z'), ('A'..'Z')].map(&:to_a).flatten
|
|
||||||
(0...length).map { o[rand(o.length)] }.join
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue