Skip to content

Commit 5d76c60

Browse files
committed
Merge pull request #151 from shakacode/glennr-gr_mocha_tests
mocha tests and update dependencies
2 parents b64dcfd + 60f4b51 commit 5d76c60

File tree

16 files changed

+1218
-981
lines changed

16 files changed

+1218
-981
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
/public/assets
1818
.env
1919
node_modules
20-
npm-debug.log
20+
npm-debug.log*
2121
/coverage
2222

2323
# Ignore bundle dependencies

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.12.7
1+
5.0

.ruby-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.2.2
1+
2.2.3

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
language:
22
- ruby
33
rvm:
4-
- 2.2.2
4+
- 2.2.3
55
install:
66
- bundle install
77
- npm install -g npm

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
source "https://rubygems.org"
2-
ruby "2.2.2"
2+
ruby "2.2.3"
33

44
#
55
# Bundle edge Rails instead: gem "rails", github: "rails/rails"

Gemfile.lock

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ GEM
4343
ast (2.1.0)
4444
astrolabe (1.3.1)
4545
parser (~> 2.2)
46-
autoprefixer-rails (6.0.3)
46+
autoprefixer-rails (6.1.0.1)
4747
execjs
4848
json
4949
awesome_print (1.6.1)
@@ -68,8 +68,7 @@ GEM
6868
bundler-audit (0.4.0)
6969
bundler (~> 1.2)
7070
thor (~> 0.18)
71-
byebug (5.0.0)
72-
columnize (= 0.9.0)
71+
byebug (8.0.0)
7372
capybara (2.5.0)
7473
mime-types (>= 1.16)
7574
nokogiri (>= 1.3.3)
@@ -92,7 +91,6 @@ GEM
9291
coffee-script-source
9392
execjs
9493
coffee-script-source (1.9.1.1)
95-
columnize (0.9.0)
9694
connection_pool (2.2.0)
9795
coveralls (0.8.3)
9896
json (~> 1.8)
@@ -155,8 +153,8 @@ GEM
155153
coderay (~> 1.1.0)
156154
method_source (~> 0.8.1)
157155
slop (~> 3.4)
158-
pry-byebug (3.2.0)
159-
byebug (~> 5.0)
156+
pry-byebug (3.3.0)
157+
byebug (~> 8.0)
160158
pry (~> 0.10)
161159
pry-doc (0.8.0)
162160
pry (~> 0.9)
@@ -205,10 +203,10 @@ GEM
205203
raindrops (0.15.0)
206204
rake (10.4.2)
207205
rdoc (4.2.0)
208-
react_on_rails (1.0.0.pre)
206+
react_on_rails (1.0.1)
209207
connection_pool
210208
execjs (~> 2.5)
211-
rails (>= 4.0)
209+
rails (>= 3.2)
212210
ref (2.0.0)
213211
rest-client (1.8.0)
214212
http-cookie (>= 1.0.2, < 2.0)
@@ -307,7 +305,7 @@ GEM
307305
unf (0.1.4)
308306
unf_ext
309307
unf_ext (0.0.7.1)
310-
unicorn (4.9.0)
308+
unicorn (5.0.0)
311309
kgio (~> 2.6)
312310
rack
313311
raindrops (~> 0.7)

README.md

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ module.exports = {
189189
// And update this
190190
styleLoader: 'style-loader!css-loader!sass-loader?imagePath=/assets/images&includePaths[]=' + bourbonPaths,
191191
```
192-
- `@import 'bourbon';` Import bourbon from your [scss file](https://github.com/shakacode/react-webpack-rails-tutorial/blob/master/client/assets/stylesheets/_app-styling-post-bootstrap-loading.scss)
192+
- `@import 'bourbon';` Import bourbon from your [scss file](https://github.com/shakacode/react-webpack-rails-tutorial/blob/master/client/assets/stylesheets/_app-styling-post-bootstrap-loading.scss)
193193

194194
# Notes on Rails assets
195195
## Rails Asset Pipeline Magic
@@ -266,11 +266,31 @@ git push heroku master
266266
```
267267

268268
# Running Tests
269-
*Default rake task runs tests and linting*
269+
*Default rake task runs feature specs, mocha tests and linting*
270270

271-
We have feature tests in /spec/features
271+
We have;
272+
273+
* feature tests in /spec/features
274+
* component unit tests in /client/test/
275+
* javascript linting
276+
277+
From the root of the project, you can run all specs+tests+linter with
278+
279+
npm run test
280+
281+
Run the feature specs individually with `rspec`.
282+
283+
Run the React unit tests (all .js and .jsx files) from the `client` dir with;
284+
285+
cd client
286+
npm run test --silent
287+
288+
In lieu of having `mocha --watch` working properly (pull request welcome!), you can have your js tests continually running with `watch`
289+
290+
npm install -g watch
291+
cd client
292+
watch 'npm run test --silent' test/ app/
272293

273-
Run the tests with `rspec`.
274294

275295
## CI configuration
276296
Add those lines to your CI scripts after `bundle install`

app/views/pages/simple.html.erb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
<h2>Using React (no Flux framework) + Rails Backend (with react_on_rails gem)</h2>
1+
<h2>Using React (no Flux framework) + Rails Backend (with
2+
<a href="https://github.com/shakacode/react_on_rails">react_on_rails gem</a>)</h2>
23
<p>This example is much simpler than the one using React + Redux and is appropriate when:</p>
34
<ul>
45
<li>No or minimal MVC</li>
56
<li>No async necessary</li>
7+
<li>No server rendering</li>
8+
<li>No pre-population of props</li>
69
</ul>
710
<hr/>
811

client/.eslintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ plugins:
99
env:
1010
browser: true
1111
node: true
12+
mocha: true
1213

1314
rules:
1415
indent: [1, 2, { SwitchCase: 1, VariableDeclarator: 2 }]

client/app/components/Comment.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class Comment extends React.Component {
1616
<h2 className="comment-author">
1717
{author}
1818
</h2>
19-
<span dangerouslySetInnerHTML={{__html: rawMarkup}}/>
19+
<span dangerouslySetInnerHTML={{__html: rawMarkup}} className="comment-text"/>
2020
</div>
2121
);
2222
}

0 commit comments

Comments
 (0)