File: app_steps.rb

package info (click to toggle)
ruby-email-spec 2.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 980 kB
  • sloc: ruby: 2,420; makefile: 3
file content (58 lines) | stat: -rw-r--r-- 2,261 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
require 'fileutils'

Given /^the (\w+) app is setup with the latest email steps$/ do |app_name|
  app_dir = File.join(root_dir, 'examples',"#{app_name}_root")
  email_specs_path = File.join(app_dir, 'features', 'step_definitions',
                               'email_steps.rb')
  latest_specs_path = File.join(root_dir, 'lib', 'generators', 'email_spec',
                                'steps', 'templates','email_steps.rb')
  FileUtils.rm(email_specs_path) if File.exists?(email_specs_path)
  FileUtils.cp_r(latest_specs_path, email_specs_path)
end

Then /^the (\w+) app should have the email steps in place$/ do |app_name|
  email_specs_path = "#{root_dir}/examples/#{app_name}_root/features/step_definitions/email_steps.rb"
  expect(File.exists?(email_specs_path)).to be true
end

Then /^I should see the following summary report:$/ do |expected_report|
  expect(@output).to include(expected_report)
end

Given /^the (\w+) app is setup with the latest generators$/ do |app_name|
  app_dir= File.join(root_dir,'examples',"#{app_name}_root")
  email_specs_path = File.join(app_dir,'features','step_definitions','email_steps.rb')
  FileUtils.rm(email_specs_path) if File.exists?(email_specs_path)

  if app_name == 'rails4'
    #Testing using the gem
    #make sure we are listed in the bundle
    Dir.chdir(app_dir) do
      output =`bundle list`
      expect(output).to include('email_spec')
    end
  else
    FileUtils.mkdir_p("#{app_dir}/vendor/plugins/email_spec")
    FileUtils.cp_r("#{root_dir}/rails_generators","#{app_dir}/vendor/plugins/email_spec/")
    Dir.chdir(app_dir) do
      system "ruby ./script/generate email_spec"
    end
  end
end

When /^I run "([^\"]*)" in the (\w+) app$/ do |cmd, app_name|
  #cmd.gsub!('cucumber', "#{Cucumber::RUBY_BINARY} #{Cucumber::BINARY}")
  app_path = File.join(root_dir, 'examples', "#{app_name}_root")
  app_specific_gemfile = File.join(app_path,'Gemfile')
  Dir.chdir(app_path) do
    #hack to fight competing bundles (email specs vs rails4_root's
    if File.exists? app_specific_gemfile
      orig_gemfile = ENV['BUNDLE_GEMFILE']
      ENV['BUNDLE_GEMFILE'] = app_specific_gemfile
      @output = `#{cmd}`
      ENV['BUNDLE_GEMFILE'] = orig_gemfile
    else
      @output = `#{cmd}`
    end
  end
end