GithubHelp home page GithubHelp logo

forgery's People

Contributors

amatsuda avatar anathematic avatar brandonarbini avatar dorian avatar durrantm avatar fallwith avatar graywh avatar holek avatar hujiko avatar ifesdjeen avatar joelparkerhenderson avatar joshuapinter avatar kiela avatar koic avatar lfzawacki avatar lwe avatar maxim avatar mbbertino avatar metavida avatar mhickman84 avatar olleolleolle avatar palmergs avatar rtlechow avatar sj26 avatar skoba avatar spickermann avatar technicalpickles avatar unnu avatar vladson avatar wingrunr21 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

forgery's Issues

Separate Dictionary sets by language

I am looking at Forgery for creating fake data. The data I am creating will not be in English (And not using a western alphabet).

In the short term I will just override the dictionaries in my app but in future it would be great if we could namespace the dictionaries by language and build up a multi-lingual + alphabet forgery library.

uninitialized constant ForgeryRailtie::Rake

On a Rails 3.1 environment and rake 0.9.2 if you try to run rspec spec.


> rspec spec                                                                                                         ruby-1.9.2-p180@tarifador master [c19c69b] modified untracked
/Users/lunks/.rvm/gems/ruby-1.9.2-p180@global/bin/bundle
/Users/lunks/.rvm/gems/ruby-1.9.2-p180@tarifador/gems/forgery-0.3.11/lib/forgery/forgery_railtie.rb:5:in `<class:ForgeryRailtie>': uninitialized constant ForgeryRailtie::Rake (NameError)
    from /Users/lunks/.rvm/gems/ruby-1.9.2-p180@tarifador/gems/forgery-0.3.11/lib/forgery/forgery_railtie.rb:4:in `<top (required)>'
    from /Users/lunks/.rvm/gems/ruby-1.9.2-p180@tarifador/gems/forgery-0.3.11/lib/forgery.rb:35:in `<top (required)>'
    from /Users/lunks/.rvm/gems/ruby-1.9.2-p180@global/gems/bundler-1.0.12/lib/bundler/runtime.rb:68:in `require'
    from /Users/lunks/.rvm/gems/ruby-1.9.2-p180@global/gems/bundler-1.0.12/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
    from /Users/lunks/.rvm/gems/ruby-1.9.2-p180@global/gems/bundler-1.0.12/lib/bundler/runtime.rb:66:in `each'
    from /Users/lunks/.rvm/gems/ruby-1.9.2-p180@global/gems/bundler-1.0.12/lib/bundler/runtime.rb:66:in `block in require'
    from /Users/lunks/.rvm/gems/ruby-1.9.2-p180@global/gems/bundler-1.0.12/lib/bundler/runtime.rb:55:in `each'
    from /Users/lunks/.rvm/gems/ruby-1.9.2-p180@global/gems/bundler-1.0.12/lib/bundler/runtime.rb:55:in `require'
    from /Users/lunks/.rvm/gems/ruby-1.9.2-p180@global/gems/bundler-1.0.12/lib/bundler.rb:120:in `require'
    from /Users/lunks/projects/tarifador/config/application.rb:8:in `<top (required)>'
    from /Users/lunks/projects/tarifador/config/environment.rb:2:in `require'
    from /Users/lunks/projects/tarifador/config/environment.rb:2:in `<top (required)>'
    from /Users/lunks/projects/tarifador/spec/spec_helper.rb:11:in `require'
    from /Users/lunks/projects/tarifador/spec/spec_helper.rb:11:in `<top (required)>'
    from /Users/lunks/projects/tarifador/spec/controllers/accessories_controller_spec.rb:1:in `require'
    from /Users/lunks/projects/tarifador/spec/controllers/accessories_controller_spec.rb:1:in `<top (required)>'
    from /Users/lunks/.rvm/gems/ruby-1.9.2-p180@tarifador/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:419:in `load'
    from /Users/lunks/.rvm/gems/ruby-1.9.2-p180@tarifador/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:419:in `block in load_spec_files'
    from /Users/lunks/.rvm/gems/ruby-1.9.2-p180@tarifador/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:419:in `map'
    from /Users/lunks/.rvm/gems/ruby-1.9.2-p180@tarifador/gems/rspec-core-2.6.4/lib/rspec/core/configuration.rb:419:in `load_spec_files'
    from /Users/lunks/.rvm/gems/ruby-1.9.2-p180@tarifador/gems/rspec-core-2.6.4/lib/rspec/core/command_line.rb:18:in `run'
    from /Users/lunks/.rvm/gems/ruby-1.9.2-p180@tarifador/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:80:in `run_in_process'
    from /Users/lunks/.rvm/gems/ruby-1.9.2-p180@tarifador/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:69:in `run'
    from /Users/lunks/.rvm/gems/ruby-1.9.2-p180@tarifador/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:11:in `block in autorun'

