cuukie 0.1.4 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,22 +1,7 @@
1
1
  require 'spec_helper'
2
-
3
- describe "The cuukie_server command" do
4
- it "starts the Cuukie server on port 4569 by default" do
5
- start_process "ruby bin/cuukie_server >/dev/null 2>&1"
6
- wait_for_server_on_port 4569
7
- stop_server_on_port 4569
8
- end
9
-
10
- it "starts the Cuukie server on any given port" do
11
- start_process "ruby bin/cuukie_server 4570 >/dev/null 2>&1"
12
- wait_for_server_on_port 4570
13
- stop_server_on_port 4570
14
- end
15
- end
2
+ require 'tempfile'
16
3
 
17
4
  describe "The cuukie formatter" do
18
- require 'tempfile'
19
-
20
5
  before :each do
21
6
  @out = Tempfile.new('cuukie.tmp')
22
7
  end
@@ -27,11 +12,11 @@ describe "The cuukie formatter" do
27
12
 
28
13
  it "expects a server on localhost:4569 by default" do
29
14
  begin
30
- start_process "ruby bin/cuukie_server 4569 >/dev/null 2>&1"
15
+ start_process "ruby bin/cuukie --server >/dev/null 2>&1"
31
16
  wait_for_server_on_port 4569
32
17
  cmd = "cd spec/test_project && \
33
18
  cucumber features/1_show_scenarios.feature:9 \
34
- --format cuukie > #{@out.path}"
19
+ --format cuukie >#{@out.path}"
35
20
  system(cmd).should be_true
36
21
  @out.read.should == ''
37
22
  ensure
@@ -40,13 +25,13 @@ describe "The cuukie formatter" do
40
25
  end
41
26
 
42
27
  it "can point to a different server" do
43
- start_process "ruby bin/cuukie_server 4570 >/dev/null 2>&1"
28
+ start_process "ruby bin/cuukie --server --cuukieport 4570 >/dev/null 2>&1"
44
29
  begin
45
30
  wait_for_server_on_port 4570
46
31
  cmd = "cd spec/test_project && \
47
32
  cucumber features/1_show_scenarios.feature:9 \
48
33
  CUUKIE_SERVER=http://localhost:4570 \
49
- --format cuukie > #{@out.path}"
34
+ --format cuukie >#{@out.path}"
50
35
  system(cmd).should be_true
51
36
  @out.read.should == ''
52
37
  ensure
@@ -58,8 +43,74 @@ describe "The cuukie formatter" do
58
43
  cmd = "cd spec/test_project && \
59
44
  cucumber features/1_show_scenarios.feature:9 \
60
45
  CUUKIE_SERVER=http://some.server:4570 \
61
- --format cuukie > #{@out.path}"
46
+ --format cuukie >#{@out.path}"
62
47
  system(cmd).should be_true
63
- @out.read.should match 'I cannot find the cuukie_server on http://some.server:4570'
48
+ @out.read.should match 'I cannot find the cuukie server on http://some.server:4570'
49
+ end
50
+ end
51
+
52
+ describe "The cuukie command" do
53
+ before(:each) { @out = Tempfile.new('cuukie.tmp') }
54
+ after(:each) { @out.delete }
55
+
56
+ it "shows help with --help" do
57
+ system "ruby bin/cuukie --help >#{@out.path}"
58
+ @out.read.should match /Usage: cuukie \[options\]/
59
+ end
60
+
61
+ it "starts the server and runs cucumber with the cuukie formatter" do
62
+ system "ruby bin/cuukie spec/test_project/features/ \
63
+ --require spec/test_project/features/step_definitions/ \
64
+ --require lib/cuukie \
65
+ --nowait \
66
+ --keepserver \
67
+ >/dev/null 2>&1"
68
+
69
+ html.should match "Passing Scenario"
70
+ stop_server_on_port 4569
71
+ end
72
+
73
+ it "gives instructions to access the page if --showpage is not enabled" do
74
+ system "ruby bin/cuukie spec/test_project/features/ \
75
+ --require spec/test_project/features/step_definitions/ \
76
+ --require lib/cuukie \
77
+ --nowait \
78
+ --cuukieport 4570 \
79
+ >#{@out.path}"
80
+
81
+ @out.read.should match 'View your features at http://localhost:4570'
82
+ end
83
+
84
+ it "closes the server on exit" do
85
+ system "ruby bin/cuukie spec/test_project/features/ \
86
+ --require spec/test_project/features/step_definitions/ \
87
+ --require lib/cuukie \
88
+ --nowait \
89
+ --cuukieport 4570 \
90
+ >/dev/null 2>&1"
91
+
92
+ lambda { ping_on_port 4570 }.should raise_error
93
+ end
94
+
95
+ describe "when used with the --server switch" do
96
+ it "starts the Cuukie server on port 4569 by default" do
97
+ start_process "ruby bin/cuukie --server >/dev/null 2>&1"
98
+ wait_for_server_on_port 4569
99
+ stop_server_on_port 4569
100
+ end
101
+
102
+ it "starts the Cuukie server on any given port" do
103
+ start_process "ruby bin/cuukie --server --cuukieport 4570 >/dev/null 2>&1"
104
+ wait_for_server_on_port 4570
105
+ stop_server_on_port 4570
106
+ end
107
+
108
+ it "exits immediately after starting the server" do
109
+ start_process "ruby bin/cuukie --server >/dev/null 2>&1"
110
+ wait_for_server_on_port 4569
111
+ html.should match /Cuukie/
112
+ html.should_not match /Feature:/
113
+ stop_server_on_port 4569
114
+ end
64
115
  end
