Skip to content

Commit

Permalink
Fix specs for Rails 4 and get Travis CI to pass.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
johnnyshields committed Apr 26, 2015
1 parent 8a8343b commit 37ca8ff
Show file tree
Hide file tree
Showing 11 changed files with 66 additions and 17 deletions.
19 changes: 14 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 0 additions & 7 deletions gemfiles/mongoid-master.gemfile

This file was deleted.

1 change: 1 addition & 0 deletions localized_fields.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 8 additions & 0 deletions spec/gemfiles/Gemfile.master
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
source 'http://rubygems.org'

gemspec path: '../../'

gem 'actionpack', '~> 4.2'
gem 'mongoid', github: 'mongoid'

gem 'coveralls', require: false
6 changes: 6 additions & 0 deletions spec/gemfiles/Gemfile.rails32
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
source 'http://rubygems.org'

gemspec path: '../../'

gem 'actionpack', '~> 3.2'
gem 'mongoid', '~> 3.1'
6 changes: 6 additions & 0 deletions spec/gemfiles/Gemfile.rails40
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
source 'http://rubygems.org'

gemspec path: '../../'

gem 'actionpack', '~> 4.0'
gem 'mongoid', '~> 4.0'
6 changes: 6 additions & 0 deletions spec/gemfiles/Gemfile.rails41
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
source 'http://rubygems.org'

gemspec path: '../../'

gem 'actionpack', '~> 4.1'
gem 'mongoid', '~> 4.0'
6 changes: 6 additions & 0 deletions spec/gemfiles/Gemfile.rails42
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
source 'http://rubygems.org'

gemspec path: '../../'

gem 'actionpack', '~> 4.2'
gem 'mongoid', '~> 4.0'
15 changes: 10 additions & 5 deletions spec/localized_fields_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ''
Expand Down Expand Up @@ -48,7 +53,7 @@
%{<div>#{localized_field.text_field(:en).html_safe}</div>}.html_safe
end

expected = %{<div><input id="post_title_translations_en" name="post[title_translations][en]" type="text" /></div>}
expected = %{<div><input type="text" name="post[title_translations][en]" id="post_title_translations_en" /></div>}

expect(output).to eq(expected)
end
Expand Down Expand Up @@ -126,7 +131,7 @@
localized_field.text_field :en
end

expected = %{<input id="post_title_translations_en" name="post[title_translations][en]" type="text" />}
expected = %{<input type="text" name="post[title_translations][en]" id="post_title_translations_en" />}

expect(output).to eq(expected)
end
Expand Down Expand Up @@ -160,7 +165,7 @@
localized_field.text_area :en, value: 'text'
end

expected = %{<textarea id="post_title_translations_en" name="post[title_translations][en]">\n}
expected = %{<textarea name="post[title_translations][en]" id="post_title_translations_en">\n}
expected << %{</textarea>}

expect(output).to eq(expected)
Expand Down Expand Up @@ -202,7 +207,7 @@
localized_field.text_area :en
end

expected = %{<textarea id="post_title_translations_en" name="post[title_translations][en]">\ntitle en}
expected = %{<textarea name="post[title_translations][en]" id="post_title_translations_en">\ntitle en}
expected << %{</textarea>}

expect(output).to eq(expected)
Expand Down
8 changes: 8 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 37ca8ff

Please sign in to comment.