features/step_definitions/rails_steps.rb in kt-paperclip-5.4.0 vs features/step_definitions/rails_steps.rb in kt-paperclip-6.2.0
- old
+ new
@@ -15,11 +15,11 @@
gem "sqlite3", :platform => [:ruby, :rbx]
gem "activerecord-jdbcsqlite3-adapter", :platform => :jruby
gem "jruby-openssl", :platform => :jruby
gem "capybara"
gem "gherkin"
- gem "aws-sdk", "~> 2.0.0"
+ gem "aws-sdk-s3"
gem "racc", :platform => :rbx
gem "rubysl", :platform => :rbx
"""
And I remove turbolinks
And I comment out lines that contain "action_mailer" in "config/environments/*.rb"
@@ -28,10 +28,18 @@
}
FileUtils.chdir("../../..")
end
+Given /^I generate a "([^"]*)" model:$/ do |model_name|
+ step %[I successfully run `rails generate model #{model_name}`]
+end
+
+Given /^I run a paperclip migration to add a paperclip "([^"]*)" to the "([^"]*)" model$/ do |attachment_name, model_name|
+ step %[I successfully run `rails generate paperclip #{model_name} #{attachment_name}`]
+end
+
Given "I allow the attachment to be submitted" do
cd(".") do
transform_file("app/controllers/users_controller.rb") do |content|
content.gsub("params.require(:user).permit(:name)",
"params.require(:user).permit!")
@@ -82,11 +90,11 @@
end
end
Given "I empty the application.js file" do
cd(".") do
- transform_file("app/assets/javascripts/application.js") do |content|
+ transform_file("app/assets/javascripts/application.js") do |_content|
""
end
end
end
@@ -133,22 +141,36 @@
Given /^I add this snippet to the User model:$/ do |snippet|
file_name = "app/models/user.rb"
cd(".") do
content = File.read(file_name)
- File.open(file_name, 'w') { |f| f << content.sub(/end\Z/, "#{snippet}\nend") }
+ File.open(file_name, "w") { |f| f << content.sub(/end\Z/, "#{snippet}\nend") }
end
end
Given /^I add this snippet to config\/application.rb:$/ do |snippet|
file_name = "config/application.rb"
cd(".") do
content = File.read(file_name)
- File.open(file_name, 'w') {|f| f << content.sub(/class Application < Rails::Application.*$/, "class Application < Rails::Application\n#{snippet}\n")}
+ File.open(file_name, "w") do |f|
+ f << content.sub(/class Application < Rails::Application.*$/,
+ "class Application < Rails::Application\n#{snippet}\n")
+ end
end
end
+Given /^I replace this snippet to app\/views\/layouts\/application.html.erb:$/ do |snippet|
+ file_name = "app/views/layouts/application.html.erb"
+ cd(".") do
+ content = File.read(file_name)
+ File.open(file_name, "w") do |f|
+ f << content.sub(/<%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>$/,
+ "#{snippet}")
+ end
+ end
+end
+
Given /^I start the rails application$/ do
cd(".") do
require "rails"
require "./config/environment"
require "capybara"
@@ -164,11 +186,11 @@
cd(".") do
file = "config/environments/test.rb"
config = IO.read(file)
config.gsub!(%r{^\s*config.cache_classes.*$},
"config.cache_classes = false")
- File.open(file, "w"){|f| f.write(config) }
+ File.open(file, "w") { |f| f.write(config) }
end
end
Then /^the file at "([^"]*)" should be the same as "([^"]*)"$/ do |web_file, path|
expected = IO.read(path)
@@ -184,13 +206,11 @@
When /^I configure the application to use "([^\"]+)"$/ do |gem_name|
append_to_gemfile "gem '#{gem_name}'"
end
When /^I append gems from Appraisal Gemfile$/ do
- File.read(ENV['BUNDLE_GEMFILE']).split(/\n/).each do |line|
- if line =~ /^gem "(?!rails|appraisal)/
- append_to_gemfile line.strip
- end
+ File.read(ENV["BUNDLE_GEMFILE"]).split(/\n/).each do |line|
+ append_to_gemfile line.strip if line =~ /^gem "(?!rails|appraisal)/
end
end
When /^I comment out the gem "([^"]*)" from the Gemfile$/ do |gemname|
comment_out_gem_in_gemfile gemname