65
116
  end
@@ -1,11 +1,102 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe 'Cuukie' do
4
- before(:all) { start_server }
5
- after(:all) { stop_server_on_port 4569 }
4
+ describe "before Cucumber has run" do
5
+ before(:all) { start_server }
6
+ after(:all) { stop_server_on_port 4569 }
7
+
8
+ it "shows a grey status bar" do
9
+ html.should match /undefinedColors\('cucumber-header'\)/
10
+ end
11
+
12
+ it "shows no features" do
13
+ html.should_not match "Feature:"
14
+ end
15
+
16
+ it "shows zero running time" do
17
+ html.should match "Running time: <strong>0':0''</strong>"
18
+ end
19
+
20
+ it "doesn't show end-of-features stats" do
21
+ html.should_not match /\d+ scenarios \(.*\)/
22
+ html.should_not match /\d+ steps \(.*\)/
23
+ end
24
+ end
25
+
26
+ shared_examples_for "while Cucumber is running" do
27
+ require 'ostruct'
28
+
29
+ after(:all) { stop_server_on_port 4569 }
30
+
31
+ it "shows a grey status bar" do
32
+ html.should match /undefinedColors\('cucumber-header'\)/
33
+ end
34
+
35
+ it "shows incomplete description for features" do
36
+ html.should match '>...: Stuff That Works<'
37
+ @formatter.feature_name 'Feature'
38
+ html.should match '>Feature: Stuff That Works<'
39
+ end
40
+
41
+ it "shows incomplete scenarios in grey" do
42
+ @formatter.scenario_name 'Scenario','Do Stuff', 'file.rb:10'
43
+ html.should match /undefinedColors\('scenario_1_1'\)/
44
+ end
45
+
46
+ it "shows incomplete steps in grey" do
47
+ @formatter.before_step OpenStruct.new(:keyword => 'Given',
48
+ :name => 'I do something',
49
+ :file_colon_line => 'file.rb:11' )
50
+ html.should match 'class="step undefined"'
51
+ end
52
+
53
+ it "shows partial running time" do
54
+ html.should_not match "Finished in"
55
+ html.should match /Running time: <strong>\d+\':\d+\'\'<\/strong>/
56
+ end
57
+
58
+ it "doesn't show end-of-features stats" do
59
+ html.should_not match /\d+ scenarios \(.*\)/
60
+ html.should_not match /\d+ steps \(.*\)/
61
+ end
62
+ end
63
+
64
+ describe "while Cucumber is running for the first time" do
65
+ before(:all) do
66
+ start_server
67
+ @formatter = Cuukie::Formatter.new
68
+
69
+ @formatter.before_features
70
+ @formatter.before_feature OpenStruct.new(:short_name => 'Stuff That Works',
71
+ :description => 'As somebody...')
72
+ end
73
+
74
+ it_behaves_like "while Cucumber is running"
75
+ end
6
76
 
7
- describe 'in the content area' do
8
- before(:all) { run_cucumber }
77
+ describe "while Cucumber is running for the nth time" do
78
+ before(:all) do
79
+ start_server
80
+ @formatter = Cuukie::Formatter.new
81
+
82
+ @formatter.before_features
83
+ @formatter.after_features OpenStruct.new(:duration => 70)
84
+
85
+ @formatter.before_features
86
+ @formatter.before_feature OpenStruct.new(:short_name => 'Stuff That Works',
87
+ :description => 'As somebody...')
88
+ end
89
+
90
+ it_behaves_like "while Cucumber is running"
91
+ end
92
+
93
+ describe "once Cucumber has run" do
94
+ before(:all) do
95
+ start_server
96
+ run_cucumber
97
+ end
98
+
99
+ after(:all) { stop_server_on_port 4569 }
9
100
 
