delinquo 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +39 -0
  6. data/Rakefile +65 -0
  7. data/bin/delinquo +14 -0
  8. data/config/database.rb +18 -0
  9. data/config.ru +7 -0
  10. data/db/migrate/20130925071434_create_projects.rb +13 -0
  11. data/db/migrate/20130927101642_create_projects.rb +13 -0
  12. data/db/migrate/20130927101721_create_runs.rb +14 -0
  13. data/db/migrate/20130927104041_create_fails.rb +17 -0
  14. data/db/migrate/20130927161238_change_run_total_to_int.rb +5 -0
  15. data/db/migrate/20130927161545_change_run_total_to_string.rb +5 -0
  16. data/db/schema.rb +44 -0
  17. data/delinquo.gemspec +31 -0
  18. data/lib/delinquo/version.rb +3 -0
  19. data/lib/delinquo.rb +112 -0
  20. data/lib/public/css/bootstrap.css +4692 -0
  21. data/lib/public/css/bootstrap.min.css +9 -0
  22. data/lib/public/css/main.css +132 -0
  23. data/lib/public/images/changeable.svg +51 -0
  24. data/lib/public/images/cloud.svg +3 -0
  25. data/lib/public/images/rain.svg +7 -0
  26. data/lib/public/images/storm.svg +3 -0
  27. data/lib/public/images/sun.svg +3 -0
  28. data/lib/public/images/umbrella.svg +3 -0
  29. data/lib/public/index.html +9 -0
  30. data/lib/public/js/bootstrap.js +1966 -0
  31. data/lib/public/js/bootstrap.min.js +6 -0
  32. data/lib/views/index.erb +56 -0
  33. data/lib/views/layout.erb +16 -0
  34. data/lib/views/no_runs.erb +1 -0
  35. data/lib/views/not_a_project.erb +4 -0
  36. data/models/fail.rb +4 -0
  37. data/models/project.rb +38 -0
  38. data/models/run.rb +47 -0
  39. data/spec/api_spec.rb +141 -0
  40. data/spec/models/fail_spec.rb +18 -0
  41. data/spec/models/project_spec.rb +74 -0
  42. data/spec/models/run_spec.rb +82 -0
  43. data/spec/report_spec.rb +207 -0
  44. data/spec/spec_helper.rb +79 -0
  45. metadata +206 -0
