utf8_enforcer_workaround 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/Appraisals CHANGED
@@ -1,5 +1,10 @@
1
1
  #-*- ruby -*-
2
- appraise "Rails32" do
2
+ appraise "rails3.2" do
3
3
  gem "rails", "~> 3.2.0"
4
4
  gem "utf8_enforcer_workaround", :path => "../"
5
5
  end
6
+
7
+ appraise "rails4.0" do
8
+ gem "rails", "~> 4.0.0"
9
+ gem "utf8_enforcer_workaround", :path => "../"
10
+ end
data/README.md CHANGED
@@ -8,7 +8,12 @@ browsers.
8
8
  Requirements
9
9
  ------------
10
10
 
11
- `utf8_enforcer_workaround` depends on Rails 3.2 and `browser`
11
+ `utf8_enforcer_workaround` depends on Rails and `browser`
12
+
13
+ ### Supported Rails versions
14
+
15
+ * Rails 3.x
16
+ * Rails 4.x
12
17
 
13
18
  Installation
14
19
  ------------
@@ -53,6 +58,6 @@ Contributing
53
58
  Copyright
54
59
  ---------
55
60
 
56
- Copyright (c) 2012 Jarl Friis. See LICENSE.txt for
61
+ Copyright (c) 2013 Jarl Friis. See LICENSE.txt for
57
62
  further details.
58
63
 
@@ -8,5 +8,6 @@ Feature: Default browsers does not see a utf8 param.
8
8
 
9
9
  Scenario:
10
10
  Given I start the rails application
11
+ And I use a compliant browser
11
12
  When I go to the new user page
12
13
  Then there is no utf8 input tag
@@ -1,16 +1,8 @@
1
1
  Given /^I generate a new rails application$/ do
