From 661ce54e949383d665adf857fe98737955ba3cc3 Mon Sep 17 00:00:00 2001 From: Antonio Terceiro Date: Tue, 4 Jan 2011 16:42:56 -0300 Subject: [PATCH] Moving plugin steps to their own file --- features/step_definitions/noosfero_steps.rb | 33 --------------------------------- features/step_definitions/plugin_steps.rb | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 33 deletions(-) create mode 100644 features/step_definitions/plugin_steps.rb diff --git a/features/step_definitions/noosfero_steps.rb b/features/step_definitions/noosfero_steps.rb index 35bcb06..f5404f1 100644 --- a/features/step_definitions/noosfero_steps.rb +++ b/features/step_definitions/noosfero_steps.rb @@ -146,29 +146,6 @@ Given /^the following certifiers$/ do |table| end end -Given /^the following plugin?$/ do |table| - table.hashes.each do |row| - row = row.dup - klass_name = row.delete('klass') - eval("class #{klass_name} < Noosfero::Plugin; end;") unless eval("defined?(#{klass_name})") - end -end - -Given /^the following events of (.+)$/ do |plugin,table| - klass = eval(plugin) - table.hashes.each do |row| - row = row.dup - event = row.delete('event').to_sym - body = eval(row.delete('body')) - - klass.class_eval do - define_method(event) do - body.call - end - end - end -end - Given /^I am logged in as "(.+)"$/ do |username| visit('/account/logout') visit('/account/login') @@ -207,16 +184,6 @@ Given /^feature "(.+)" is (enabled|disabled) on environment$/ do |feature, statu e.save end -Given /^plugin (.+) is (enabled|disabled) on environment$/ do |plugin, status| - e = Environment.default - if status == 'enabled' - e.enabled_plugins += [plugin] - else - e.enabled_plugins -= [plugin] - end - e.save! -end - Given /^organization_approval_method is "(.+)" on environment$/ do |approval_method| e = Environment.default e.organization_approval_method = approval_method diff --git a/features/step_definitions/plugin_steps.rb b/features/step_definitions/plugin_steps.rb new file mode 100644 index 0000000..1052822 --- /dev/null +++ b/features/step_definitions/plugin_steps.rb @@ -0,0 +1,32 @@ +Given /^the following plugin?$/ do |table| + table.hashes.each do |row| + row = row.dup + klass_name = row.delete('klass') + eval("class #{klass_name} < Noosfero::Plugin; end;") unless eval("defined?(#{klass_name})") + end +end + +Given /^the following events of (.+)$/ do |plugin,table| + klass = eval(plugin) + table.hashes.each do |row| + row = row.dup + event = row.delete('event').to_sym + body = eval(row.delete('body')) + + klass.class_eval do + define_method(event) do + body.call + end + end + end +end + +Given /^plugin (.+) is (enabled|disabled) on environment$/ do |plugin, status| + e = Environment.default + if status == 'enabled' + e.enabled_plugins += [plugin] + else + e.enabled_plugins -= [plugin] + end + e.save! +end -- libgit2 0.21.2