Random generation in numbers

Random number is generated by this code in the 12th line of forgery/extensions/range.rb.

Kernel.rand(last - first + (exclude_end? ? 0 : 1)) + first

Forgery(:basic).number(at_least: 0.3, at_most: 1.2) returns only 0.3, because Kernel.rand only returns integers.
It would be better that returns the float number between 0.3 to 1.2, so I propose to change random number generation under this code and will pull request.

        Random.rand self

RAILS_ROOT Deprecation

RAILS_ROOT is deprecated in Rails 3, Forgery is still using it and causes some deprecation warnings.

Date.date( future:false ) may return dates from the future

Forgery 0.5.0

Date.date( future: false ) may return dates from the future. however past:true seems to work ok.

ruby-1.9.2-p180 :064 > c=0; 100.times { c+=1 if Forgery::Date.date(future:false) > Time.now.to_date  }; c
 => 48 
ruby-1.9.2-p180 :065 > c=0; 100.times { c+=1 if Forgery::Date.date(past:true) > Time.now.to_date  }; c
 => 0 

Reorganization Of Categories

One thing I've noticed about Forgery is how sometimes the categories and methods are unintuitive.

For instance, lets say I want to generate a fake name! My first thought would maybe be in the :basic category? No. Ok, what about :personal? Nope. Finally I find it in :name, an entire class for generated names? Hrm, I think it could do a little better than that! I'm willing to do the work, but I want to discuss the goal.

I have a few suggestions for improving the library:

  • Since all methods are unique, why not have: Forge(:full_name) or Forge(:monetary, :min => 100, :max => 200)
  • Categories should be based on broad concepts, not usage weights: Forgery(:person).full_name or Forgery(:numeric).date
  • Have a way for creating hashes for easy decompiling: Forge.build(:address)[:state] or
Forgery.build(:person)
  #=>
{ 
  :name => {
    :first => "Kurtis",
    :middle => "Lowell",
    :last => "Rainbolt-Greene"
  },
  :address => {
    :street => "718 Mill Street",
    :city => "Springfield",
    :state => {
      :full => "Oregon",
      :short => "OR"
    }
  }
}

and so on.

Any or even all of these used would improve the library significantly, and greatly improve not only my development experience but those I direct to use Forgery.

Fixnum is deprecated

/home/efranco/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/forgery-0.6.0/lib/forgery/forgery/lorem_ipsum.rb:51: warning: constant ::Fixnum is deprecated

Forgery(:internet).email_address - whitespace in email address

This generates invalid emails such as:

"cpalmer@group buy united.biz"
"pday@deliver the deals.biz"
"jlawson@steal the deal.name"
"[email protected]"
"aortiz@all buys.gov"
"kflores@smart canucks.com"
"[email protected]"
"bking@dream ninja.info"
"fdean@toronto deals online.edu"
"jclark@red flag deals.mil"
"thudson@miser mcgee.info"
"[email protected]"
"jholmes@buy battle.edu"
"[email protected]"
"wholmes@toronto deals online.net"
"[email protected]"
"dgeorge@steal the deal.edu"
"wford@great deal of the day.name"
"breynolds@one spout.net"
"[email protected]"
"[email protected]"
"mburns@angry buys.name"
"[email protected]"
"jduncan@angry buys.name"
"[email protected]"
"jarnold@miser mcgee.gov"
"jlewis@sweet ontario deals.biz"
"[email protected]"
"dfisher@angry buys.org"
"[email protected]"

NoMethodError in Forgery::Name.job_title on ruby 3

Calling .sub method on an object of class Forgery::Extensions::String returns String object instead of Forgery::Extensions::String object on ruby 3, which causes NoMethodError: undefined method 'unextend' for "":String when using Forgery::Name.job_title

undefined method `root' for Rails:Module

We're still using the "ancient" Rails 1.2.6 for our app & after upgrading to the newest forgery gem started getting "undefined method `root' for Rails:Module" errors. Turns out this happens when the Rails object is defined, but doesn't respond to the root method.

Forgery::Basic.encrypt not generating unique values

Gem version 0.7.0

I've got a model with an db index that has db unique constraint

create_table "thing", force: :cascade do |t|
  t.string "name"
  t.string "unique_ref"
  t.index ["unique_ref"], name: "index_thing_on_unique_ref", unique: true
end

I've set up my factory with the following. (made sure I didn't make the mistake mentioned #43)

FactoryBot.define do
  factory :thing do
    unique_ref { Forgery::Basic.encrypt }
  end
end

When I go to run my spec

create(:thing, name: 'one')
create(:thing, name: 'two')

I receive the following error

