Jasmine Fixture Builder
Jasmine Fixture Builder (or "JazzFix" for short) allows you to generate fixtures for your jasmine specs based on the DOM your application renders. Don't let your jasmine fixtures get stale and lie to you - use JazzFix to keep your application's DOM and jasmine specs in sync!
JazzFix works alongside the use of the following:
JazzFix leverages the fixture loading ability of jasmine-jquery along with the clean DOM rendering that rspec-rails view specs provide. JazzFix owes a debt of gratitude to the work and subsequent experience report from JB Steadman.
Add the following gems to application's gem file, grouped to development/test:
(rspec-rails is a dependency of jasmine_fixture_builder, so there is no need to explicitly add it to your gem file as a dependency)
Run the following:
rails generate rspec:install
rails generate jasmine:install
assets/jasmine-jquery.js underneath the
###Create a fixture with RSpec:
Create a view spec for a particular view you want to create a fixture from. Render the view, then save the rendered html to a fixture with the provided
describe 'widgets/index' do it 'creates fixture' do render save_fixture(rendered, 'widgets_index.html') end end
save_fixture takes 2 arguments: the markup as its first, the name to ascribe the fixture to as its second.
This saves the markup from the view into a file living at
###Use that fixture in your Jasmine test:
loadFixture method from jasmine-jquery to load up the fixture for use in your test.
loadFixture inserts the markup from your fixture into a container
After checking out the repo, run
bin/setup to install dependencies. Then, run
bin/console for an interactive prompt that will allow you to experiment.
- Fork it ( https://github.com/[my-github-username]/jasmine_fixture_builder/fork )
- Create your feature branch (
git checkout -b my-new-feature)
- Commit your changes (
git commit -am 'Add some feature')
- Push to the branch (
git push origin my-new-feature)
- Create a new Pull Request