Single Fixtures declaration for Selenium on Rails

When testing out a complex website, replicating the |open|/selenium/setup?fixtures=x| line would be painful!

So, Add a const at the beginning of the setup_controller in Selenium Plugin at
./vendor/plugins/selenium_on_rails/lib/controllers/selenium_controller.rb:

[ruby]
MY_FIXTURES = “table_a, table_b, table_c”
[/ruby]

Also alter #setup as so :
[ruby]
def setup
unless params.has_key? :keep_session
reset_session
@session_wiped = true
end
if params[:fixtures] == “all“
fixtures = PM_FIXTURES
end
fixtures ||= params[:fixtures].to_s
@loaded_fixtures = load_fixtures fixtures
render :file => view_path(‘setup.rhtml’), :layout => layout_path
end
[/ruby]

New lines are 6-9, and the change on 10 from referencing params[] to the local var fixtures.

Then, use this in the selenese script :

|open|/selenium/setup?fixtures=all|

Isn’t that beautiful!??

Now I don’t have to endure copy-paste-age-break hell on my fixtures configuration.

Ahhh, Ruby is so nice!

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

Gravatar
WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s