Skip to content
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 · Fixed by #1718
Closed

how to add testing #1712

Skeyelab opened this issue Jul 9, 2014 · 6 comments · Fixed by #1718
Milestone

Comments

@Skeyelab
Copy link

Skeyelab commented Jul 9, 2014

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

@mitchellhenke
Copy link

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
Copy link
Author

Skeyelab commented Jul 9, 2014

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

@mitchellhenke
Copy link

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

@namusyaka
Copy link
Contributor

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
Copy link

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

@namusyaka
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants