New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to add testing #1712

Closed
Skeyelab opened this Issue Jul 9, 2014 · 6 comments

Comments

Projects
None yet
3 participants
@Skeyelab

Skeyelab commented Jul 9, 2014

I created a project without a testing framework. What is the best way to add testing now?

@mitchellhenke

This comment has been minimized.

Show comment
Hide comment
@mitchellhenke

mitchellhenke Jul 9, 2014

I'm not sure if there's a more official way, but you can edit the .components file in the project to set the testing framework (bacon, shoulda, cucumber, riot, rspec, minitest, steak).

Example:

:orm: sequel
:test: rspec
# etc.

Then you can run the generators and the test files should be created for you from then on.

mitchellhenke commented Jul 9, 2014

I'm not sure if there's a more official way, but you can edit the .components file in the project to set the testing framework (bacon, shoulda, cucumber, riot, rspec, minitest, steak).

Example:

:orm: sequel
:test: rspec
# etc.

Then you can run the generators and the test files should be created for you from then on.

@Skeyelab

This comment has been minimized.

Show comment
Hide comment
@Skeyelab

Skeyelab Jul 9, 2014

thanks. I'll try that. Any advice for already existing models? Can I generate just the tests?

Skeyelab commented Jul 9, 2014

thanks. I'll try that. Any advice for already existing models? Can I generate just the tests?

@mitchellhenke

This comment has been minimized.

Show comment
Hide comment
@mitchellhenke

mitchellhenke Jul 10, 2014

Re-running the generate command for the models will create the test files.

mitchellhenke commented Jul 10, 2014

Re-running the generate command for the models will create the test files.

@namusyaka

This comment has been minimized.

Show comment
Hide comment
@namusyaka

namusyaka Jul 10, 2014

Member

Padrino provides the component generator, so please try this.
padrino g component --test=rspec

Padrino does not provide the way for already existing model.
The model generator will abort if model already exists.
By using a runner, it is possible to create a test file...

# scripts/sample.rb
require 'padrino-gen/generators/components/tests/rspec' #<-- your test component name

def generate_model_test(name)
  rspec_contents = RSPEC_MODEL_TEST.gsub(/!NAME!/, name.to_s.underscore.camelize).gsub(/!DNAME!/, name.to_s.underscore)
  model_spec_path = File.join('spec','app','models',"#{name.to_s.underscore}_spec.rb")
  create_file model_spec_path, rspec_contents, :skip => true
end

generate_model_test(:model_name)

and
padrino r scripts/sample.rb

@padrino/core-members I think the model generator should provide :force option for use in this case. What do you think?

Member

namusyaka commented Jul 10, 2014

Padrino provides the component generator, so please try this.
padrino g component --test=rspec

Padrino does not provide the way for already existing model.
The model generator will abort if model already exists.
By using a runner, it is possible to create a test file...

# scripts/sample.rb
require 'padrino-gen/generators/components/tests/rspec' #<-- your test component name

def generate_model_test(name)
  rspec_contents = RSPEC_MODEL_TEST.gsub(/!NAME!/, name.to_s.underscore.camelize).gsub(/!DNAME!/, name.to_s.underscore)
  model_spec_path = File.join('spec','app','models',"#{name.to_s.underscore}_spec.rb")
  create_file model_spec_path, rspec_contents, :skip => true
end

generate_model_test(:model_name)

and
padrino r scripts/sample.rb

@padrino/core-members I think the model generator should provide :force option for use in this case. What do you think?

@mitchellhenke

This comment has been minimized.

Show comment
Hide comment
@mitchellhenke

mitchellhenke Jul 10, 2014

Oops, sorry, I was thinking of the controller generator which does allow it.

mitchellhenke commented Jul 10, 2014

Oops, sorry, I was thinking of the controller generator which does allow it.

@namusyaka

This comment has been minimized.

Show comment
Hide comment
@namusyaka

namusyaka Jul 12, 2014

Member

@Skeyelab The :force option will be resolved your problem.
Could you please confirm?

Member

namusyaka commented Jul 12, 2014

@Skeyelab The :force option will be resolved your problem.
Could you please confirm?

@ujifgc ujifgc closed this in #1718 Jul 15, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment