Skip to content

Commit 591b99a

Browse files
authored
Merge pull request #1 from munderseth/master
Ruby.RSpec Refactoring
2 parents 9151e0c + 43f35b1 commit 591b99a

File tree

12 files changed

+180
-113
lines changed

12 files changed

+180
-113
lines changed

.c9build.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
# Build
4+
gem install bundler
5+
bundle install
6+
7+
# Analysis
8+
bundle exec rubocop --format emacs --out tmp/rubocop.txt
9+
bundle exec brakeman -o tmp/brakeman.json
10+
bundle exec brakeman_translate_checkstyle_format translate --file="tmp/brakeman.json" > tmp/brakeman_checkstyle.xml
11+
12+
# Test
13+
export CI_REPORTS=$PWD/spec/reports
14+
COVERAGE=true xvfb-run --server-args="-screen 0 1024x768x24" bundle exec rake ci:setup:rspec spec
15+
16+
# Publish
17+
curl -s https://testspace-client.s3.amazonaws.com/testspace-linux.tgz | sudo tar -zxvf- -C /usr/local/bin
18+
testspace publish @.testspace master.c9

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,6 @@
1919
/coverage
2020
/spec/reports
2121

22-
/vendor
22+
/vendor
23+
24+
/firefox

.ruby-version

Lines changed: 0 additions & 1 deletion
This file was deleted.

.testspace

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## Addding some comments here
2+
tmp/rubocop.txt
3+
tmp/brakeman_checkstyle.xml
4+
[Tests]$CI_REPORTS/SPEC*.xml{spec}
5+
coverage/coverage.xml

.testspace.xml

Lines changed: 0 additions & 22 deletions
This file was deleted.

.travis.yml

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
1-
language: ruby
1+
language:
2+
- ruby
3+
24
rvm:
3-
- 2.1.1
5+
- 2.3.1
46

57
before_install:
6-
# Install Testspace Runner
7-
- ./testspace_install.sh
8-
- export PATH="${HOME}/testspace:${PATH}"
9-
- gem install bundler
108
- "export DISPLAY=:99.0"
119
- "sh -e /etc/init.d/xvfb start"
1210
- sleep 3 # give xvfb some time to start
1311

1412
script:
15-
- COVERAGE=true bundle exec rake ci:setup:rspec spec
13+
- gem install bundler
14+
- bundle exec rubocop --format emacs --out tmp/rubocop.txt || true
15+
- bundle exec brakeman -o tmp/brakeman.json
16+
- bundle exec brakeman_translate_checkstyle_format translate --file="tmp/brakeman.json" > tmp/brakeman_checkstyle.xml
1617