ActiveRecord::RecordNotUnique:
  PG::UniqueViolation: ERROR:  duplicate key value violates unique constraint "index_things_on_unique_ref"
  DETAIL:  Key (unique_ref)=(25357e2fe475921386b7bf09b9804d9e357ad287) already exists.
  : INSERT INTO "things" ("unique_ref", "name", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "id"

Switching from encrypt to password things seem to work as expected and generate unique values.

FactoryBot.define do
  factory :thing do
    unique_ref { Forgery::Basic.password }
  end
end

Forgery::Address.phone returns invalid phone numbers

While the #-(###)###-#### format is simple enough, it creates phone numbers which are not E164 compliant.

This is an issue if you want to introduce phone number plausibility checking from Phony into your model and suddenly all your tests fail randomly.

Maybe the Phony guys could help with a generator? It seems nontrivial. For now I use a preset country code and just generate the last 7 digits of the phone number randomly.

Invalid load path

My setup: ruby 1.9.2, rails 3.0.0rc, datamapper (dm-rails 1.0.3).

When the load path gets built, Rails.root is not yet set by rails. Therefore, it generates a wrong load path for lib/forgery...
I can get around it by calling Forgery.load_from! "#{Rails.root}/lib/forgery" right before I use my custom forgeries.

WARNING: Global access to Rake DSL methods is deprecated.

Hi SevenWire,

Seems like Rake::DSL has to be included explicitly to use rake tasks from now on. These are the warnings that are dumped when using Rails 3.1.rc4

WARNING: Global access to Rake DSL methods is deprecated. Please include
... Rake::DSL into classes and modules which use the Rake DSL methods.
WARNING: DSL method Class#namespace called at /Users/akashmanohar/.rvm/gems/ruby-1.9.2-p180@rails31/gems/forgery-0.3.10/lib/forgery/forgery_railtie.rb:10:in block in <class:ForgeryRailtie>' WARNING: DSL method Class#desc called at /Users/akashmanohar/.rvm/gems/ruby-1.9.2-p180@rails31/gems/forgery-0.3.10/lib/forgery/forgery_railtie.rb:24:inblock (2 levels) in class:ForgeryRailtie'
WARNING: DSL method Class#task called at /Users/akashmanohar/.rvm/gems/ruby-1.9.2-p180@rails31/gems/forgery-0.3.10/lib/forgery/forgery_railtie.rb:25:in `block (2 levels) in class:ForgeryRailtie'

Akash

Can't generate more unique values for Sham.__________

Really great lib, but this error is terribly annoying. It only appears for some values (e.g. Sham.gender defined with returning either "m" or "f").

"Can't generate more unique values for Sham.xxx"

where xxx is a defined sham. I consider this more of a bug than a feature...or the documentation missed to mention something.

Lorem Ipsum Randomness

The Lorem Ipsum functions dont seem to be using any randomness. I'll take a crack at fixing them, those they don't seem to follow the same general idea the other generators use?

Extend formats to allow alpha character

Should allow both upper and lower in the form of:

A โ€“ Upper a โ€“ Lower

So, using it with the number format, you would do:

aaaAAA###

Which might generate:

qweRTY123

undefined method `random' for 0..932:Range

Forgery::LoremIpsum.words(1,:random => true) raises that error. The trace:

undefined method `random' for 0..932:Range
/home/atd/.rvm/gems/ruby-1.9.2-p180/gems/forgery-0.4.1/lib/forgery/forgery/lorem_ipsum.rb:102:in `range_from_quantity'
/home/atd/.rvm/gems/ruby-1.9.2-p180/gems/forgery-0.4.1/lib/forgery/forgery/lorem_ipsum.rb:43:in `words'
/home/atd/dev/social_stream-base/lib/tasks/db/populate.rake:36:in `block in set_tags'
...

forgery not producing unique values

When used with FactoryGirl, i.e.

factory :user do
   email Forgery(:internet).email_address
end

and you attempt to create records:

5.times { FactoryGirl.create(:user) }

will return five records with the same e-mail address. This creates a problem if the model validates the uniqueness of the e-mail address.

Forgery + Factory = nonrandom data?

Hi, I am using Forgery with factory_girl.
I have one trouble though - when I create Factory like so
Factory.define :client do |f|
f.first_name Forgery(:name).first_name
end
all objects that are created with this factory have the same first name!
Does anybody have an idea on this?
Thanks.

problem using monetary

Works in 0.3.12, breaks in 0.4.2.

Forgery(:monetary).money

     NoMethodError:
       undefined method `random' for 0..1000:Range

Links to Nowhere in README

Well, not quite nowhere. There are many self-referencing links caused by lonely square brackets (e.g. "many more!")

Hopefully no one's already caught in an infinite loop. ;D

Overwrite core dictionaries?

Is there a way to overwrite the core dictionaries included with forgery?

For instance, I don't want to use any of the male_first_names...I'd like to use only the ones I supply.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.