Skip to content

Get master passing again #779

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

Closed
wants to merge 4 commits into from
Closed
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
9 changes: 2 additions & 7 deletions Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -43,30 +43,25 @@ appraise "rails-4.2-sprockets_4" do
gem 'rails', '~> 4.2.1'
gem "sprockets", "~> 4.0.x"
gem "turbolinks", "~> 2.5.0"
gem "webpacker", github: "rails/webpacker"
# This ExecJS backend provides stateful context
# which the default nodejs backend does not
gem "mini_racer"
end

appraise "rails-5_no_sprockets_webpacker" do
gem 'rails', '~> 5.0.0'
gem "webpacker", github: "rails/webpacker"
gem "webpacker", '< 3.0'
# This ExecJS backend provides stateful context
# which the default nodejs backend does not
gem "therubyracer"
end

appraise "rails-5-no_sprockets" do
# Appraisal adds `turbolinks` to this gemfile because it is
# present in `./Gemfile`.
# But it causes this gemfile to break, so it must be removed
# from `./gemfiles/rails_5_no_sprockets.gemfile` manually.
gem 'rails', '~> 5.0.0'
end

appraise "rails-5.1-sprockets_4" do
gem "rails", "5.1.0.rc1"
gem "rails", "~> 5.1.0"
gem "sprockets", "~> 4.0.x"
gem "turbolinks", "~> 5.0.0"
end
2 changes: 0 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
source 'http://rubygems.org'

gemspec
# This is an optional dev-dependency, required whenever sprockets is required
gem "turbolinks"
2 changes: 1 addition & 1 deletion gemfiles/rails_3.2.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

source "http://rubygems.org"

gem "turbolinks", "~> 2.0"
gem "rails", "~> 3.2.21"
gem "rack-cache", "~> 1.6.1"
gem "turbolinks", "~> 2.0"

gemspec :path => "../"
2 changes: 1 addition & 1 deletion gemfiles/rails_4.0.5.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

source "http://rubygems.org"

gem "turbolinks"
gem "rails", "4.0.5"
gem "turbolinks"

gemspec :path => "../"
2 changes: 1 addition & 1 deletion gemfiles/rails_4.0_with_therubyracer.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

source "http://rubygems.org"

gem "turbolinks"
gem "rails", "~> 4.0.13"
gem "therubyracer", "0.12.0", :platform => :mri
gem "turbolinks"

gemspec :path => "../"
2 changes: 1 addition & 1 deletion gemfiles/rails_4.1.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

source "http://rubygems.org"

gem "turbolinks", "~> 2.3.0"
gem "rails", "~> 4.1.10"
gem "turbolinks", "~> 2.3.0"

gemspec :path => "../"
2 changes: 1 addition & 1 deletion gemfiles/rails_4.2_sprockets_2.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

source "http://rubygems.org"

gem "turbolinks"
gem "rails", "~> 4.2.1"
gem "sprockets", "~> 2.12"
gem "turbolinks"

gemspec :path => "../"
2 changes: 1 addition & 1 deletion gemfiles/rails_4.2_sprockets_3.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

source "http://rubygems.org"

gem "turbolinks", "~> 2.5.0"
gem "rails", "~> 4.2.1"
gem "sprockets", "~> 3.5"
gem "turbolinks", "~> 2.5.0"

gemspec :path => "../"
3 changes: 1 addition & 2 deletions gemfiles/rails_4.2_sprockets_4.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

source "http://rubygems.org"

gem "turbolinks", "~> 2.5.0"
gem "rails", "~> 4.2.1"
gem "sprockets", "~> 4.0.x"
gem "webpacker", :github => "rails/webpacker"
gem "turbolinks", "~> 2.5.0"
gem "mini_racer"

gemspec :path => "../"
4 changes: 2 additions & 2 deletions gemfiles/rails_5.1_sprockets_4.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

source "http://rubygems.org"

gem "turbolinks", "~> 5.0.0"
gem "rails", "5.1.0.rc1"
gem "rails", "~> 5.1.0"
gem "sprockets", "~> 4.0.x"
gem "turbolinks", "~> 5.0.0"

gemspec :path => "../"
1 change: 0 additions & 1 deletion gemfiles/rails_5_no_sprockets.gemfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# This file was generated by Appraisal
# This shouldn't have turbolinks or sprockets

source "http://rubygems.org"

Expand Down
3 changes: 1 addition & 2 deletions gemfiles/rails_5_no_sprockets_webpacker.gemfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# This file was generated by Appraisal
# This file shouldn't have turbolinks or sprockets in it

source "http://rubygems.org"

gem "rails", "~> 5.0.0"
gem "webpacker", :github => "rails/webpacker"
gem "webpacker", "< 3.0"
gem "therubyracer"

gemspec :path => "../"
6 changes: 3 additions & 3 deletions test/generators/coffee_component_generator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@ def class_name
'GeneratedComponent'
end