@@ -0,0 +1,207 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Report' do
4
+
5
+ before(:each) do
6
+ @project = Project.create!(name: 'delinquo')
7
+ end
8
+
9
+ after(:each) do
10
+ Project.delete_all
11
+ end
12
+
13
+ describe 'Project info' do
14
+
15
+ it 'has the correct page title' do
16
+ visit '/report/delinquo'
17
+ page.title.should == "Delinquo"
18
+ end
19
+
20
+ it 'has the name of the project in an h1' do
21
+ visit '/report/delinquo'
22
+ page.should have_css('h1', text: 'Delinquo')
23
+ end
24
+
25
+ end
26
+
27
+ describe 'warns when a project does not exist' do
28
+
29
+ it 'should have a warning message' do
30
+ visit '/report/cookies'
31
+ page.should have_css('.not_a_project', text: "That is not a project.")
32
+ end
33
+
34
+ it 'should have a warning icon' do
35
+ visit '/report/cookiescrumbs'
36
+ page.find('#warning')[:src].should == '/images/umbrella.svg'
37
+ end
38
+
39
+ end
40
+
41
+ describe 'Forcast icon' do
42
+
43
+ it 'has a forecast icon' do
44
+ add_runs 10, 'passing'
45
+ visit '/report/delinquo'
46
+ page.should have_css('#forecast')
47
+ end
48
+
49
+ it 'has a sun icon when all runs passed' do
50
+ add_runs 10, 'passing'
51
+ visit '/report/delinquo'
52
+ page.find('#forecast')[:src].should == '/images/sun.svg'
53
+ end
54
+
55
+ it 'has a changable icon when between one and three runs fail' do
56
+ add_runs 9, 'passing'
57
+ add_runs 1, 'failing'
58
+
59
+ visit '/report/delinquo'
60
+ page.find('#forecast')[:src].should == '/images/changeable.svg'
61
+ end
62
+
63
+ it 'has a cloud icon when between four and six runs fail' do
64
+ add_runs 6, 'passing'
65
+ add_runs 4, 'failing'
66
+
67
+ visit '/report/delinquo'
68
+ page.find('#forecast')[:src].should == '/images/cloud.svg'
69
+ end
70
+
71
+ it 'has a rain cloud icon when between seven and nine runs fail' do
72
+ add_runs 3, 'passing'
73
+ add_runs 7, 'failing'
74
+
75
+ visit '/report/delinquo'
76
+ page.find('#forecast')[:src].should == '/images/rain.svg'
77
+ end
78
+
79
+ it 'has a storm cloud icon when ten runs fail' do
80
+ add_runs 10, 'failing'
81
+
82
+ visit '/report/delinquo'
83
+ page.find('#forecast')[:src].should == '/images/storm.svg'
84
+ end
85
+
86
+ end
87
+
88
+ describe 'Top fail' do
89
+
90
+ it 'has the correct top fail in the top fail section' do
91
+ add_runs_with_a_top_fail
92
+ visit '/report/delinquo'
93
+
94
+ page.should have_css("#top_fail", text: 'this is the most fequently failing test')
95
+ end
96
+
97
+ end
98
+
99
+ describe 'Last ten runs list' do
100
+
101
+ it 'has the last ten runs' do
102
+ add_runs 10
103
+
104
+ visit '/report/delinquo'
105
+ page.all('#runs a').count.should == 10
106
+ end
107
+
108
+ it 'each run has its own collapsable element' do
109
+ add_runs 10
110
+
111
+ visit '/report/delinquo'
112
+ page.all('.accordion-body').each_with_index do |element,index|
113
+ element[:id].should == 'run_' + (index + 1).to_s
114
+ end
115
+ end
116
+
117
+ it 'each run has its own link that open / closes its collapsable element' do
118
+ add_runs 10
119
+
120
+ visit '/report/delinquo'
121
+ page.all('.accordion-toggle').each_with_index do |element,index|
122
+ element[:href].should == '#run_' + (index + 1).to_s
123
+ end
124
+ end
125
+
126
+ it 'gives each passing run a passed title' do
127
+ add_runs 10, 'passing'
128
+
129
+ visit '/report/delinquo'
130
+ page.all('.accordion-toggle span.status').each_with_index do |element|
131
+ element.text.should == 'Passed'
132
+ end
133
+ end
134
+
135
+ it 'gives each failing run a failed title' do
136
+ add_runs 10
137
+
138
+ visit '/report/delinquo'
139
+ page.all('.accordion-toggle span.status').each_with_index do |element|
140
+ element.text.should == 'Failed'
141
+ end
142
+ end
143
+
144
+ it 'should show a feature, scenario, step and line in a failing runs collapsable element' do
145
+ add_runs 1
146
+
147
+ visit '/report/delinquo'
148
+ page.find('.accordion-inner').should have_content('Feature: a feature Scenario: a scenario Step: a step Line: a line')
149
+ end
150
+
151
+ it 'should not have a collapsable element for a passing run' do
152
+ add_runs 1, 'passing'
153
+
154
+ visit '/report/delinquo'
155
+ page.should_not have_css('.accordion-body')
156
+ end
157
+
158
+ it 'should have a data and time for each run' do
159
+ add_run
160
+ run_id = @project.runs.first.id
161
+ @project.runs.update(run_id, created_at: "2013-10-13 13:21:10")
162
+ visit '/report/delinquo'
163
+ page.should have_css('.date-time', :text => '13/10/2013 14.21')
164
+ end
165
+
166
+ end
167
+
168
+ describe 'Progression bar' do
169
+
170
+ it 'should have a bar with 100% green if the tests all passed in a run' do
171
+ add_run 'passed'
172
+ visit '/report/delinquo'
173
+
174
+ page.find('.progress-bar-success').native.attributes['style'].value.should == "width: 100%"
175
+ page.find('.progress-bar-danger').native.attributes['style'].value.should == "width: 0%"
176
+ end
177
+
178
+ it 'should have a progression bar with mostly green and some red when 2 tests fails out of 500' do
179
+ add_run 'failing'
180
+
181
+ visit '/report/delinquo'
182
+ page.find('.progress-bar-success').native.attributes['style'].value.should == "width: 99%"
183
+ page.find('.progress-bar-danger').native.attributes['style'].value.should == "width: 1%"
184
+ end
185
+
186
+ end
187
+
188
+ describe 'Expander' do
189
+
190
+ it 'should show the number of failing and passing tests' do
191
+ add_run 'failing'
192
+
193
+ visit '/report/delinquo'
194
+ page.should have_css('.total-number-of-fails', text: '2')
195
+ page.should have_css('.total-number-of-passes', text: '498')
196
+ end
197
+
198
+ it 'should show the full command to run all the failing test' do
199
+ add_run 'failing'
200
+
201
+ visit '/report/delinquo'
202
+ page.should have_css('.run-fails', text: 'bundle exec cucumber a line')
203
+ end
204
+
205
+ end
206
+
207
+ end
@@ -0,0 +1,79 @@
1
+ ENV['RACK_ENV'] = "test"
2
+
3
+ require_relative '../lib/delinquo'
4
+ require 'rspec'
5
+ require 'rack/test'
6
+ require 'capybara/rspec'
7
+
8
+ ActiveRecord::Base.logger = nil
9
+
10
+ Capybara.app = Delinquo::App
11
+
12
+ def app
13
+ Delinquo::App
14
+ end
15
+
16
+ RSpec.configure do |conf|
17
+ conf.include Rack::Test::Methods
18
+ conf.include Capybara::DSL
19
+ conf.before(:all) do
20
+ puts "\nCurrrent Database: " + ActiveRecord::Base.connection.instance_variable_get(:@config)[:database]
21
+ end
22
+ end
23
+
24
+ def check_status(code)
25
+ last_response.status.should == code
26
+ end
27
+
28
+ def json_for_a_run_with_two_fails
29
+ {
30
+ total: '500',
31
+ fails: [
32
+ { feature: "a feature", scenario: "a scenario", step: "a step", line: "a line"},
33
+ { feature: "a feature", scenario: "a scenario", step: "a step", line: "a line"}
34
+ ]
35
+ }.to_json
36
+ end
37
+
38
+ def json_for_a_passing_run
39
+ {
40
+ total: '500',
41
+ fails: []
42
+ }.to_json
43
+ end
44
+
45
+
46
+ def json_for_a_run_with_a_top_fail
47
+ {
48
+ total: '500',
49
+ fails: [
50
+ { feature: "a feature", scenario: "a scenario", step: "a step", line: "this is the most fequently failing test"},
51
+ { feature: "a feature", scenario: "a scenario", step: "a step", line: "this is the most fequently failing test"},
52
+ { feature: "a feature", scenario: "a scenario", step: "a step", line: "this is the most fequently failing test"},
53
+ { feature: "a feature", scenario: "a scenario", step: "a step", line: "this is the most fequently failing test"},
54
+ { feature: "a feature", scenario: "a scenario", step: "a step", line: "this is the most fequently failing test"}
55
+ ]
56
+ }.to_json
57
+ end
58
+
59
+ def add_runs_with_a_top_fail
60
+ 2.times do
61
+ post '/project/delinquo/run', json_for_a_run_with_two_fails
62
+ check_status 201
63
+ end
64
+ post '/project/delinquo/run', json_for_a_run_with_a_top_fail
65
+ check_status 201
66
+ end
67
+
68
+
69
+ def add_runs(number=2,state='failing')
70
+ number.times do
71
+ post '/project/delinquo/run', (state == 'failing')? json_for_a_run_with_two_fails : json_for_a_passing_run
72
+ check_status 201
73
+ end
74
+ end
75
+
76
+ def add_run(state='failing')
77
+ post '/project/delinquo/run', (state == 'failing')? json_for_a_run_with_two_fails : json_for_a_passing_run
78
+ check_status 201
79
+ end
metadata ADDED
@@ -0,0 +1,206 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: delinquo
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ platform: ruby
6
+ authors:
7
+ - Steven Cook
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-12-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: thin
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: sinatra
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: sinatra-activerecord
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: sqlite3
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: json
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rake
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description: Commit a fault
126
+ email:
127
+ - stevenjamescook@gmail.com
128
+ executables:
129
+ - delinquo
130
+ extensions: []
131
+ extra_rdoc_files: []
132
+ files:
133
+ - .gitignore
134
+ - Gemfile
135
+ - LICENSE.txt
136
+ - README.md
137
+ - Rakefile
138
+ - bin/delinquo
139
+ - config.ru
140
+ - config/database.rb
141
+ - db/migrate/20130925071434_create_projects.rb
142
+ - db/migrate/20130927101642_create_projects.rb
143
+ - db/migrate/20130927101721_create_runs.rb
144
+ - db/migrate/20130927104041_create_fails.rb
145
+ - db/migrate/20130927161238_change_run_total_to_int.rb
146
+ - db/migrate/20130927161545_change_run_total_to_string.rb
147
+ - db/schema.rb
148
+ - delinquo.gemspec
149
+ - lib/delinquo.rb
150
+ - lib/delinquo/version.rb
151
+ - lib/public/css/bootstrap.css
152
+ - lib/public/css/bootstrap.min.css
153
+ - lib/public/css/main.css
154
+ - lib/public/images/changeable.svg
155
+ - lib/public/images/cloud.svg
156
+ - lib/public/images/rain.svg
157
+ - lib/public/images/storm.svg
158
+ - lib/public/images/sun.svg
159
+ - lib/public/images/umbrella.svg
160
+ - lib/public/index.html
161
+ - lib/public/js/bootstrap.js
162
+ - lib/public/js/bootstrap.min.js
163
+ - lib/views/index.erb
164
+ - lib/views/layout.erb
165
+ - lib/views/no_runs.erb
166
+ - lib/views/not_a_project.erb
167
+ - models/fail.rb
168
+ - models/project.rb
169
+ - models/run.rb
170
+ - spec/api_spec.rb
171
+ - spec/models/fail_spec.rb
172
+ - spec/models/project_spec.rb
173
+ - spec/models/run_spec.rb
174
+ - spec/report_spec.rb
175
+ - spec/spec_helper.rb
176
+ homepage: ''
177
+ licenses:
178
+ - MIT
179
+ metadata: {}
180
+ post_install_message:
181
+ rdoc_options: []
182
+ require_paths:
183
+ - lib
184
+ required_ruby_version: !ruby/object:Gem::Requirement
185
+ requirements:
186
+ - - '>='
187
+ - !ruby/object:Gem::Version
188
+ version: '0'
189
+ required_rubygems_version: !ruby/object:Gem::Requirement
190
+ requirements:
191
+ - - '>='
192
+ - !ruby/object:Gem::Version
193
+ version: '0'
194
+ requirements: []
195
+ rubyforge_project:
196
+ rubygems_version: 2.0.5
197
+ signing_key:
198
+ specification_version: 4
199
+ summary: A really simple cucumber failure monitoring api
200
+ test_files:
201
+ - spec/api_spec.rb
202
+ - spec/models/fail_spec.rb
203
+ - spec/models/project_spec.rb
204
+ - spec/models/run_spec.rb
205
+ - spec/report_spec.rb
206
+ - spec/spec_helper.rb