10
101
  it "cleans up previous data at the beginning of a run" do
11
102
  run_cucumber
@@ -30,11 +121,11 @@ describe 'Cuukie' do
30
121
  html.should match '>features&#x2F;1_show_scenarios.feature:'
31
122
  end
32
123
 
33
- it "shows the passed scenarios in green" do
124
+ it "shows passed scenarios in green" do
34
125
  html.should match /passedColors\('scenario_1_1'\)/
35
126
  end
36
127
 
37
- it "shows the failed scenarios in red" do
128
+ it "shows failed scenarios in red" do
38
129
  html.should match /failedColors\('scenario_3_1'\)/
39
130
  end
40
131
 
@@ -54,7 +145,7 @@ describe 'Cuukie' do
54
145
  end
55
146
 
56
147
  it "shows the step source position" do
57
- html.should match '>features&#x2F;step_definitions&#x2F;main_steps.rb:'
148
+ html.should match '>.&#x2F;features&#x2F;step_definitions&#x2F;main_steps.rb:'
58
149
  end
59
150
 
60
151
  it "shows the step status" do
@@ -63,17 +154,17 @@ describe 'Cuukie' do
63
154
  end
64
155
 
65
156
  it "shows exception messages" do
66
- html.should match /main_steps.rb:7<\/span><\/div>[ \n]*<div class="message"><pre>Crash!<\/pre><\/div>/
157
+ html.should match /1_show_scenarios.feature:16<\/span><\/div>[ \n]*<div class=\"message\"><pre>Crash!/
67
158
  end
68
159
 
69
160
  it "shows exception backtraces" do
70
- html.should match 'backtrace"><pre>.&#x2F;features&#x2F;step_definitions&#x2F;main_steps.rb:8:in `&#x2F;I do'
71
- html.should match '3_failed_background.feature:7:in `Given I do'
161
+ html.should match 'features&#x2F;3_failed_background.feature:7:in `Given a Background Step fails&#x27;'
162
+ html.should match '3_failed_background.feature:7:in `Given a Background Step'
72
163
  end
73
164
 
74
165
  it "shows exception source snippets" do
75
166
  html.should match '<pre class="ruby"><code><span class="linenum">6<\/span>'
76
- html.should match '<span class="constant">I</span> <span class="keyword">do</span> <span class="ident">something'
167
+ html.should match '<span class="keyword">raise</span> <span class="punct">&quot;</span><span class="string">Crash!'
77
168
  end
78
169
 
79
170
  it "marks the exception source in snippets" do
@@ -93,8 +184,8 @@ describe 'Cuukie' do
93
184
  html.should match '<pre class=\"val\"> Cuukie is sweet!\n Let&#x27;s try it out.</pre>'
94
185
  end
95
186
 
96
- it "shows total duration" do
97
- html.should match /Finished in <strong>\d+m\d+\.\d+s seconds<\/strong>/
187
+ it "shows total running time" do
188
+ html.should match /Duration: <strong>\d+\':\d+\'\'<\/strong>/
98
189
  end
99
190
 
100
191
  it "shows end-of-features stats" do
@@ -102,26 +193,23 @@ describe 'Cuukie' do
102
193
  html.should match /3 scenarios \(1 failed, 1 pending, 1 passed\)/
103
194
  html.should match /11 steps \(1 failed, 2 skipped, 1 pending, 7 passed\)/
104
195
  end
105
- end
106
-
107
- describe 'in the page header' do
108
- it "contains essential information" do
109
- run_cucumber
196
+
197
+ it "contains essential information in the status bar" do
110
198
  html.should match '<h1>Cucumber Features</h1>'
111
199
  html.should match '<title>Cuukie</title>'
112
200
  end
113
201
 
114
- it "shows green if all scenarios passed" do
202
+ it "shows a green status bar if all scenarios passed" do
115
203
  run_cucumber '1_show_scenarios.feature:9'
116
204
  html.should match /passedColors\('cucumber-header'\)/
117
205
  end
118
206
 
119
- it "shows red if any scenario failed" do
207
+ it "shows a red status bar if any scenario failed" do
120
208
  run_cucumber '1_show_scenarios.feature'
121
209
  html.should match /failedColors\('cucumber-header'\)/
122
210
  end
123
211
 
124
- it "shows yellow if no scenarios failed but some are pending" do
212
+ it "shows a yellow status bar if no scenarios failed but some are pending" do
125
213
  run_cucumber '1_show_scenarios.feature:19'
