Jasmine Fixtures is an add-on for the behavior-driven development framework, Jasmine. If you’re using Jasmine to test the JavaScript in your Ruby projects and you want to test your DOM and bindings, you can use Jasmine Fixtures.
The gem includes 3 major pieces:
1) The helpers required to loadFixture() within your Jasmine specs
2) JQuery-based matchers to make your life easier
3) RSpec-based methods for creating DOM fixtures
We’re assuming you’re on Rails 2.3.10, you’ve installed rspec, and you’ve installed the jasmine gem and run “script/generate jasmine”.
gem install jasmine-fixtures
script/generate jasmine_fixtures
If you want to use the fixture generator, you need to load jasmine_fixture_generator_methods.rb. If you load everything in your support directory in your spec_helper.rb already, you’re good to go. Otherwise, make sure it’s required with the rest of your requires in spec_helper.rb.
Once you run the generator, take a look at the added files to see how to generate and use the fixtures, especially
spec/controllers/jasmine_fixture_creators.rb
and
spec/javascripts/example-users-spec.js
You haven’t messed with the default Jasmine configuration to load everything in the helpers directory. If you have, make sure you get the jasmine-fixture-*.js files loaded.
All your fixtures should be in /tmp/js_dom_fixtures/FIXTURE_NAME.fixture.html.erb
You can roll your own fixtures and use the above path/naming convention. Also, be sure to wrap all fixtures in a wrapping <div>{Your content goes here}</div> that we ignore.
Alternatively, if you use our RSpec-based methods to generate fixtures (the better way), you need RSpec!
-
Fork the project.
-
Make your feature addition or bug fix.
-
Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
-
Send me a pull request. Bonus points for topic branches.
Copyright © 2010. See LICENSE for details.