Commit 661ce54e949383d665adf857fe98737955ba3cc3

Authored by Antonio Terceiro
1 parent ca8c843a

Moving plugin steps to their own file

features/step_definitions/noosfero_steps.rb
... ... @@ -146,29 +146,6 @@ Given /^the following certifiers$/ do |table|
146 146 end
147 147 end
148 148  
149   -Given /^the following plugin?$/ do |table|
150   - table.hashes.each do |row|
151   - row = row.dup
152   - klass_name = row.delete('klass')
153   - eval("class #{klass_name} < Noosfero::Plugin; end;") unless eval("defined?(#{klass_name})")
154   - end
155   -end
156   -
157   -Given /^the following events of (.+)$/ do |plugin,table|
158   - klass = eval(plugin)
159   - table.hashes.each do |row|
160   - row = row.dup
161   - event = row.delete('event').to_sym
162   - body = eval(row.delete('body'))
163   -
164   - klass.class_eval do
165   - define_method(event) do
166   - body.call
167   - end
168   - end
169   - end
170   -end
171   -
172 149 Given /^I am logged in as "(.+)"$/ do |username|
173 150 visit('/account/logout')
174 151 visit('/account/login')
... ... @@ -207,16 +184,6 @@ Given /^feature &quot;(.+)&quot; is (enabled|disabled) on environment$/ do |feature, statu
207 184 e.save
208 185 end
209 186  
210   -Given /^plugin (.+) is (enabled|disabled) on environment$/ do |plugin, status|
211   - e = Environment.default
212   - if status == 'enabled'
213   - e.enabled_plugins += [plugin]
214   - else
215   - e.enabled_plugins -= [plugin]
216   - end
217   - e.save!
218   -end
219   -
220 187 Given /^organization_approval_method is "(.+)" on environment$/ do |approval_method|
221 188 e = Environment.default
222 189 e.organization_approval_method = approval_method
... ...
features/step_definitions/plugin_steps.rb 0 → 100644
... ... @@ -0,0 +1,32 @@
  1 +Given /^the following plugin?$/ do |table|
  2 + table.hashes.each do |row|
  3 + row = row.dup
  4 + klass_name = row.delete('klass')
  5 + eval("class #{klass_name} < Noosfero::Plugin; end;") unless eval("defined?(#{klass_name})")
  6 + end
  7 +end
  8 +
  9 +Given /^the following events of (.+)$/ do |plugin,table|
  10 + klass = eval(plugin)
  11 + table.hashes.each do |row|
  12 + row = row.dup
  13 + event = row.delete('event').to_sym
  14 + body = eval(row.delete('body'))
  15 +
  16 + klass.class_eval do
  17 + define_method(event) do
  18 + body.call
  19 + end
  20 + end
  21 + end
  22 +end
  23 +
  24 +Given /^plugin (.+) is (enabled|disabled) on environment$/ do |plugin, status|
  25 + e = Environment.default
  26 + if status == 'enabled'
  27 + e.enabled_plugins += [plugin]
  28 + else
  29 + e.enabled_plugins -= [plugin]
  30 + end
  31 + e.save!
  32 +end
... ...