Simple Regular Expression to Replace Non-instantiated Fixtures

Aug 26
09:19 PDT | 0 comments | filed under Rails

Today I wanted to update my unit test to use instantiated fixtures, and I found this regular expression useful for replacing the non-instantiated fixture syntax fixture(:name) with the instantiated syntax @name.

I used the following pattern to find references to the non-instantiated fixtures:

\w+\(:(\w+)\)

I used the following pattern to replace each match with an instantiated fixture.

@$1

Comments

Join the Discussion

URLs and email addresses will be converted to links and line breaks will be converted to paragraphs. Your email address is used only to display your Gravatar, and will never be displayed.

All HTML tags are disabled, except for two exceptions:

To display formatted code, use the <code> tag. By default, code between the tags is interpreted as Ruby, however, you may use the format <code:language> to change the default interpreter. The languages currently supported are Ruby, C, HTML, RHTML and Delphi.

Using the <quote> tag, you may highlight quoted text in a formatted box.

  verification text
  Please type the text you see in the image above:
 
 

About

Archives