Developer Tips: Scenarios and Datasets

Posted by Jim Gay on Tuesday, March 10, 2009 | |

You may have the need to update specs for your extension if you had been using the Scenarios plugin that came with Radiant.

Recent changes to Radiant moved from the Scenarios plugin to the new rewrite as the Dataset plugin. For great information about the thinking behind the move to Datasets, check out John Long’s post.

If you’re working with your extension and your specs no longer run because of an error like:

../../activesupport/lib/active_support/dependencies.rb:279:in `load_missing_constant': uninitialized constant Scenario (NameError)

That means that you’ll either need to add back the Scenarios plugin, or just alter some code to use Datasets.

Your existing spec/spec_helper.rb might have something like

if File.directory?(File.dirname(__FILE__) + "/scenarios")
  Scenario.load_paths.unshift File.dirname(__FILE__) + "/scenarios"
end

You’ll need to change that to

Dataset::Resolver.default << (File.dirname(__FILE__) + "/datasets")

And your specs load your scenarios with scenario :users. You’ll just need to change that to dataset :users. Here’s an example from the site_watcher extension