Skip to content

Commit

Permalink
Update CONTRIBUTING.md and related files
Browse files Browse the repository at this point in the history
  • Loading branch information
wanyamaman committed Feb 26, 2017
1 parent 8e47c79 commit 80f4f14
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
36 changes: 23 additions & 13 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ When making doc changes, we want the change to work on both the gitbook and the
## To run tests:
* After updating code via git, to prepare all examples and run all tests:

```
```sh
cd react_on_rails/
bundle && yarn && rake examples:prepare_all && rake node_package && rake
```

Expand Down Expand Up @@ -72,6 +73,13 @@ It's critical to configure your IDE/editor to ignore certain directories. Otherw
* /spec/react_on_rails/dummy-for-generators

# Configuring your test app to use your local fork
You can test the `react-on-rails` gem using your own external test app or the gem's internal `spec/dummy` app. The `spec/dummy` app is an example of the various setup techniques you can use with the gem.
```
├── test
└── react_on_rails
└── spec
└── dummy
```

## Ruby Gem
If you want to test the gem with an application before you release a new version of the gem, you can specify the path to your local version via your test app's Gemfile:
Expand All @@ -86,13 +94,14 @@ Note that you will need to bundle install after making this change, but also tha
First, be **sure** to build the NPM package

```sh
cd react_on_rails/
yarn
yarn run build
```

Use a relative path in your `package.json`, like this:
Use a relative path in your test app's `package.json`, like this:
```sh
cd client
cd test/client
yarn add "react-on-rails@../../react_on_rails"
```

Expand All @@ -119,9 +128,10 @@ yarn global add phantomjs
Note this *must* be installed globally for the dummy test project rspec runner to see it properly.

### Local Node Package
Because the example and dummy apps rely on the react-on-rails node package, they should link directly to your local version to pick up any changes you may have made to that package. To achieve this, switch to the test app's root directory and run this command below which runs something like [this script](spec/dummy/package.json#L14)
Because the example and dummy apps rely on the react-on-rails node package, they should link directly to your local version to pick up any changes you may have made to that package. To achieve this, switch to the dummy app's root directory and run this command below which runs something like [this script](spec/dummy/package.json#L14)

```sh
cd react_on_rails/spec/dummy
yarn run install-react-on-rails
```

Expand All @@ -141,9 +151,9 @@ From now on, the example and dummy apps will use your local node_package folder
### Install NPM dependencies and build the NPM package for react-on-rails

```sh
cd <top level>
cd react_on_rails/
yarn
npm build
yarn build
```

Or run this which builds the yarn package, then the webpack files for spec/dummy, and runs tests in
Expand All @@ -153,40 +163,40 @@ spec/dummy.
```sh
# Optionally change default selenium_firefox driver
export DRIVER=poltergeist
cd <top level>
cd react_on_rails/
yarn run dummy:spec
```

### Run NPM JS tests

```sh
cd <top level>
cd react_on_rails/
yarn test
```

### Run spec/dummy tests

```sh
cd spec/dummy
cd react_on_rails/spec/dummy
rspec
```

Eventually, we may have JS tests:

```sh
cd spec/dummy/client
cd react_on_rails/spec/dummy/client
yarn run test
```

### Run most tests and linting

```sh
cd <top level>
npm run check
cd react_on_rails/
yarn run check
```

### Starting the Dummy App
To run the test app, it's **CRITICAL** to not just run `rails s`. You have to run `foreman start`. If you don't do this, then `webpack` will not generate a new bundle, and you will be seriously confused when you change JavaScript and the app does not change. If you change the webpack configs, then you need to restart foreman. If you change the JS code for react-on-rails, you need to run `yarn run build`. Since the react-on-rails package should be sym linked, you don't have to `yarn react-on-rails` after every change.
To run the dummy app, it's **CRITICAL** to not just run `rails s`. You have to run `foreman start`. If you don't do this, then `webpack` will not generate a new bundle, and you will be seriously confused when you change JavaScript and the app does not change. If you change the webpack configs, then you need to restart foreman. If you change the JS code for react-on-rails, you need to run `yarn run build`. Since the react-on-rails package should be sym linked, you don't have to `yarn react-on-rails` after every change.

### RSpec Testing
Run `rake` for testing the gem and `spec/dummy`. Otherwise, the `rspec` command only works for testing within the sample apps, like `spec/dummy`.
Expand Down
2 changes: 1 addition & 1 deletion spec/dummy/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"build:dev:server": "webpack -w --config webpack.server.rails.build.config.js",
"build:server": "webpack --config webpack.server.rails.build.config.js",
"hot-assets": "babel-node server-rails-hot.js",
"install-react-on-rails": "yarn 'file:../../..'"
"install-react-on-rails": "CLIENT_PATH=$(pwd) && cd ../../../ && yarn && cd $CLIENT_PATH && yarn add 'file:../../..'"
},
"author": "",
"license": "ISC"
Expand Down

0 comments on commit 80f4f14

Please sign in to comment.