Skip to content

Commit 6bef8f4

Browse files
committed
Fix Tests
- Added npm package.json to the helper_files folder. - Update Rakefile to install npm packages in the helper_files folder. - Added a new test for passing components.
1 parent 82104cc commit 6bef8f4

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

Rakefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
require 'rake/testtask'
22

3+
# make sure we load NPM dependencies in the helper_files directory
4+
config_path = File.expand_path('../test/helper_files', __FILE__)
5+
`cd #{config_path} && npm install`
6+
37
Rake::TestTask.new do |task|
48
task.libs << %w(test lib)
59
task.pattern = 'test/**/*_test.rb'

test/helper_files/package.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"repository": {},
3+
"dependencies": {},
4+
"devDependencies": {
5+
"react": "^0.14.5",
6+
"babel-core": "^6.3.26",
7+
"babel-loader": "^6.2.0",
8+
"babel-preset-es2015": "^6.3.13",
9+
"babel-preset-react": "^6.3.13"
10+
}
11+
}

test/react/render_test.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class ReactRenderTest < Minitest::Test
99
end
1010
end
1111

12-
context ' a rails react studio render' do
12+
context 'a rails react studio render' do
1313
setup do
1414
@path_to_component =
1515
File.expand_path('../../helper_files/Hello.jsx', __FILE__)
@@ -29,5 +29,13 @@ class ReactRenderTest < Minitest::Test
2929
result = RailsReactStdio::React.render('', {})
3030
assert_includes result, 'Cannot load component'
3131
end
32+
33+
should 'pass props to component' do
34+
result =
35+
RailsReactStdio::React.render(
36+
@path_to_component, message: 'foobar_message'
37+
)
38+
assert_includes result, 'foobar_message'
39+
end
3240
end
3341
end

0 commit comments

Comments
 (0)