test 'that it the uses CoffeeScript syntax' do
def test_that_it_the_uses_CoffeeScript_syntax
run_generator %w(GeneratedComponent name --coffee)

assert_file filename, /^class @#{class_name}\sextends\sReact\.Component/
end

test 'that propTypes get assigned' do
def test_that_propTypes_get_assigned
run_generator %w(GeneratedComponent name --coffee)

assert_file filename, /@propTypes\s=/
assert_file filename, /React.PropTypes/
end

test 'that it generates working jsx' do
def test_that_it_generates_working_jsx
expected_name_div = /React\.createElement\(\s*"div",\s*null,\s*"Name:\s*",\s*this\.props\.name\s*\)/x
expected_shape_div = /React\.createElement\(\s*"div",\s*null,\s*"Address:\s*",\s*this\.props\.address\s*\)/x

Expand Down
14 changes: 7 additions & 7 deletions test/generators/component_generator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def filename
end
end

test "creates the component file" do
def test_creates_the_component_file
run_generator %w(GeneratedComponent)

assert_file filename do |contents|
Expand All @@ -27,37 +27,37 @@ def filename
end
end

test "creates the component file with a node argument" do
def test_creates_the_component_file_with_a_node_argument
run_generator %w(GeneratedComponent name)
assert_file filename, %r{name: React.PropTypes.node}
end