126
214
  html.should match /pendingColors\('cucumber-header'\)/
127
215
  end
@@ -1,4 +1,5 @@
1
1
  require 'bundler/setup'
2
+ require 'cuukie'
2
3
 
3
4
  def start_process(command)
4
5
  Process.detach fork { exec command }
@@ -23,14 +24,18 @@ def html
23
24
  end
24
25
 
25
26
  def start_server
26
- start_process "ruby bin/cuukie_server >/dev/null 2>&1"
27
+ start_process "ruby bin/cuukie --server >/dev/null 2>&1"
27
28
  wait_for_server_on_port 4569
28
29
  end
29
30
 
31
+ def ping_on_port(port)
32
+ RestClient.get "http://localhost:#{port}/ping"
33
+ end
34
+
30
35
  def wait_for_server_on_port(port)
31
36
  loop do
32
37
  begin
33
- RestClient.get "http://localhost:#{port}/ping"
38
+ ping_on_port port
34
39
  return
35
40
  rescue; end
36
41
  end
@@ -4,7 +4,7 @@ Feature: Visualize Scenarios
4
4
  So that I know which steps are not passing
5
5
 
6
6
  Background: Common Steps
7
- Given I execute a Background step
7
+ Given a Background step
8
8
 
9
9
  Scenario: Passing Scenario
10
10
  And I do something
@@ -13,9 +13,9 @@ Scenario: Passing Scenario
13
13
  Then the entire Scenario should pass
14
14
 
15
15
  Scenario: Failing Scenario
16
- When I do something that results in an error
16
+ When a Step fails
17
17
  Then the entire Scenario should fail
18
18
 
19
19
  Scenario: Pending Scenario
20
- When I call a pending Step
20
+ When a Step is pending
21
21
  Then the entire Scenario should be pending
@@ -1,4 +1,4 @@
1
- Feature:
1
+ Feature: Show Multiline Arguments
2
2
  As a Cuker
3
3
  I want to see multiline arguments in the result
4
4
  To see everything about steps
@@ -4,12 +4,10 @@ Feature: Show Failed Background
4
4
  So that I know that everything else is skipped
5
5
 
6
6
  Background: Failing Background
7
- Given I do something that results in an error
7
+ Given a Background Step fails
8
8
 
9
- Scenario: Skipped Scenario
10
- When I do something
11
- Then the entire Scenario should be skipped anyway
9
+ Scenario: First Scenario
10
+ Then the first Scenario should be failing
12
11
 
13
- Scenario: Another Skipped Scenario
14
- When I do something else
15
- Then the entire Scenario should be skipped anyway
12
+ Scenario: Other Scenarios
13
+ Then the following Scenarios should be skipped
@@ -4,21 +4,22 @@ end
4
4
  When /^I pass an "([^"]*)"$/ do |argument|
5
5
  end
6
6
 
7
- When /I do something that results in an error/ do
7
+ When /^a.+Step fails$/ do
8
8
  raise "Crash!"
9
9
  end
10
10
 
11
- When /I call a pending Step/ do
11
+ When /^a Step is pending$/ do
12
12
  pending
13
13
  end
14
14
 
15
- Given /^I execute a Background step$/ do; end
15
+ Given /^a Background step$/ do; end
16
16
  Given /^I do something$/ do; end
17
17
  When /^I do something else$/ do; end
18
18
  Then /^I should see stuff$/ do; end
19
19
  Then /^the entire Scenario should pass$/ do; end
20
20
  Then /^the entire Scenario should fail$/ do; end
21
21
  Then /^the entire Scenario should be pending$/ do; end
22
- Then /^the entire Scenario should be skipped anyway$/ do; end
22
+ Then /^the first Scenario should be failing$/ do; end
23
+ Then /^the following Scenarios should be skipped$/ do; end
23
24
  Then /^Cuukie should be OK with it$/ do; end
24
25
  Given /^I say$/ do |smart_stuff|; end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cuukie
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,33 +9,44 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-12-08 00:00:00.000000000 Z
12
+ date: 2011-12-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sinatra
16
- requirement: &70339163759300 !ruby/object:Gem::Requirement
16
+ requirement: &70206687427700 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
- - - ! '>='
19
+ - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: '0'
21
+ version: '1.3'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70206687427700
25
+ - !ruby/object:Gem::Dependency
26
+ name: cucumber
27
+ requirement: &70206687427220 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: '1.1'
22
33
  type: :runtime
23
34
  prerelease: false
24
- version_requirements: *70339163759300
35
+ version_requirements: *70206687427220
25
36
  - !ruby/object:Gem::Dependency
