require 'active_support/core_ext/string/inflections' Then /^I should (?:(not ))?see "([^\"]*)"$/ do |negator, expected_text| step %{the output should #{negator}contain "#{expected_text}"} end Then /^I should (?:(not ))?see like this \/([^\/]*)\/$/ do |negator, expected_text| step %{the output should #{negator}match /#{expected_text}/} end When /^I route "([^\"]*)" to "([^\"]*)"$/ do |path, controller_action_pair| route = %(get "#{path}", :to => "#{controller_action_pair}") routes_file = File.join(rails_root, "config", "routes.rb") File.open(routes_file, "r+") do |file| content = file.read content.gsub!(/^end$/, " #{route}\nend") file.rewind file.write(content) end end When /^I route "([^\"]*)" to resources$/ do |path| route = %(resources :#{path}) routes_file = File.join(rails_root, "config", "routes.rb") File.open(routes_file, "r+") do |file| content = file.read content.gsub!(/^end$/, " #{route}\nend") file.rewind file.write(content) end end Then(/^I should generate in assets folder mongodb_logger files$/) do js_and_css = false Dir["#{LOCAL_RAILS_ROOT}/public/assets/*{.js,.css}"].each do |file| js_and_css = true unless /^mongodb_logger\-([0-9a-z]+)\.(js|css)$/.match(File.basename(file)).nil? end raise "mongodb_logger gem not installed in rails (assets not compiled)" if false == js_and_css end When /^I have copy tests_controller_spec$/ do test_file = File.join(PROJECT_ROOT, 'spec', 'factories', 'config', 'database.yml') target = File.join(rails_root, 'config', 'database.yml') FileUtils.cp(test_file, target) FileUtils.mkdir_p("#{rails_root}/spec") FileUtils.mkdir_p("#{rails_root}/spec/controllers") test_file = File.join(PROJECT_ROOT, 'spec', 'rails_spec', 'spec_helper_rails.rb') target = File.join(rails_root, 'spec', 'spec_helper.rb') FileUtils.cp(test_file, target) test_file = File.join(PROJECT_ROOT, 'spec', 'rails_spec', 'controllers', 'tests_controller_spec_rails.rb') target = File.join(rails_root, 'spec', 'controllers', 'tests_controller_spec.rb') FileUtils.cp(test_file, target) # init log file logfile = File.join(rails_root, 'log', 'test.log') FileUtils.touch(logfile) FileUtils.chmod(0666, logfile) end When /^I have set up tests controllers$/ do definition = <