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
|
||||
factory :map do
|
||||
name { random_string(10) }
|
||||
sequence(:name) { |n| "Cool Map ##{n}" }
|
||||
permission :commons
|
||||
arranged { false }
|
||||
user
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
FactoryGirl.define do
|
||||
factory :synapse do
|
||||
desc { random_string(10) }
|
||||
sequence(:desc) { |n| "Cool synapse ##{n}" }
|
||||
category :to
|
||||
permission :commons
|
||||
association :topic1, factory: :topic
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
FactoryGirl.define do
|
||||
factory :topic do
|
||||
name { random_string(10) }
|
||||
sequence(:name) { |n| "Cool Topic ##{n}" }
|
||||
permission :commons
|
||||
user
|
||||
metacode
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
FactoryGirl.define do
|
||||
factory :user do
|
||||
name { random_string(10) }
|
||||
email { random_string(10) + '@' + random_string(10) + '.com' }
|
||||
code { random_string(8) }
|
||||
joinedwithcode { code }
|
||||
sequence(:name) { |n| "Cool User ##{n}" }
|
||||
sequence(:email) { |n| "cooluser#{n}@cooldomain.com" }
|
||||
joinedwithcode { "qwertyui" }
|
||||
password 'omgwtfbbq'
|
||||
|
||||
transient do
|
||||
validate false
|
||||
end
|
||||
|
||||
# bypass validation of the joinedwithcode
|
||||
to_create { |instance| instance.save(validate: false) }
|
||||
to_create { |instance| instance.save(validate: instance.validate) }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,14 +6,4 @@ RSpec.configure do |config|
|
|||
config.mock_with :rspec do |mocks|
|
||||
mocks.verify_partial_doubles = true
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue