Giter VIP home page Giter VIP logo

foreigner-matcher's Introduction

yellow5

This project houses a code kata for using a web framework to generate an HTML page with a yellow 5 in it.

The goals of the kata:

  • Try new web frameworks in various languages
  • Keep the problem space simple
  • Deploy it to Heroku
  • Tag history of what was used

Whatever master has will be used to power The Yellow 5!

foreigner-matcher's People

Contributors

iainbeeston avatar woods avatar yellow5 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

foreigner-matcher's Issues

:dependent is required in have_foreign_key_for

Hi,
I've just installed your gem, this is working fine except a minor bug.
In my migration, I have :

add_foreign_key :product_categorizations, :product_categories
add_foreign_key :product_categorizations, :products

In my spec, I have :

  describe ProductCategorization do
        #working
        it { should have_foreign_key_for(:products, :dependent => nil) }
        # NOT working
        it { should have_foreign_key_for(:products) }
  end

Here is the error :

expected [
#<struct Foreigner::ConnectionAdapters::ForeignKeyDefinition from_table="product_categorizations", to_table="product_categories", options={:column=>"product_category_id", :name=>"product_categorizations_product_category_id_fk", :primary_key=>"id", :dependent=>nil}>,
#<struct Foreigner::ConnectionAdapters::ForeignKeyDefinition from_table="product_categorizations", to_table="products", options={:column=>"product_id", :name=>"product_categorizations_product_id_fk", :primary_key=>"id", :dependent=>nil}>
] to include
#<struct Foreigner::ConnectionAdapters::ForeignKeyDefinition from_table="product_categorizations", to_table="products", options={:primary_key=>"id", :column=>"product_id", :name=>"product_categorizations_product_id_fk"}>

Would be nice if :dependent was optional

ActiveRecord::Base#connection deprecated in rails 4

I'm testing a rails 4 project using foreigner-matcher, and I'm seeing the following deprecation warning whenever I call should have_foreign_key_for in my specs:

DEPRECATION WARNING: #connection is deprecated in favour of accessing it via the class.

Matcher generates incorrect foreign key name when a custom column name is set

Given a foreign key defined like:

add_foreign_key(:comments, :posts, column: 'article_id')

I'd expect the following matcher to pass:

comment.should have_foreign_key_for(:post, :column => "article_id")

However, for me it failed, because the fk names generated by foreigner and foreigner matcher were different.

Unfortunately I've since deleted the code I had for this (:cry:), so I'm trying to explain it from memory. I think foreigner matcher was always using the model name to generate the name of the column (so in the example above the fk name would have included "post_id", rather than "article_id").

Sorry I can't be of much more help for this. After I'd realised I no longer had the code in my own project, I thought maybe I could add an example for this case in the specs for foreigner-matcher, but I can't work out where the schema is defined in the test suite (and how I'd test locally). A hope that at least reporting the problem is better than nothing!

foreigner-matcher conflicts with pg-power

I use pg-power for writing specs for functional indices. However, when I have both included:

Failures:

  1) User should have a foreign key for cities
     Failure/Error: it { should have_foreign_key_for :cities }
       expected [#<struct PgPower::ConnectionAdapters::ForeignKeyDefinition from_table="users", to_table="public.cities", options={:column=>"city_id", :name=>"users_city_id_fk", :primary_key=>"id", :dependent=>nil}>] to include #<struct Foreigner::ConnectionAdapters::ForeignKeyDefinition from_table="users", to_table="cities", options={:primary_key=>"id", :column=>"city_id", :name=>"users_city_id_fk", :dependent=>nil}>
     # ./spec/models/user_spec.rb:18:in `block (2 levels) in <top (required)>'

Finished in 8.63 seconds

When I remove pg-power:

Failures:

  1) User should have a unique index on columns lower(username)
     Failure/Error: it { should have_db_index('lower(username)').unique(true) }
       Expected User to have a unique index on columns lower(username) ()
     # ./spec/models/user_spec.rb:15:in `block (2 levels) in <top (required)>'

  2) User should have a unique index on columns lower(email)
     Failure/Error: it { should have_db_index('lower(email)').unique(true) }
       Expected User to have a unique index on columns lower(email) ()
     # ./spec/models/user_spec.rb:16:in `block (2 levels) in <top (required)>'

Finished in 9.68 seconds
88 examples, 2 failures

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.