From 37ca8ff78abaa5f67a76a6d3cffd0d477a4c6e4e Mon Sep 17 00:00:00 2001 From: Johnny Shields Date: Sun, 26 Apr 2015 18:48:29 +0900 Subject: [PATCH] Fix specs for Rails 4 and get Travis CI to pass. I've now added gemfiles for each of Rails versions 3.2, 4.0, 4.1, 4.2. In addition, there's a "master" version but Mongoid currently conflicts so it's set to Rails 4.2 and Mongoid master. I've moved /gemfiles to be /spec/gemfiles. Rails 3 specs are marked as "allowed failures" since the format has changed entirely. I've investigated and decided that it's not worth the effort to make both Rails 3 and 4 pass, but at least I've gotten to the point where the Rails 3 env build correctly and we can see the individual specs fail due to format change. I've also added coveralls as a dev dependency, otherwise Travis fails. Lastly, Travis CI does not require service: mongodb to pass hence I've removed it. --- .travis.yml | 19 ++++++++++++++----- CHANGELOG.md | 1 + gemfiles/mongoid-master.gemfile | 7 ------- localized_fields.gemspec | 1 + spec/gemfiles/Gemfile.master | 8 ++++++++ spec/gemfiles/Gemfile.rails32 | 6 ++++++ spec/gemfiles/Gemfile.rails40 | 6 ++++++ spec/gemfiles/Gemfile.rails41 | 6 ++++++ spec/gemfiles/Gemfile.rails42 | 6 ++++++ spec/localized_fields_spec.rb | 15 ++++++++++----- spec/spec_helper.rb | 8 ++++++++ 11 files changed, 66 insertions(+), 17 deletions(-) delete mode 100644 gemfiles/mongoid-master.gemfile create mode 100644 spec/gemfiles/Gemfile.master create mode 100644 spec/gemfiles/Gemfile.rails32 create mode 100644 spec/gemfiles/Gemfile.rails40 create mode 100644 spec/gemfiles/Gemfile.rails41 create mode 100644 spec/gemfiles/Gemfile.rails42 diff --git a/.travis.yml b/.travis.yml index 0513fd5..136e14e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,16 +3,25 @@ language: ruby rvm: - 1.9.3 - 2.0.0 - - 2.1.0 - -services: mongodb + - 2.1.6 + - 2.2.2 before_install: gem install bundler --pre gemfile: - - Gemfile - - gemfiles/mongoid-master.gemfile + - spec/gemfiles/Gemfile.master + - spec/gemfiles/Gemfile.rails32 + - spec/gemfiles/Gemfile.rails40 + - spec/gemfiles/Gemfile.rails41 + - spec/gemfiles/Gemfile.rails42 notifications: email: - tiagogodinho3@gmail.com + +matrix: + exclude: + - rvm: 2.2.2 + gemfile: spec/gemfiles/Gemfile.rails32 + allow_failures: + - gemfile: spec/gemfiles/Gemfile.rails32 diff --git a/CHANGELOG.md b/CHANGELOG.md index d3f92b5..ec62cda 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ### Improvements * Added ability to specify the label text. ([@xavier][]) commit: [7222f15][] +* Fix Travis CI for Rails 4. ([@johnnyshields][]) ## 0.2.0 - June 15, 2012 diff --git a/gemfiles/mongoid-master.gemfile b/gemfiles/mongoid-master.gemfile deleted file mode 100644 index b9b6abd..0000000 --- a/gemfiles/mongoid-master.gemfile +++ /dev/null @@ -1,7 +0,0 @@ -source 'https://rubygems.org' - -gem 'mongoid', github: 'mongoid/mongoid' - -gem 'coveralls', require: false - -gemspec path: '../' diff --git a/localized_fields.gemspec b/localized_fields.gemspec index e738c3c..4a37265 100644 --- a/localized_fields.gemspec +++ b/localized_fields.gemspec @@ -20,4 +20,5 @@ Gem::Specification.new do |gem| gem.add_development_dependency 'rake', '~> 10.1.0' gem.add_development_dependency 'rspec', '~> 2.14.0' + gem.add_development_dependency 'coveralls' end diff --git a/spec/gemfiles/Gemfile.master b/spec/gemfiles/Gemfile.master new file mode 100644 index 0000000..f7374dc --- /dev/null +++ b/spec/gemfiles/Gemfile.master @@ -0,0 +1,8 @@ +source 'http://rubygems.org' + +gemspec path: '../../' + +gem 'actionpack', '~> 4.2' +gem 'mongoid', github: 'mongoid' + +gem 'coveralls', require: false diff --git a/spec/gemfiles/Gemfile.rails32 b/spec/gemfiles/Gemfile.rails32 new file mode 100644 index 0000000..c37162d --- /dev/null +++ b/spec/gemfiles/Gemfile.rails32 @@ -0,0 +1,6 @@ +source 'http://rubygems.org' + +gemspec path: '../../' + +gem 'actionpack', '~> 3.2' +gem 'mongoid', '~> 3.1' diff --git a/spec/gemfiles/Gemfile.rails40 b/spec/gemfiles/Gemfile.rails40 new file mode 100644 index 0000000..1a7e24b --- /dev/null +++ b/spec/gemfiles/Gemfile.rails40 @@ -0,0 +1,6 @@ +source 'http://rubygems.org' + +gemspec path: '../../' + +gem 'actionpack', '~> 4.0' +gem 'mongoid', '~> 4.0' diff --git a/spec/gemfiles/Gemfile.rails41 b/spec/gemfiles/Gemfile.rails41 new file mode 100644 index 0000000..b7fdfd9 --- /dev/null +++ b/spec/gemfiles/Gemfile.rails41 @@ -0,0 +1,6 @@ +source 'http://rubygems.org' + +gemspec path: '../../' + +gem 'actionpack', '~> 4.1' +gem 'mongoid', '~> 4.0' diff --git a/spec/gemfiles/Gemfile.rails42 b/spec/gemfiles/Gemfile.rails42 new file mode 100644 index 0000000..71d813a --- /dev/null +++ b/spec/gemfiles/Gemfile.rails42 @@ -0,0 +1,6 @@ +source 'http://rubygems.org' + +gemspec path: '../../' + +gem 'actionpack', '~> 4.2' +gem 'mongoid', '~> 4.0' diff --git a/spec/localized_fields_spec.rb b/spec/localized_fields_spec.rb index d8f32e0..f333487 100644 --- a/spec/localized_fields_spec.rb +++ b/spec/localized_fields_spec.rb @@ -3,7 +3,12 @@ describe 'LocalizedFields' do let(:post) { Post.new } let(:template) { ActionView::Base.new } - let(:builder) { ActionView::Helpers::FormBuilder.new(:post, post, template, {}) } + let(:builder) { ActionView::Helpers::FormBuilder.new(*builder_args) } + let(:builder_args) do + args = [:post, post, template, {}] + args += [proc {}] if rails3? + args + end before do template.output_buffer = '' @@ -48,7 +53,7 @@ %{
#{localized_field.text_field(:en).html_safe}
}.html_safe end - expected = %{
} + expected = %{
} expect(output).to eq(expected) end @@ -126,7 +131,7 @@ localized_field.text_field :en end - expected = %{} + expected = %{} expect(output).to eq(expected) end @@ -160,7 +165,7 @@ localized_field.text_area :en, value: 'text' end - expected = %{} expect(output).to eq(expected) @@ -202,7 +207,7 @@ localized_field.text_area :en end - expected = %{} expect(output).to eq(expected) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index ce7c732..47e059f 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -4,3 +4,11 @@ require 'localized_fields' Dir[File.expand_path(File.join(File.dirname(__FILE__), 'support', '**', '*.rb'))].each { |f| require f } + +def rails3? + !defined?(ActionView::VERSION::MAJOR) +end + +def rails4? + ActionView::VERSION::MAJOR == 4 +end