Skip to content
This repository has been archived by the owner on May 2, 2020. It is now read-only.

Commit

Permalink
let people write specs in jsx
Browse files Browse the repository at this point in the history
Change-Id: I454d9ffbbb0628ce30acba39b711ae1459f33965
Reviewed-on: https://gerrit.instructure.com/57055
Reviewed-by: Clay Diffrient <[email protected]>
Product-Review: Clay Diffrient <[email protected]>
QA-Review: Clay Diffrient <[email protected]>
Tested-by: Jenkins
  • Loading branch information
cmatheson committed Dec 5, 2015
1 parent d7a3d19 commit b42a402
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 14 deletions.
10 changes: 6 additions & 4 deletions guard/jsx.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ module Guard
class JSX < Guard

def initialize(watchers=[], options={})
super([::Guard::Watcher.new(/(app\/jsx\/.*)/)], {})
super([::Guard::Watcher.new(%r{app/jsx/.*}),
::Guard::Watcher.new(%r{spec/javascripts/jsx/.*})], {})
end

def run_on_change(paths)
Expand All @@ -15,9 +16,10 @@ def run_on_change(paths)

def run_all
::Guard::UI.info "Compiling JSX"
source = 'app/jsx'
dest = 'public/javascripts/jsx'
`node_modules/.bin/babel #{source} --out-dir #{dest} --source-maps inline`
[["app/jsx", "public/javascripts/jsx"],
["spec/javascripts/jsx", "spec/javascripts/compiled"]].each { |source, dest|
`node_modules/.bin/babel #{source} --out-dir #{dest} --source-maps inline`
}
end

end
Expand Down
22 changes: 12 additions & 10 deletions lib/tasks/js.rake
Original file line number Diff line number Diff line change
Expand Up @@ -319,17 +319,19 @@ namespace :js do

desc "Compile React JSX to JS"
task :jsx do
source = Rails.root + 'app/jsx'
dest = Rails.root + 'public/javascripts/jsx'
if Rails.env == 'development'
msg = `node_modules/.bin/babel #{source} --out-dir #{dest} --source-maps inline 2>&1 >/dev/null`
else
msg = `node_modules/.bin/babel #{source} --out-dir #{dest} 2>&1 >/dev/null`
end
dirs = [["#{Rails.root}/app/jsx", "#{Rails.root}/public/javascripts/jsx"],
["#{Rails.root}/spec/javascripts/jsx", "#{Rails.root}/spec/javascripts/compiled"]]
dirs.each { |source,dest|
if Rails.env == 'development'
msg = `node_modules/.bin/babel #{source} --out-dir #{dest} --source-maps inline 2>&1 >/dev/null`
else
msg = `node_modules/.bin/babel #{source} --out-dir #{dest} 2>&1 >/dev/null`
end

unless $?.success?
raise msg
end
unless $?.success?
raise msg
end
}
end

desc "creates ember app bundles"
Expand Down
7 changes: 7 additions & 0 deletions spec/javascripts/jsx/exampleSpec.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
define([], () => {
module("Example JSX Spec");

test("this is true", () => {
equal(true, true, "yep");
});
});

0 comments on commit b42a402

Please sign in to comment.