test "creates the component file with various standard proptypes" do
def test_creates_the_component_file_with_various_standard_proptypes
proptypes = %w(string bool number array func number object any)
run_generator %w(GeneratedComponent) + proptypes.map { |type| "my_#{type}:#{type}" }
proptypes.each do |type|
assert_file filename, %r(my#{type.capitalize}: React.PropTypes.#{type})
end
end

test "creates a component file with an instanceOf property" do
def test_creates_a_component_file_with_an_instanceOf_property
run_generator %w(GeneratedComponent favorite_food:instanceOf{food})
assert_file filename, /favoriteFood: React.PropTypes.instanceOf\(Food\)/
end

test "creates a component file with a oneOf property" do
def test_creates_a_component_file_with_a_oneOf_property
run_generator %w(GeneratedComponent favorite_food:oneOf{pizza,hamburgers})
assert_file filename, /favoriteFood: React.PropTypes.oneOf\(\['pizza','hamburgers'\]\)/
end

test "creates a component file with a oneOfType property" do
def test_creates_a_component_file_with_a_oneOfType_property
run_generator %w(GeneratedComponent favorite_food:oneOfType{string,Food})
expected_property = "favoriteFood: React.PropTypes.oneOfType([React.PropTypes.string,React.PropTypes.instanceOf(Food)])"

assert_file filename, Regexp.new(Regexp.quote(expected_property))
end

test "generates working jsx" do
def test_generates_working_jsx
expected_name_div = /React\.createElement\(\s*"div",\s*null,\s*\"Name:\s*\",\s*this\.props\.name\s*\)/x
expected_shape_div = /React\.createElement\(\s*"div",\s*null,\s*\"Address:\s*\",\s*this\.props\.address\s*\)/x

Expand Down
6 changes: 3 additions & 3 deletions test/generators/es6_component_generator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ def class_name
'GeneratedComponent'
end

test "uses es6 syntax" do
def test_uses_es6_syntax
run_generator %w(GeneratedComponent name --es6)

assert_file filename, /^class\s#{class_name}\sextends\sReact\.Component/
end

test "assigns defaultProps after class definintion" do
def test_assigns_defaultProps_after_class_definintion
run_generator %w(GeneratedComponent name --es6)

assert_file filename, /\s^#{class_name}\.propTypes/
end

test "generates working jsx" do
def test_generates_working_jsx
expected_name_div = /React\.createElement\(\s*"div",\s*null,\s*\"Name:\s*\",\s*this\.props\.name\s*\)/x
expected_shape_div = /React\.createElement\(\s*"div",\s*null,\s*\"Address:\s*\",\s*this\.props\.address\s*\)/x

Expand Down
18 changes: 9 additions & 9 deletions test/generators/install_generator_sprockets_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,33 @@ def copy_directory(dir)
FileUtils.cp_r source, dest
end

test "adds requires to `application.js`" do
def test_adds_requires_to_application_js
run_generator
assert_application_file_created
end

test "it modifes an existing 'application.js'" do
def test_it_modifes_an_existing_application_js
copy_directory('app/assets/javascripts/application.js')
run_generator
assert_application_file_modified
end

test "creates `application.js` if it doesn't exist" do
def test_creates_application_js_if_it_doesnt_exist
copy_directory('app/assets/javascripts/application.js')
File.delete destination_root + '/app/assets/javascripts/application.js'

run_generator
assert_application_file_created
end

test "modifies `application.js` if it's empty" do
def test_modifies_application_js_if_its_empty
init_application_js ''

run_generator
assert_application_file_created
end

test "updates `application.js` if require_tree is commented" do
def test_updates_application_js_if_require_tree_is_commented
init_application_js <<-END
//
// require_tree .
Expand All @@ -53,7 +53,7 @@ def copy_directory(dir)
assert_application_file_modified
end

test "updates `application.js` if require turbolinks has extra spaces" do
def test_updates_application_js_if_require_turbolinks_has_extra_spaces
init_application_js <<-END
//
//#{"= require turbolinks "}
Expand All @@ -64,20 +64,20 @@ def copy_directory(dir)
assert_application_file_modified
end

test "creates server_rendering.js with default requires" do
def test_creates_server_rendering_js_with_default_requires
run_generator
server_rendering_file_path = "app/assets/javascripts/server_rendering.js"
assert_file server_rendering_file_path, %r{//= require react-server\n}
assert_file server_rendering_file_path, %r{//= require ./components\n}
end

test "creates server rendering initializer" do
def test_creates_server_rendering_initializer
run_generator
initializer_path = "config/initializers/react_server_rendering.rb"
assert_file(initializer_path, %r{Rails.application.config.assets.precompile \+= \["server_rendering.js"\]})
end

test "skipping server rendering" do
def test_skipping_server_rendering
run_generator %w(--skip-server-rendering)
assert_no_file "config/initializers/react_server_rendering.rb"
assert_no_file "app/assets/javascripts/server_rendering.js"
Expand Down
6 changes: 3 additions & 3 deletions test/generators/install_generator_webpacker_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ def copy_directory(dir)
FileUtils.cp_r source, dest
end

test "adds requires to `application.js`" do
def test_adds_requires_to_application_js
run_generator
assert_file "app/javascript/packs/application.js", EXPECTED_SETUP
assert_file "app/javascript/components"
end

test "creates server_rendering.js with default requires" do
def test_creates_server_rendering_js_with_default_requires
run_generator
assert_file DEFAULT_SERVER_RENDERING_PACK_PATH do |contents|
assert_includes contents, "var componentRequireContext = require.context(\"components\", true)\n"
Expand All @@ -38,7 +38,7 @@ def copy_directory(dir)
end
end

test "skipping server rendering" do
def test_skipping_server_rendering
run_generator %w(--skip-server-rendering)
assert_no_file DEFAULT_SERVER_RENDERING_PACK_PATH
end
Expand Down
2 changes: 1 addition & 1 deletion test/react/jsx/jsx_prepocessor_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class JSXPreprocessorTest < ActiveSupport::TestCase
REQUIRED_COFFEESCRIPT = "var requireCoffee; requireCoffee = true;"
REQUIRED_JSX = "React.createElement(\"div\", { className: \"require-jsx\" });"
OWN_JSX = "React.createElement(\"div\", { className: \"le-javascript\" });"
test 'executes //= require directives' do
def test_executes_require_directives
require_parent = SprocketsHelpers.fetch_asset_body("require_test/jsx_preprocessor_test.js")

assert_compiled_javascript_includes(require_parent, REQUIRED_JAVASCRIPT)
Expand Down
8 changes: 4 additions & 4 deletions test/react/jsx/jsx_transformer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class JSXTransformerTest < ActionDispatch::IntegrationTest
SprocketsHelpers.manually_expire_asset('JSXTransformer.js')
end

test 'can use dropped-in version of JSX transformer' do
def test_can_use_dropped_in_version_of_JSX_transformer
hidden_path = Rails.root.join("vendor/assets/react/JSXTransformer__.js")
replacing_path = Rails.root.join("vendor/assets/react/JSXTransformer.js")

Expand All @@ -27,7 +27,7 @@ class JSXTransformerTest < ActionDispatch::IntegrationTest
assert_equal 'test_confirmation_token_jsx_transformed;', @response.body.strip
end

test 'accepts harmony: true option' do
def test_accepts_harmony_true_option
React::JSX.transform_options = {harmony: true}
get '/assets/harmony_example.js'
assert_response :success
Expand All @@ -37,14 +37,14 @@ class JSXTransformerTest < ActionDispatch::IntegrationTest
assert_match(/active=\$__0\.active/, @response.body, "destructuring assignment")
end

test 'accepts strip_types: true option' do
def test_accepts_strip_types_true_option
React::JSX.transform_options = {strip_types: true, harmony: true}
get '/assets/flow_types_example.js'
assert_response :success
assert_match(/\(i\s*,\s*name\s*\)\s*\{/, @response.body, "type annotations are removed")
end

test 'accepts asset_path: option' do
def test_accepts_asset_path_option
hidden_path = Rails.root.join("vendor/assets/react/JSXTransformer__.js")
custom_path = Rails.root.join("vendor/assets/react/custom")
replacing_path = custom_path.join("CustomTransformer.js")
Expand Down
Loading