26
37
  name: rest-client
27
- requirement: &70339163757860 !ruby/object:Gem::Requirement
38
+ requirement: &70206687426740 !ruby/object:Gem::Requirement
28
39
  none: false
29
40
  requirements:
30
- - - ! '>='
41
+ - - ~>
31
42
  - !ruby/object:Gem::Version
32
- version: '0'
43
+ version: '1.6'
33
44
  type: :runtime
34
45
  prerelease: false
35
- version_requirements: *70339163757860
46
+ version_requirements: *70206687426740
36
47
  - !ruby/object:Gem::Dependency
37
- name: cucumber
38
- requirement: &70339163755420 !ruby/object:Gem::Requirement
48
+ name: launchy
49
+ requirement: &70206687442620 !ruby/object:Gem::Requirement
39
50
  none: false
40
51
  requirements:
41
52
  - - ! '>='
@@ -43,10 +54,10 @@ dependencies:
43
54
  version: '0'
44
55
  type: :runtime
45
56
  prerelease: false
46
- version_requirements: *70339163755420
57
+ version_requirements: *70206687442620
47
58
  - !ruby/object:Gem::Dependency
48
59
  name: syntax
49
- requirement: &70339163753560 !ruby/object:Gem::Requirement
60
+ requirement: &70206687442140 !ruby/object:Gem::Requirement
50
61
  none: false
51
62
  requirements:
52
63
  - - ! '>='
@@ -54,10 +65,10 @@ dependencies:
54
65
  version: '0'
55
66
  type: :runtime
56
67
  prerelease: false
57
- version_requirements: *70339163753560
68
+ version_requirements: *70206687442140
58
69
  - !ruby/object:Gem::Dependency
59
70
  name: rake
60
- requirement: &70339163760240 !ruby/object:Gem::Requirement
71
+ requirement: &70206687441660 !ruby/object:Gem::Requirement
61
72
  none: false
62
73
  requirements:
63
74
  - - ! '>='
@@ -65,10 +76,10 @@ dependencies:
65
76
  version: '0'
66
77
  type: :development
67
78
  prerelease: false
68
- version_requirements: *70339163760240
79
+ version_requirements: *70206687441660
69
80
  - !ruby/object:Gem::Dependency
70
81
  name: jeweler
71
- requirement: &70339163758480 !ruby/object:Gem::Requirement
82
+ requirement: &70206687441180 !ruby/object:Gem::Requirement
72
83
  none: false
73
84
  requirements:
74
85
  - - ! '>='
@@ -76,11 +87,12 @@ dependencies:
76
87
  version: '0'
77
88
  type: :development
78
89
  prerelease: false
79
- version_requirements: *70339163758480
80
- description: Shows Cucumber results on a web page as they run.
90
+ version_requirements: *70206687441180
91
+ description: A drop-in replacement for the "cucumber" command. It shows running features
92
+ on a web page.
81
93
  email: paolo.nusco.perrotta@gmail.com
82
94
  executables:
83
- - cuukie_server
95
+ - cuukie
84
96
  extensions: []
85
97
  extra_rdoc_files:
86
98
  - README.markdown
@@ -92,19 +104,21 @@ files:
92
104
  - README.markdown
93
105
  - Rakefile
94
106
  - VERSION
95
- - bin/cuukie_server
107
+ - bin/cuukie
96
108
  - cuukie.gemspec
97
109
  - doc/LICENSE.txt
98
110
  - doc/backlog.txt
99
111
  - doc/pomodoro.txt
100
112
  - lib/cuukie.rb
101
- - lib/cuukie/cucumber/formatter/code_snippets.rb
102
- - lib/cuukie/cucumber/formatter/cuukie.rb
113
+ - lib/cuukie/cli.rb
114
+ - lib/cuukie/code_snippets.rb
115
+ - lib/cuukie/formatter.rb
103
116
  - lib/cuukie/public/cucumber.css
104
117
  - lib/cuukie/public/cuukie.js
105
118
  - lib/cuukie/public/jquery-1.7.min.js
106
119
  - lib/cuukie/server.rb
107
120
  - lib/cuukie/views/index.erb
121
+ - spec/cli_spec.rb
108
122
  - spec/code_snippets_spec.rb
109
123
  - spec/commands_spec.rb
110
124
  - spec/cuukie_spec.rb
@@ -131,7 +145,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
131
145
  version: '0'
132
146
  segments:
133
147
  - 0
134
- hash: -2459400379263552476
148
+ hash: -4010332035183604014
135
149
  required_rubygems_version: !ruby/object:Gem::Requirement
136
150
  none: false
137
151
  requirements: