cucumber_monitor 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/app/assets/images/cucumber_monitor/ajax-loader.gif +0 -0
- data/app/assets/javascripts/cucumber_monitor/cucumber_monitor.js.erb +6 -0
- data/app/assets/stylesheets/cucumber_monitor/cucumber_monitor.css +38 -2
- data/app/controllers/cucumber_monitor_controller.rb +8 -0
- data/app/views/cucumber_monitor/feature_runner.js.erb +11 -0
- data/app/views/cucumber_monitor/show_feature.html.erb +14 -2
- data/app/views/layouts/cucumber_monitor.html.erb +1 -0
- data/config/locales/cucumber_monitor_views.yml +13 -0
- data/config/routes.rb +2 -0
- data/lib/cucumber_monitor/array.rb +4 -0
- data/lib/cucumber_monitor/base.rb +4 -0
- data/lib/cucumber_monitor/context.rb +3 -2
- data/lib/cucumber_monitor/feature_runner.rb +46 -0
- data/lib/cucumber_monitor/scenario.rb +2 -1
- data/lib/cucumber_monitor/step.rb +10 -5
- data/lib/cucumber_monitor/version.rb +1 -1
- data/lib/cucumber_monitor.rb +1 -0
- data/test/base_test.rb +37 -0
- data/test/context_test.rb +13 -0
- data/test/cucumber_monitor_test.rb +0 -3
- data/test/dummy/app/helpers/application_helper.rb +3 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/test.log +1272 -0
- data/test/feature_file_test.rb +21 -0
- data/test/scenario_test.rb +23 -0
- data/test/setup.rb +7 -0
- data/test/step_test.rb +36 -0
- data/test/test_helper.rb +2 -0
- metadata +24 -2
Binary file
|
@@ -1,5 +1,6 @@
|
|
1
1
|
body {
|
2
2
|
font-family: "Lucida Console";
|
3
|
+
font-size: 11px;
|
3
4
|
}
|
4
5
|
|
5
6
|
hr {
|
@@ -20,10 +21,10 @@ hr {
|
|
20
21
|
border: solid 1px #ebebeb;
|
21
22
|
border-radius: 5px;
|
22
23
|
font-size: 12px;
|
23
|
-
margin: 0;
|
24
|
+
margin: 0 auto 20px auto;
|
24
25
|
padding: 0;
|
25
26
|
margin-top: 20px;
|
26
|
-
width:
|
27
|
+
width: 100%;
|
27
28
|
}
|
28
29
|
|
29
30
|
#main table th {
|
@@ -93,4 +94,39 @@ div.feature_container .steps table td {
|
|
93
94
|
padding: 5px;
|
94
95
|
border-bottom: #ebebeb solid 1px;
|
95
96
|
border-right: #ebebeb solid 1px;
|
97
|
+
}
|
98
|
+
|
99
|
+
.step_description {
|
100
|
+
display: inline-block;
|
101
|
+
width: 100%;
|
102
|
+
}
|
103
|
+
|
104
|
+
.step_result {
|
105
|
+
width: 5%;
|
106
|
+
padding: 5px;
|
107
|
+
border: solid 1px #ccc;
|
108
|
+
display: inline-block;
|
109
|
+
float: right;
|
110
|
+
font-size: 11px;
|
111
|
+
text-align: center;
|
112
|
+
}
|
113
|
+
|
114
|
+
.run_feature {
|
115
|
+
width: 150px;
|
116
|
+
float: right;
|
117
|
+
padding: 10px;
|
118
|
+
display: block;
|
119
|
+
background: #006699;
|
120
|
+
text-align: center;
|
121
|
+
}
|
122
|
+
|
123
|
+
.run_feature a {
|
124
|
+
font-size: 11px;
|
125
|
+
text-align: center;
|
126
|
+
color: #fff;
|
127
|
+
text-decoration: none;
|
128
|
+
}
|
129
|
+
|
130
|
+
.td_result {
|
131
|
+
width: 6%;
|
96
132
|
}
|
@@ -16,4 +16,12 @@ class CucumberMonitorController < ApplicationController
|
|
16
16
|
@steps_search_results = CucumberMonitor.new.search(params[:criteria])
|
17
17
|
end
|
18
18
|
|
19
|
+
def feature_runner
|
20
|
+
respond_to do |format|
|
21
|
+
format.js do
|
22
|
+
@json_feature_result = CucumberMonitor::FeatureRunner.run_and_return_json(name: params[:name])
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
19
27
|
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
$(function() {
|
2
|
+
<% @json_feature_result.first['elements'].each do |element| %>
|
3
|
+
<% element['steps'].each do |step| %>
|
4
|
+
<% status = step['result']['status'] %>
|
5
|
+
$("#<%= step['code'] %>").html('<%= t("results.#{status}") || status %>');
|
6
|
+
<% end %>
|
7
|
+
<% end %>
|
8
|
+
|
9
|
+
$("#run_feature_link").html("Executar feature");
|
10
|
+
|
11
|
+
});
|
@@ -8,13 +8,20 @@
|
|
8
8
|
<%= link_to t("links.back_to_features_link"), features_cucumber_monitor_path %>
|
9
9
|
</p>
|
10
10
|
|
11
|
+
<div class="run_feature"><%= link_to 'Executar feature', feature_runner_cucumber_monitor_path(@feature.name), remote: true, id: 'run_feature_link' %></div>
|
12
|
+
|
11
13
|
<% if @feature.contexts.any? %>
|
12
14
|
<div class="feature_container context">
|
13
15
|
<% @feature.contexts.each do |context|%>
|
14
16
|
<h4><%= t(".background") %></h4>
|
15
17
|
<div class="steps">
|
16
18
|
<% context.steps.each do |step| %>
|
17
|
-
|
19
|
+
<div class="step_description">
|
20
|
+
<%= step.formatted.html_safe %>
|
21
|
+
<% if step.not_a_table %>
|
22
|
+
<div class="step_result" id="<%= step.code %>">-</div>
|
23
|
+
<% end %>
|
24
|
+
</div>
|
18
25
|
<% if step.not_a_table %>
|
19
26
|
<hr />
|
20
27
|
<% end %>
|
@@ -29,7 +36,12 @@
|
|
29
36
|
<h4><%= "#{t(".scenario")} #{scenario.name}" %></h4>
|
30
37
|
<div class="steps">
|
31
38
|
<% scenario.steps.each do |step| %>
|
32
|
-
|
39
|
+
<div class="step_description">
|
40
|
+
<%= step.formatted.html_safe %>
|
41
|
+
<% if step.not_a_table %>
|
42
|
+
<div class="step_result" id="<%= step.code %>">-</div>
|
43
|
+
<% end %>
|
44
|
+
</div>
|
33
45
|
<% if step.not_a_table %>
|
34
46
|
<hr />
|
35
47
|
<% end %>
|
@@ -3,6 +3,7 @@
|
|
3
3
|
<head>
|
4
4
|
<title>Cucumber Monitor</title>
|
5
5
|
<%= stylesheet_link_tag "cucumber_monitor/cucumber_monitor", :media => "all" %>
|
6
|
+
<%= javascript_include_tag "jquery", "jquery_ujs", "cucumber_monitor/cucumber_monitor", :media => "all" %>
|
6
7
|
<%= csrf_meta_tags %>
|
7
8
|
</head>
|
8
9
|
<body>
|
@@ -1,4 +1,8 @@
|
|
1
1
|
"pt-BR":
|
2
|
+
results:
|
3
|
+
passed: passou
|
4
|
+
failed: falhou
|
5
|
+
skipped: pulou
|
2
6
|
buttons:
|
3
7
|
search: Buscar
|
4
8
|
links:
|
@@ -16,6 +20,7 @@
|
|
16
20
|
feature: Funcionalidade
|
17
21
|
background: Contexto
|
18
22
|
scenario: Cenário
|
23
|
+
|
19
24
|
search:
|
20
25
|
title: Busca
|
21
26
|
search_results: Resultados da busca
|
@@ -26,6 +31,10 @@
|
|
26
31
|
results_not_found_for: "Nenhum resultado encontrado para '<strong>%{criteria}</strong>'"
|
27
32
|
|
28
33
|
"en":
|
34
|
+
results:
|
35
|
+
passed: passou
|
36
|
+
failed: falhou
|
37
|
+
skipped: pulou
|
29
38
|
buttons:
|
30
39
|
search: Search
|
31
40
|
links:
|
@@ -43,6 +52,10 @@
|
|
43
52
|
feature: Feature
|
44
53
|
background: Background
|
45
54
|
scenario: Scenario
|
55
|
+
results:
|
56
|
+
passed: passou
|
57
|
+
failed: falhou
|
58
|
+
skipped: pulou
|
46
59
|
search:
|
47
60
|
title: Search
|
48
61
|
search_results: Search results
|
data/config/routes.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
Rails.application.routes.draw do
|
2
2
|
resource :cucumber_monitor, only: [] do
|
3
|
+
get '/' => 'cucumber_monitor#features', as: 'features'
|
3
4
|
get 'features' => 'cucumber_monitor#features', as: 'features'
|
4
5
|
get 'show_feature/:name' => 'cucumber_monitor#show_feature', as: 'show_feature'
|
5
6
|
get 'search' => 'cucumber_monitor#search', as: 'search'
|
7
|
+
get 'feature_runner/:name' => 'cucumber_monitor#feature_runner', as: 'feature_runner'
|
6
8
|
end
|
7
9
|
end
|
@@ -8,6 +8,10 @@ class Array
|
|
8
8
|
result << item
|
9
9
|
end
|
10
10
|
|
11
|
+
if item.respond_to?(:description) && !item.description.nil? && !options[:description].nil? && item.description.include?(options[:description])
|
12
|
+
result << item
|
13
|
+
end
|
14
|
+
|
11
15
|
if item.respond_to?(:id) && item.id == options[:id]
|
12
16
|
result << item
|
13
17
|
end
|
@@ -4,10 +4,11 @@ module CucumberMonitor
|
|
4
4
|
|
5
5
|
class Context
|
6
6
|
|
7
|
-
attr_accessor :name, :feature
|
7
|
+
attr_accessor :name, :keyword, :feature
|
8
8
|
|
9
9
|
def initialize(name,feature)
|
10
10
|
@name = name
|
11
|
+
@keyword = I18n.t("background")
|
11
12
|
@feature = feature
|
12
13
|
end
|
13
14
|
|
@@ -18,7 +19,7 @@ module CucumberMonitor
|
|
18
19
|
record = false
|
19
20
|
count = 0
|
20
21
|
feature.lines.each_with_index do |line, i|
|
21
|
-
if line.include?(
|
22
|
+
if line.include?(keyword)
|
22
23
|
started = true
|
23
24
|
end
|
24
25
|
if started && !stopped
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module CucumberMonitor
|
2
|
+
|
3
|
+
class FeatureRunner
|
4
|
+
|
5
|
+
def self.command(feature)
|
6
|
+
"bundle exec cucumber features/#{feature}.feature --format json --out tmp/cucumber.out"
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.run(options={})
|
10
|
+
`#{command(options[:name])}` if options.has_key?(:name)
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.json
|
14
|
+
JSON.parse(File.open(CucumberMonitor::Base.cucumber_output_file).read)
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.run_and_return_json(options={})
|
18
|
+
run(options)
|
19
|
+
json
|
20
|
+
prepare
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.elements
|
24
|
+
json.first['elements'].map{|e| "#{e['keyword']}: #{e['name']}"}
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.prepare
|
28
|
+
prepared_json = json
|
29
|
+
prepared_json.first['elements'].each do |element|
|
30
|
+
element['steps'].each do |step|
|
31
|
+
description = "#{step['keyword']}#{step['name']}"
|
32
|
+
code_first_part = element['name'].blank? ? element['keyword'].parameterize : element['name'].parameterize
|
33
|
+
code_second_part = description.parameterize
|
34
|
+
code = "#{code_first_part}-#{code_second_part}"
|
35
|
+
step.merge!({
|
36
|
+
'description' => description,
|
37
|
+
'code' => code.parameterize
|
38
|
+
})
|
39
|
+
end
|
40
|
+
end
|
41
|
+
prepared_json
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
@@ -2,24 +2,27 @@ module CucumberMonitor
|
|
2
2
|
|
3
3
|
class Step
|
4
4
|
|
5
|
-
attr_accessor :description, :parent, :id
|
5
|
+
attr_accessor :description, :code, :parent, :id
|
6
6
|
|
7
7
|
def initialize(description, parent, id)
|
8
8
|
@description = description.strip
|
9
|
+
code_first_part = parent.name.blank? ? parent.keyword.parameterize : parent.name.parameterize
|
10
|
+
code_second_part = @description.parameterize
|
11
|
+
@code = "#{code_first_part}-#{code_second_part}"
|
9
12
|
@parent = parent
|
10
13
|
@id = id
|
11
14
|
end
|
12
15
|
|
13
|
-
def
|
14
|
-
parent.steps
|
16
|
+
def siblings_and_self
|
17
|
+
parent.steps
|
15
18
|
end
|
16
19
|
|
17
20
|
def previous
|
18
|
-
|
21
|
+
siblings_and_self.where(id: self.id - 1)
|
19
22
|
end
|
20
23
|
|
21
24
|
def next
|
22
|
-
|
25
|
+
siblings_and_self.where(id: self.id + 1)
|
23
26
|
end
|
24
27
|
|
25
28
|
def table?
|
@@ -56,6 +59,7 @@ module CucumberMonitor
|
|
56
59
|
table_content.each do |th|
|
57
60
|
output << " <th>#{th}</th>\n"
|
58
61
|
end
|
62
|
+
output << " <th> </th>"
|
59
63
|
output << " </tr>\n"
|
60
64
|
output << "</table>\n" if table_last_line?
|
61
65
|
elsif table_row?
|
@@ -63,6 +67,7 @@ module CucumberMonitor
|
|
63
67
|
table_content.each do |td|
|
64
68
|
output << " <td>#{td}</td>\n"
|
65
69
|
end
|
70
|
+
output << " <td class='td_result'> </td>"
|
66
71
|
output << " </tr>\n"
|
67
72
|
output << "</table>\n" if table_last_line?
|
68
73
|
else
|
data/lib/cucumber_monitor.rb
CHANGED
data/test/base_test.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class BaseTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
test "should return all features" do
|
6
|
+
assert_equal 2, @cucumber.features.size
|
7
|
+
|
8
|
+
features = ['administration.feature','change_my_data.feature']
|
9
|
+
assert_equal features, @cucumber.features.map(&:file)
|
10
|
+
end
|
11
|
+
|
12
|
+
test "should find features by searching" do
|
13
|
+
assert_equal 2, @cucumber.features.where(name: 'a').size
|
14
|
+
features = ['administration.feature','change_my_data.feature']
|
15
|
+
assert_equal features, @cucumber.features.where(name: 'a').map(&:file)
|
16
|
+
|
17
|
+
assert_equal 'administration.feature', @cucumber.features.where(name: 'admin').file
|
18
|
+
assert_equal 'change_my_data.feature', @cucumber.features.where(name: 'change').file
|
19
|
+
end
|
20
|
+
|
21
|
+
test 'should find all steps that matches with a given term' do
|
22
|
+
assert_equal 4, @cucumber.search("email").size
|
23
|
+
|
24
|
+
term = 'I should see'
|
25
|
+
|
26
|
+
steps = [
|
27
|
+
'Then I should see "Invalid username/password"',
|
28
|
+
'Then I should see my personal information',
|
29
|
+
'Then I should see "Personal data successfully changed"',
|
30
|
+
'And I should see "Petter Summers"',
|
31
|
+
'I should see the following table:'
|
32
|
+
]
|
33
|
+
|
34
|
+
assert_equal steps, @cucumber.search(term).map(&:description)
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ContextTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
test "context should return its steps" do
|
6
|
+
assert_equal 1, @feature_two.contexts.first.steps.size
|
7
|
+
|
8
|
+
step_1 = 'Given my name is Peter and I have an account in the system'
|
9
|
+
|
10
|
+
assert_equal step_1, @feature_two.contexts.first.steps[0].description
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
File without changes
|
File without changes
|