Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix specs for Rails 4 and get Travis CI to pass #12

Merged
merged 1 commit into from
May 8, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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