Skip to content
New issue

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

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

Already on GitHub? # to your account

patch: automatically create fixutres from templates #14

Closed
drnic opened this issue Jul 18, 2009 · 7 comments
Closed

patch: automatically create fixutres from templates #14

drnic opened this issue Jul 18, 2009 · 7 comments

Comments

@drnic
Copy link

drnic commented Jul 18, 2009

NOTE: For details see commit message in link below

I've ported a gist (http://gist.github.com/148947) from Jonas Nicklas into the blue_ridge + javascript_spec generators.

http://github.com/drnic/blue-ridge/commit/0d425952e40fec35b48e6d2a29c00f92c95b2247 (subsequent commit has patch to README for contributors)

If you're using rspec + pass a relative path to a rails template (e.g. accounts/new.html.rb) then the fixture file will be automatically rendered from the template.

Just run "spec spec/javascripts/accounts_new_spec.rb" (after setting up what data you want for the template).

It's only available for rspec since it uses rspec's view render mechanism.

@drnic
Copy link
Author

drnic commented Jul 19, 2009

Added a css() helper to insert css tags into fixtures, like the require() helper inserts <script> tags

http://github.com/drnic/blue-ridge/commit/e085508f296cf5d55473e769a0ef34a20550b5f8

@drnic
Copy link
Author

drnic commented Jul 20, 2009

The subsequent commit adds css() stub method to test_runner

@dan-manges
Copy link

I'm doing something similar to generate fixtures but with one additional step - I'm also extracting the javascript from the HTML to generate the javascript file that is included in the spec. Doing this removed duplication that I originally had between the javascript specs and the javascript that was on the HTML page. Code: https://gist.github.com/87926f378ef0c6a72b71

@drnic
Copy link
Author

drnic commented Jul 20, 2009

@dan - why did you have JavaScript on the page? :)

@drnic
Copy link
Author

drnic commented Jul 20, 2009

(my smart-arse comment assumed you were pulling inline >script> tags; I noticed you're also pulling >script src=''> tags)

Is it better/different to explicitly require those script assets etc from the top of the xxx_spec.js file?

@dan-manges
Copy link

I don't think it makes much of a difference. I like extracting the Javascript because it removes the duplication. Rather than the spec being responsible for knowing which JS files the page needs, the page has that responsibility, and the spec reads it from the page.

But it's common to combine multiple JS files into one, so the re-declaration of JS dependencies should usually be minimal.

@karnowski
Copy link

This is definitely a direction I want to follow, but I'm a little concerned about requiring Rspec. My goal for the next few months is to allow "plugins" to BlueRidge for letting folks better integrate with Rspec, Cucumber, and even Selenium, without affecting BlueRidge's core functionality. I'm marking this ticket as closed, but will follow up when we get the plugin architecture ready.

This issue was closed.
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

3 participants