2
2
  steps %{
3
- When I run `bundle exec #{new_application_command} #{APP_NAME}`
3
+ When I run `bundle exec #{new_application_command(APP_NAME)} `
4
4
  And I cd to "#{APP_NAME}"
5
5
  And I turn off class caching
6
- And I write to "Gemfile" with:
7
- """
8
- source "http://rubygems.org"
9
- gem "rails", "#{framework_version}"
10
- gem "sqlite3"
11
- gem "capybara"
12
- gem "gherkin"
13
- """
14
6
  And I configure the application to use "utf8_enforcer_workaround" from this project
15
7
  And I reset Bundler environment variable
16
8
  And I successfully run `bundle install --local`
@@ -147,7 +139,6 @@ end
147
139
 
148
140
  When /^I configure the application to use "([^\"]+)" from this project$/ do |name|
149
141
  append_to_gemfile "gem '#{name}', :path => '#{PROJECT_ROOT}'"
150
- steps %{And I run `bundle install --local`}
151
142
  end
152
143
 
153
144
  When /^I configure the application to use "([^\"]+)"$/ do |gem_name|
@@ -10,6 +10,10 @@ Then /there is (a|no) utf8 input tag/ do |exists|
10
10
  end
11
11
  end
12
12
 
13
- Then /I use Internet Explorer/ do
14
- set_headers({'HTTP_USER_AGENT'=> "Mozilla/5.0 (compatible; MSIE 6.0; Windows NT 5.1)"})
13
+ Given /I use Internet Explorer/ do
14
+ Capybara.current_driver = :rack_test_non_compliant
15
+ end
16
+
17
+ Given /I use a compliant browser/ do
18
+ Capybara.current_driver = :rack_test_non_compliant
15
19
  end
@@ -18,3 +18,18 @@ end
18
18
  #require 'utf8_enforcer_workaround'
19
19
 
20
20
  #require 'rspec/expectations'
21
+ Capybara.register_driver(:rack_test_compliant) do |app|
22
+ agent_string = 'Firefox'
23
+ Capybara::RackTest::Driver.new(app, headers: {
24
+ 'User-Agent' => agent_string, ##Rails 3.x
25
+ 'HTTP_USER_AGENT' => agent_string ##Rails 4.x
26
+ })
27
+ end
28
+
29
+ Capybara.register_driver(:rack_test_non_compliant) do |app|
30
+ agent_string = 'Mozilla/5.0 (compatible; MSIE 6.0; Windows NT 5.1)'
31
+ Capybara::RackTest::Driver.new(app, headers: {
32
+ 'User-Agent' => agent_string, ##Rails 3.x
33
+ 'HTTP_USER_AGENT' => agent_string ##Rails 4.x
34
+ })
35
+ end
@@ -31,16 +31,28 @@ module RailsCommandHelpers
31
31
  @framework_version ||= `rails -v`[/^Rails (.+)$/, 1]
32
32
  end
33
33
 
34
- def new_application_command
35
- framework_version?("3") ? "rails new" : "rails"
34
+ def new_application_command(name)
35
+ case framework_version
36
+ when /^2/ then "rails #{name}"
37
+ when /^3/ then "rails new #{name}"
38
+ when /^4/ then "rails new #{name} --skip-sprockets --skip-javascript"
39
+ end
36
40
  end
37
41
 
38
42
  def generator_command
39
- framework_version?("3") ? "script/rails generate" : "script/generate"
43
+ case framework_version
44
+ when /^2/ then "script/generate"
45
+ when /^3/ then "script/rails generate"
46
+ when /^4/ then "rails generate"
47
+ end
40
48
  end
41
49
 
42
50
  def runner_command
43
- framework_version?("3") ? "script/rails runner" : "script/runner"
51
+ case framework_version
52
+ when /^2/ then "script/runner"
53
+ when /^3/ then "script/rails runner"
54
+ when /^4/ then "rails runner"
55
+ end
44
56
  end
45
57
  end
46
58
 
File without changes
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "~> 4.0.0"
6
+ gem "utf8_enforcer_workaround", :path=>"../"
7
+
8
+ gemspec :path=>"../"
@@ -1,3 +1,3 @@
1
1
  module Utf8EnforcerWorkaround
2
- VERSION = "1.0.1"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -29,4 +29,5 @@ Gem::Specification.new do |gem|
29
29
  gem.add_development_dependency('sqlite3', '~> 1.3')
30
30
  gem.add_development_dependency('aruba')
31
31
  gem.add_development_dependency('capybara')
32
+ gem.add_development_dependency('launchy')
32
33
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: utf8_enforcer_workaround
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-22 00:00:00.000000000 Z
12
+ date: 2013-08-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -155,6 +155,22 @@ dependencies:
155
155
  - - ! '>='
156
156
  - !ruby/object:Gem::Version
157
157
  version: '0'
158
+ - !ruby/object:Gem::Dependency
159
+ name: launchy
160
+ requirement: !ruby/object:Gem::Requirement
161
+ none: false
162
+ requirements:
163
+ - - ! '>='
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
166
+ type: :development
167
+ prerelease: false
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ none: false
170
+ requirements:
171
+ - - ! '>='
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
158
174
  description: Make utf8_enforcer to be applied only for non-standards-complying browsers.
159
175
  email:
160
176
  - jarl@softace.dk
@@ -177,8 +193,8 @@ files:
177
193
  - features/support/paths.rb
178
194
  - features/support/rails.rb
179
195
  - features/support/selectors.rb
180
- - features/support/user_agent.rb
181
- - gemfiles/Rails32.gemfile
196
+ - gemfiles/rails3.2.gemfile
197
+ - gemfiles/rails4.0.gemfile
182
198
  - lib/utf8_enforcer_workaround.rb
183
199
  - lib/utf8_enforcer_workaround/action_controller/base.rb
184
200
  - lib/utf8_enforcer_workaround/action_view/helpers/form_tag_helper.rb
@@ -198,7 +214,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
198
214
  version: '0'
199
215
  segments:
200
216
  - 0
201
- hash: -1376317580474258143
217
+ hash: 1309340087898795168
202
218
  required_rubygems_version: !ruby/object:Gem::Requirement
203
219
  none: false
204
220
  requirements:
@@ -207,10 +223,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
207
223
  version: '0'
208
224
  segments:
209
225
  - 0
210
- hash: -1376317580474258143
226
+ hash: 1309340087898795168
211
227
  requirements: []
212
228
  rubyforge_project: utf8_enforcer_workaround
213
- rubygems_version: 1.8.24
229
+ rubygems_version: 1.8.23
214
230
  signing_key:
215
231
  specification_version: 3
216
232
  summary: Make utf8_enforcer to be applied only for non-standards-complying browsers.
@@ -224,4 +240,3 @@ test_files:
224
240
  - features/support/paths.rb
225
241
  - features/support/rails.rb
226
242
  - features/support/selectors.rb
227
- - features/support/user_agent.rb
@@ -1,14 +0,0 @@
1
- # https://gist.github.com/358664 (by aslakhellesoy)
2
- module RackHeaderHack
3
- def set_headers(headers)
4
- driver = page.driver.browser
5
- def driver.env
6
- @env.merge(super)
7
- end
8
- def driver.env=(env)
9
- @env = env
10
- end
11
- driver.env = headers
12
- end
13
- end
14
- World(RackHeaderHack)