Commit f29f96b2 by Jon Yurek

Running Rails 4 specs and features

parent 3b40121b
......@@ -12,3 +12,8 @@ appraise "3.2" do
gem "rails", "~> 3.2.6"
gem "paperclip", :path => "../"
end
appraise "4.0" do
gem "rails", "~> 4.0.0"
gem "paperclip", :path => "../"
end
source "https://rubygems.org"
gemspec
gem "jruby-openssl", :platform => :jruby
gem "activerecord-jdbcsqlite3-adapter", :platform => :jruby
gem "sqlite3", :platform => :ruby
......@@ -7,6 +7,7 @@ Feature: Rails integration
And I run a migration
And I update my new user view to include the file upload field
And I update my user view to include the attachment
And I allow the attachment to be submitted
Scenario: Configure defaults for all attachments through Railtie
Given I add this snippet to config/application.rb:
......
......@@ -16,6 +16,7 @@ Given /^I generate a new rails application$/ do
gem "aws-sdk"
"""
And I remove turbolinks if it exists
And I empty the application.js file if it exists
And I configure the application to use "paperclip" from this project
And I reset Bundler environment variable
And I successfully run `bundle install --local`
......@@ -30,23 +31,30 @@ Given "I fix the application.rb for 3.0.12" do
end
end
def transform_file(filename)
content = File.read(filename)
File.open(filename, "w") do |f|
content = yield(content)
f.write(content)
Given "I allow the attachment to be submitted" do
in_current_dir do
transform_file("app/controllers/users_controller.rb") do |content|
content.gsub("params.require(:user).permit(:name)",
"params.require(:user).permit!")
end
end
end
Given "I remove turbolinks if it exists" do
if framework_major_version >= 4
in_current_dir do
transform_file("app/assets/javascripts/application.js") do |content|
content.gsub("//= require turbolinks", "")
end
transform_file("app/views/layouts/application.html.erb") do |content|
content.gsub(', "data-turbolinks-track" => true', "")
end
in_current_dir do
transform_file("app/assets/javascripts/application.js") do |content|
content.gsub("//= require turbolinks", "")
end
transform_file("app/views/layouts/application.html.erb") do |content|
content.gsub(', "data-turbolinks-track" => true', "")
end
end
end
Given "I empty the application.js file if it exists" do
in_current_dir do
transform_file("app/assets/javascripts/application.js") do |content|
""
end
end
end
......@@ -132,11 +140,11 @@ end
Then /^the file at "([^"]*)" should be the same as "([^"]*)"$/ do |web_file, path|
expected = IO.read(path)
actual = if web_file.match %r{^https?://}
Net::HTTP.get(URI.parse(web_file))
else
visit(web_file)
page.source
end
Net::HTTP.get(URI.parse(web_file))
else
visit(web_file)
page.source
end
actual.force_encoding("UTF-8") if actual.respond_to?(:force_encoding)
actual.should == expected
end
......@@ -167,3 +175,13 @@ Given /^I am using Rails newer than ([\d\.]+)$/ do |version|
pending "Not supported in Rails < #{version}"
end
end
def transform_file(filename)
if File.exists?(filename)
content = File.read(filename)
File.open(filename, "w") do |f|
content = yield(content)
f.write(content)
end
end
end
# This file was generated by Appraisal
source "https://rubygems.org"
gem "jruby-openssl", :platform=>:jruby
gem "activerecord-jdbcsqlite3-adapter", :platform=>:jruby
gem "sqlite3", :platform=>:ruby
gem "rails", "~> 4.0.0"
gem "paperclip", :path=>"../"
gemspec :path=>"../"
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment