CSC/ECE 517 Spring 2013/using fixtures with expertiza: Difference between revisions
| Line 30: | Line 30: | ||
YAML originally stood for “Yet Another Markup Language,” the authors now claim that it stands for “YAML Ain’t Markup Language.” | YAML originally stood for “Yet Another Markup Language,” the authors now claim that it stands for “YAML Ain’t Markup Language.” | ||
The YAML specification can be found here. [ | The YAML specification can be found here. [http://yaml.org/spec/current.html#representation] | ||
Basic YAML rules. | Basic YAML rules. | ||
Revision as of 20:22, 5 May 2013
Using Fixtures with Expertiza
Fixtures are a means with Rails to provide test data. Since Expertiza has several different types of ActiveRecord database objects, Fixtures can be a useful way to accomplish testing.
This page will give a brief overview of fixtures in rails and describe how to use them in Expertiza.
Please remember this is a Wiki page - it's not static! If there's something here that's incorrect or out of date, please help keep it up to date.
What is a Fixture?
The term "fixture" comes from the engineering world (see this definition [1]) and represents some device which can be used to test a system without having to use the system extensively. For example consider how one might test a car tire. Instead of driving a car with the tire thousands of miles, an engineer would create a test fixture which spins the tire over various simulated roads thus providing an easier means of comprehensive testing.
A software test fixture is the same concept - how can we set up a test that would normally be complex in a fixed way.
Fixtures in the context of Ruby on Rails represent test database entries. Once the test database is populated, either manual or automated testing can be done with the resultant database. Fixtures allow the tester to create the same data every time which allows for easier reproduction of bugs and quick regression testing.
How do fixtures compare to other test tools?
It's important to make a distinction between fixtures and seeds in Rails.
Fixtures represent test data. Test data will only be populated during testing and not in a production environment.
Seeds represent a base level of data which is used to start up all applications including those in production.
When is it appropriate to use fixtures?
How to use fixtures in Expertiza.
YAML language
YAML originally stood for “Yet Another Markup Language,” the authors now claim that it stands for “YAML Ain’t Markup Language.” The YAML specification can be found here. [2]
Basic YAML rules.
A pound / hash sign (‘#’) is used to begin a comment line. Only spaces, never tabs, may be used to indent YAML files. While this may seem annoying, it’s done to ensure compatibility between different environments which treat tabs in different ways.
An ActiveRecord object is defined with YAML in the following manner: objectName:
Attribute1: value Attribute2: value
…
Attributen: value