features/step_definitions/rails_steps.rb in paperclip-2.7.5 vs features/step_definitions/rails_steps.rb in paperclip-2.8.0
- old
+ new
@@ -69,11 +69,15 @@
"""
}
end
Given /^I add this snippet to the User model:$/ do |snippet|
- insert_snippet_into_file("app/models/user.rb", snippet)
+ file_name = "app/models/user.rb"
+ in_current_dir do
+ content = File.read(file_name)
+ File.open(file_name, 'w') { |f| f << content.sub(/end\Z/, "#{snippet}\nend") }
+ end
end
Given /^I start the rails application$/ do
in_current_dir do
require "./config/environment"
@@ -107,16 +111,10 @@
File.open("Gemfile", "w") { |file| file.write(gemfile_template.sub(/RAILS_VERSION/, framework_version)) }
end
end
end
-Given /^I add attr_accessible to a Rails 3.2 application$/ do
- if framework_version?("3.2")
- insert_snippet_into_file("app/models/user.rb", "attr_accessible :attachment\n")
- end
-end
-
Given /^I add the paperclip rake task to a Rails 2.3 application$/ do
if framework_version?("2.3")
require 'fileutils'
source = File.expand_path('lib/tasks/paperclip.rake')
destination = in_current_dir { File.expand_path("lib/tasks") }
@@ -157,17 +155,9 @@
When /^I comment out the gem "([^"]*)" from the Gemfile$/ do |gemname|
comment_out_gem_in_gemfile gemname
end
module FileHelpers
- def insert_snippet_into_file(file_name, snippet)
- in_current_dir do
- content = File.read(file_name)
- File.open(file_name, 'w') { |f| f << content.sub(/end\Z/, "#{snippet}\nend") }
- content = File.read(file_name)
- end
- end
-
def append_to(path, contents)
in_current_dir do
File.open(path, "a") do |file|
file.puts
file.puts contents