17-
# Publish Test Results along with Coverage
18-
- testspace publish [Tests]spec/reports/*.xml{spec} coverage/coverage.xml ${TESTSPACE_URL}
18+
- export CI_REPORTS=$PWD/spec/reports
19+
- COVERAGE=true bundle exec rake ci:setup:rspec spec
20+
21+
after_script:
22+
- curl -s https://testspace-client.s3.amazonaws.com/testspace-linux.tgz | sudo tar -zxvf- -C /usr/local/bin
23+
- testspace publish @.testspace $TESTSPACE_TOKEN/${TRAVIS_BRANCH}#travis.Build.${TRAVIS_BUILD_NUMBER}

Gemfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,14 @@ group :development, :test do
4848
gem 'ci_reporter_rspec'
4949
gem 'simplecov', :require => false
5050
gem 'simplecov-cobertura'
51+
52+
# A Ruby static code analyzer.
53+
gem 'rubocop', :require => false
54+
# A static analysis security vulnerability scanner for Ruby on Rails.
55+
gem 'brakeman', :require => false
56+
# Translate brakeman json format into Checkstyle format.
57+
gem 'brakeman_translate_checkstyle_format', :require => false
58+
5159
end
5260

5361
group :test do

Gemfile.lock

Lines changed: 67 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,13 @@ GEM
2929
tzinfo (~> 1.1)
3030
addressable (2.4.0)
3131
arel (5.0.1.20140414130214)
32+
ast (2.3.0)
3233
bcrypt (3.1.11)
3334
bootstrap-sass (3.1.1.1)
3435
sass (~> 3.2)
36+
brakeman (3.3.5)
37+
brakeman_translate_checkstyle_format (0.0.1)
38+
thor
3539
builder (3.2.2)
3640
capybara (2.4.4)
3741
mime-types (>= 1.16)
@@ -58,19 +62,19 @@ GEM
5862
diff-lcs (1.2.5)
5963
docile (1.1.5)
6064
erubis (2.7.0)
61-
execjs (2.6.0)
65+
execjs (2.7.0)
6266
factory_girl (4.4.0)
6367
activesupport (>= 3.0.0)
6468
factory_girl_rails (4.4.1)
6569
factory_girl (~> 4.4.0)
6670
railties (>= 3.0.0)
6771
faker (1.4.3)
6872
i18n (~> 0.5)
69-
ffi (1.9.10)
73+
ffi (1.9.14)
7074
formatador (0.2.5)
71-
guard (2.13.0)
75+
guard (2.14.0)
7276
formatador (>= 0.2.4)
73-
listen (>= 2.7, <= 4.0)
77+
listen (>= 2.7, < 4.0)
7478
lumberjack (~> 1.0)
7579
nenv (~> 0.1)
7680
notiffany (~> 0.0)
@@ -82,7 +86,7 @@ GEM
8286
rspec (>= 2.14, < 4.0)
8387
hike (1.2.3)
8488
i18n (0.7.0)
85-
jbuilder (2.4.1)
89+
jbuilder (2.6.0)
8690
activesupport (>= 3.0.0, < 5.1)
8791
multi_json (~> 1.2)
8892
jquery-rails (3.1.4)
@@ -91,26 +95,32 @@ GEM
9195
json (1.8.3)
9296
launchy (2.4.3)
9397
addressable (~> 2.3)
94-
listen (3.0.6)
95-
rb-fsevent (>= 0.9.3)
96-
rb-inotify (>= 0.9.7)
98+
listen (3.1.5)
99+
rb-fsevent (~> 0.9, >= 0.9.4)
100+
rb-inotify (~> 0.9, >= 0.9.7)
101+
ruby_dep (~> 1.2)
97102
lumberjack (1.0.10)
98103
mail (2.5.4)
99104
mime-types (~> 1.16)
100105
treetop (~> 1.4.8)
101106
method_source (0.8.2)
102107
mime-types (1.25.1)
103-
mini_portile2 (2.0.0)
104-
minitest (5.8.4)
105-
multi_json (1.11.2)
108+
mini_portile2 (2.1.0)
109+
minitest (5.9.0)
110+
multi_json (1.12.1)
106111
nenv (0.3.0)
107-
nokogiri (1.6.7.2)
108-
mini_portile2 (~> 2.0.0.rc2)
109-
notiffany (0.0.8)
112+
nokogiri (1.6.8)
113+
mini_portile2 (~> 2.1.0)
114+
pkg-config (~> 1.1.7)
115+
notiffany (0.1.1)
110116
nenv (~> 0.1)
111117
shellany (~> 0.0)
118+
parser (2.3.1.2)
119+
ast (~> 2.2)
120+
pkg-config (1.1.7)
112121
polyglot (0.3.5)
113-
pry (0.10.3)
122+
powerpack (0.1.1)
123+
pry (0.10.4)
114124
coderay (~> 1.1.0)
115125
method_source (~> 0.8.1)
116126
slop (~> 3.4)
@@ -132,33 +142,42 @@ GEM
132142
activesupport (= 4.1.1)
133143
rake (>= 0.8.7)
134144
thor (>= 0.18.1, < 2.0)
135-
rake (11.1.2)
145+
rainbow (2.1.0)
146+
rake (11.2.2)
136147
rb-fsevent (0.9.7)
137148
rb-inotify (0.9.7)
138149
ffi (>= 0.5.0)
139150
rdoc (4.2.2)
140151
json (~> 1.4)
141-
rspec (3.4.0)
142-
rspec-core (~> 3.4.0)
143-
rspec-expectations (~> 3.4.0)
144-
rspec-mocks (~> 3.4.0)
145-
rspec-core (3.4.4)
146-
rspec-support (~> 3.4.0)
147-
rspec-expectations (3.4.0)
152+
rspec (3.5.0)
153+
rspec-core (~> 3.5.0)
154+
rspec-expectations (~> 3.5.0)
155+
rspec-mocks (~> 3.5.0)
156+
rspec-core (3.5.2)
157+
rspec-support (~> 3.5.0)
158+
rspec-expectations (3.5.0)
148159
diff-lcs (>= 1.2.0, < 2.0)
149-
rspec-support (~> 3.4.0)
150-
rspec-mocks (3.4.1)
160+
rspec-support (~> 3.5.0)
161+
rspec-mocks (3.5.0)
151162
diff-lcs (>= 1.2.0, < 2.0)
152-
rspec-support (~> 3.4.0)
153-
rspec-rails (3.4.2)
154-
actionpack (>= 3.0, < 4.3)
155-
activesupport (>= 3.0, < 4.3)
156-
railties (>= 3.0, < 4.3)
157-
rspec-core (~> 3.4.0)
158-
rspec-expectations (~> 3.4.0)
159-
rspec-mocks (~> 3.4.0)
160-
rspec-support (~> 3.4.0)
161-
rspec-support (3.4.1)
163+
rspec-support (~> 3.5.0)
164+
rspec-rails (3.5.2)
165+
actionpack (>= 3.0)
166+
activesupport (>= 3.0)
167+
railties (>= 3.0)
168+
rspec-core (~> 3.5.0)
169+
rspec-expectations (~> 3.5.0)
170+
rspec-mocks (~> 3.5.0)
171+
rspec-support (~> 3.5.0)
172+
rspec-support (3.5.0)
173+
rubocop (0.42.0)
174+
parser (>= 2.3.1.1, < 3.0)
175+
powerpack (~> 0.1)
176+
rainbow (>= 1.99.1, < 3.0)
177+
ruby-progressbar (~> 1.7)
178+
unicode-display_width (~> 1.0, >= 1.0.1)
179+
ruby-progressbar (1.8.1)
180+
ruby_dep (1.4.0)
162181
rubyzip (1.2.0)
163182
sass (3.2.19)
164183
sass-rails (4.0.5)
@@ -169,22 +188,22 @@ GEM
169188
sdoc (0.4.1)
170189
json (~> 1.7, >= 1.7.7)
171190
rdoc (~> 4.0)
172-
selenium-webdriver (2.53.0)
191+
selenium-webdriver (2.53.4)
173192
childprocess (~> 0.5)
174193
rubyzip (~> 1.0)
175194
websocket (~> 1.0)
176195
shellany (0.0.1)
177196
shoulda-matchers (2.6.2)
178197
activesupport (>= 3.0.0)
179-
simplecov (0.11.2)
198+
simplecov (0.12.0)
180199
docile (~> 1.1.0)
181-
json (~> 1.8)
200+
json (>= 1.8, < 3)
182201
simplecov-html (~> 0.10.0)
183202
simplecov-cobertura (1.1.0)
184203
simplecov (~> 0.8)
185204
simplecov-html (0.10.0)
186205
slop (3.6.0)
187-
spring (1.7.1)
206+
spring (1.7.2)
188207
spring-commands-rspec (1.0.4)
189208
spring (>= 0.9.1)
190209
sprockets (2.12.4)
@@ -203,12 +222,14 @@ GEM
203222
treetop (1.4.15)
204223
polyglot
205224
polyglot (>= 0.3.1)
206-
turbolinks (2.5.3)
207-
coffee-rails
225+
turbolinks (5.0.1)
226+
turbolinks-source (~> 5)
227+
turbolinks-source (5.0.0)
208228
tzinfo (1.2.2)
209229
thread_safe (~> 0.1)
210-
uglifier (3.0.0)
230+
uglifier (3.0.2)
211231
execjs (>= 0.3.0, < 3)
232+
unicode-display_width (1.1.0)
212233
websocket (1.2.3)
213234
xpath (2.0.0)
214235
nokogiri (~> 1.3)
@@ -219,6 +240,8 @@ PLATFORMS
219240
DEPENDENCIES
220241
bcrypt (~> 3.1.7)
221242
bootstrap-sass (~> 3.1.1)
243+
brakeman
244+
brakeman_translate_checkstyle_format
222245
capybara (~> 2.4.3)
223246
ci_reporter_rspec
224247
coffee-rails (~> 4.0.0)
@@ -231,6 +254,7 @@ DEPENDENCIES
231254
launchy (~> 2.4.2)
232255
rails (= 4.1.1)
233256
rspec-rails (~> 3.1)
257+
rubocop
234258
sass-rails (~> 4.0.3)
235259
sdoc (~> 0.4.0)
236260
selenium-webdriver (~> 2.53)
@@ -244,4 +268,4 @@ DEPENDENCIES
244268
uglifier (>= 1.3.0)
245269

246270
BUNDLED WITH
247-
1.11.2
271+
1.12.5

README.md

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,54 @@
55

66
Sample demonstrates techniques for using Testspace with Ruby code and the [`rspec` test framework](http://rspec.info/) together with [`simplecov` code coverage gem](https://github.com/colszowka/simplecov) and [`selenium-webdriver` gem](https://rubygems.org/gems/selenium-webdriver/).
77

8-
[![Build Status](https://travis-ci.org/testspace-samples/ruby.rspec.svg?branch=master)](https://travis-ci.org/testspace-samples/ruby.rspec)
9-
[![Space Health](https://samples.testspace.com/projects/85/spaces/312/badge)](https://samples.testspace.com/projects/85/spaces/312 "Test Cases")
10-
[![Space Metric](https://samples.testspace.com/projects/85/spaces/312/metrics/216/badge)](https://samples.testspace.com/projects/85/spaces/312/metrics#metric-216 "Line/Statement Coverage")
8+
***
9+
Using Multiple Online CI Services:
10+
11+
[![Build Status](https://travis-ci.org/munderseth/ruby.rspec.svg?branch=master)](https://travis-ci.org/munderseth/ruby.rspec)
12+
[![CircleCI](https://circleci.com/gh/munderseth/ruby.rspec.svg?style=svg)](https://circleci.com/gh/munderseth/ruby.rspec)
13+
[![Run Status](https://api.shippable.com/projects/57c59c86d69e8d0f0053cfd4/badge?branch=master)](https://app.shippable.com/projects/57c59c86d69e8d0f0053cfd4)
14+
15+
***
16+
Publishing **Test Content** using www.testspace.com.
17+
18+
[![Space Health](http://munderseth.stridespace.com/projects/271/spaces/906/badge)](http://munderseth.stridespace.com/projects/271/spaces/906 "Test Cases")
19+
[![Space Metric](http://munderseth.stridespace.com/projects/271/spaces/906/metrics/334/badge)](http://munderseth.stridespace.com/spaces/906/schema/Code%20Coverage "Code Coverage (lines)")
20+
[![Space Metric](http://munderseth.stridespace.com/projects/271/spaces/906/metrics/335/badge)](http://munderseth.stridespace.com/spaces/906/schema/Static%20Analysis "Static Analysis (issues)")
1121

1222
***
1323

14-
In order to run this sample you will need a host workstation with installed `ruby 2.1.1`, `bundler` and `firefox`.
24+
In order to run this sample you will need a host workstation that supports the [RSpec test framework](http://rspec.info/) with installed `ruby 2.3.0`, `bundler` and `firefox`.
25+
26+
Running Static Analysis:
1527

1628
<pre>
17-
bundle update
18-
COVERAGE=true bundle exec rake ci:setup:rspec spec
29+
bundle install
30+
bundle exec rubocop --format emacs --out tmp/rubocop.txt
31+
bundle exec brakeman -o tmp/brakeman.json
32+
bundle exec brakeman_translate_checkstyle_format translate --file="tmp/brakeman.json" > tmp/brakeman_checkstyle.xml
33+
</pre>
34+
35+
Running Tests with Code Coverage:
36+
37+
<pre>
38+
export CI_REPORTS=$PWD/spec/reports
39+
COVERAGE=true xvfb-run --server-args="-screen 0 1024x768x24" bundle exec rake ci:setup:rspec spec
1940
</pre>
2041

21-
Publishing results example:
42+
Publishing Results using **Testspace**:
2243

2344
<pre>
24-
testspace publish [Tests]spec/reports/*.xml{spec} coverage/coverage.xml
45+
curl -s https://testspace-client.s3.amazonaws.com/testspace-linux.tgz | sudo tar -zxvf- -C /usr/local/bin
46+
testspace @.testspace $TESTSPACE_TOKEN/$BRANCH_NAME
2547
</pre>
2648

27-
Checkout the [Space](https://samples.testspace.com/projects/ruby/spaces/rspec).
2849

29-
***
50+
Checkout the [Space](http://munderseth.stridespace.com/projects/ruby.rspec).
3051

31-
To fork this example using Travis requires:
52+
***
53+
To replicate this sample:
3254
- Account at www.testspace.com.
33-
- Travis Environment Variable:
34-
- `TESTSPACE_URL` = `credentials:@my-org-name.testspace.com/my-project/my-space`
55+
- Environment Variable called `TESTSPACE_TOKEN`:
3556
- `credentials` set to `username:password` or your [access token](http://help.testspace.com/using-your-organization:user-settings).
3657
- `my-org-name.testspace.com/my-project/my-space` based on your subdomain, project, and space names. Refer [here](http://help.testspace.com/reference:runner-reference#login-credentials) for more details.
58+

0 commit comments

Comments
 (0)