Coder Social home page Coder Social logo

ndea / regressor Goto Github PK

View Code? Open in Web Editor NEW
205.0 7.0 34.0 184 KB

Generate specs for your rails application the easy way. Regressor generates model and controller specs based on validations, associations, enums, database, routes, callbacks. Use regressor to capture your rails application behaviour.

License: MIT License

Ruby 96.00% HTML 4.00%
rspec test-automation generator

regressor's People

Contributors

bitdeli-chef avatar buren avatar damirsvrtan avatar krzysiek1507 avatar luizpicolo avatar ndea avatar randikabanura avatar shanehofstetter 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

regressor's Issues

Error when using inside Rails Engine

% bundle exec rails generate regressor:model 1 ↵ ✹ ✭
/Users/plagi/.rvm/gems/ruby-2.1.2@leadhacker/gems/regressor-0.4.0/lib/generators/regressor/model_generator.rb:8:in create_regression_files': undefined methodeager_load!' for nil:NilClass (NoMethodError)
from /Users/plagi/.rvm/gems/ruby-2.1.2@leadhacker/gems/thor-0.19.1/lib/thor/command.rb:27:in run' from /Users/plagi/.rvm/gems/ruby-2.1.2@leadhacker/gems/thor-0.19.1/lib/thor/invocation.rb:126:ininvoke_command'
from /Users/plagi/.rvm/gems/ruby-2.1.2@leadhacker/gems/thor-0.19.1/lib/thor/invocation.rb:133:in block in invoke_all' from /Users/plagi/.rvm/gems/ruby-2.1.2@leadhacker/gems/thor-0.19.1/lib/thor/invocation.rb:133:ineach'
from /Users/plagi/.rvm/gems/ruby-2.1.2@leadhacker/gems/thor-0.19.1/lib/thor/invocation.rb:133:in map' from /Users/plagi/.rvm/gems/ruby-2.1.2@leadhacker/gems/thor-0.19.1/lib/thor/invocation.rb:133:ininvoke_all'
from /Users/plagi/.rvm/gems/ruby-2.1.2@leadhacker/gems/thor-0.19.1/lib/thor/group.rb:232:in dispatch' from /Users/plagi/.rvm/gems/ruby-2.1.2@leadhacker/gems/thor-0.19.1/lib/thor/base.rb:440:instart'
from /Users/plagi/.rvm/gems/ruby-2.1.2@leadhacker/gems/railties-4.1.10/lib/rails/generators.rb:157:in invoke' from /Users/plagi/.rvm/gems/ruby-2.1.2@leadhacker/gems/railties-4.1.10/lib/rails/commands/generate.rb:11:in<top (required)>'
from /Users/plagi/.rvm/gems/ruby-2.1.2@leadhacker/gems/railties-4.1.10/lib/rails/engine/commands.rb:19:in require' from /Users/plagi/.rvm/gems/ruby-2.1.2@leadhacker/gems/railties-4.1.10/lib/rails/engine/commands.rb:19:in<top (required)>'
from bin/rails:12:in require' from bin/rails:12:in

'

Can't put Regressor gem in the development group

I put the regressor gem in the development group in my GemFile but because of the app won't start in test mode due to the initializer. I wrapped the initializer in "if Rails.env.development?" and the test now starts up. not sure if this is the best way.. if so I'll send a long a pull request..

Is Regressor compatible with shoulda-matchers 3.0.x?

I'm getting:

Bundler could not find compatible versions for gem "shoulda-matchers":
In Gemfile:
regressor (~> 0.6.0) ruby depends on
shoulda-matchers (>= 2.7.0, ~> 2.7.0) ruby

shoulda-matchers (~> 3.0.0) ruby

If it is compatible, how should the two gems be specified in my gemfile? If not, any plans for it to be soon?

Thanks,
Tim

Cannot create model regression when using table_name_prefix

ubuntu@localhost:~/app$ RAILS_ENV=test rails g regressor:model
Running via Spring preloader in process 3670
Cannot create model regression for User. Reason Mysql2::Error: Table 'app_test.users' doesn't exist: SHOW KEYS FROM `users`

If you are using a table_name_prefix:

ActiveRecord::Base.table_name_prefix = 'sr_'

Then running regressor will fail since it doesn't take it into account when retrieving the indexes:

module Regressor
  module Model
    module Database
      module Index
        def indices
          ::ActiveRecord::Base.connection.indexes(@model.tableize.gsub("/", "_")).map do |indexes|
            "it { is_expected.to have_db_index #{indexes.columns} }"
          end.flatten.join("\n  ")
        end
      end
    end
  end
end

To fix this the ActiveRecord class method table_namecan be used:

::ActiveRecord::Base.connection.indexes(@model.constantize.table_name).map do |indexes|

Cannot create model regression tests

Hi,

I'm facing the error messages bellow when I try to generate regression tests for my models:

$ RAILS_ENV=test rails generate regressor:model

Cannot create model regression for ApplicationRecord. Reason Could not find table ''
Cannot create model regression for User. Reason Could not find table 'users'
Cannot create model regression for Note. Reason Could not find table 'notes'

Have you seen this error before?

PS: For database I'm using sqlite.

use_before_filter numeric value

After running rails generate regressor:controller, some of the controllers generated a numeric value where there were none. These were only with inherited controllers such as:

Controller:

class User::RolesController < RolesController; end

Spec:

describe User::RolesController do
    it { should use_before_filter(:70303058551480) }

Rails 5 support?

Hi there!

Any plans on supporting Rails 5?

Bundler could not find compatible versions for gem "rails":
  In snapshot (Gemfile.lock):
    rails (= 5.0.0.1)

  In Gemfile:
    rails (= 5.0.0.1)

    regressor (~> 0.6.0) was resolved to 0.6.0, which depends on
      rails (~> 4.0)

Running `bundle update` will rebuild your snapshot from scratch, using only
the gems in your Gemfile, which may resolve the conflict.

"error mongoid [not found]"

Even after updating the gem to the github-hosted version, upon trying to generate any migration, the generator fails with

ruby -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) /opt/code/salescenter/bin/spring rails generate migration SomeMigration -s
       error  mongoid [not found]

It's worth noting that we do not use anything backed with mongoid in our application.

Model tests generated via validation do not respect :if conditions

Given the following model validation:

validates :hair_color, presence: true, if: :has_hair?

... the automatically generated model spec:

it { is_expected.to validate_presence_of :hair_color }

... fails if there is no initial value for has_hair? or if the initialized value of has_hair? is false.

Syntax error in generated controller specs

Hey,

I have encountered a problem using your gem. Controller specs generator created this kind of spec for me:

it { should use_before_filter(:_callback_before_45(self)) }

It raises an error

syntax error, unexpected '(', expecting ')' (SyntaxError)

I'm not sure why. Please advise. :)

Thanks,
Sergey

web-console gem (ships with Rails 4.2) causing filter failures

When using the web-console gem, it apparently uses an automatically-inserted after_filter in every controller. This apparently only happens when the gem is loaded only into the development environment, but loading this particular gem into the development environment makes sense and is indicated as such in the instructions.

Failure/Error: it { should use_after_filter(:inject_console_into_view) }
Expected that MyController would have :inject_console_into_view as a after_filter

explicitly add gem 'shoulda-matchers' to Gemfile

In order to make tests pass I had to explicitly list the shoulda-matchers gem in the Gemfile. Typical errors were something like:

undefined method `belong_to' for #<RSpec::ExampleGroups::Address_2:0x00000102255a00>
expected #<Address:0x00000108e3fd88> to respond to `has_db_column?`

Nice project indeed, thanks for sharing!

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.