spec/cuukie_spec.rb in cuukie-0.1.2 vs spec/cuukie_spec.rb in cuukie-0.1.3

- old
+ new

@@ -1,28 +1,30 @@ +require 'spec_helper' + describe 'Cuukie' do before(:all) { start_server } - after(:all) { stop_server } + after(:all) { stop_server_on_port 4569 } - describe 'on the page header' do + describe 'shows suite result at the top of the page' do it "contains essential information" do run_cucumber html.should match '<h1>Cucumber Features</h1>' html.should match '<title>Cuukie</title>' end - it "is green if all scenarios passed" do - run_cucumber '1_visualize_scenarios.feature:9' + it "shows green if all scenarios passed" do + run_cucumber '1_show_scenarios.feature:9' html.should match /passedColors\('cucumber-header'\)/ end - it "is red if any scenario failed" do - run_cucumber '1_visualize_scenarios.feature' + it "shows red if any scenario failed" do + run_cucumber '1_show_scenarios.feature' html.should match /failedColors\('cucumber-header'\)/ end - it "is yellow if no scenarios failed but some are pending" do - run_cucumber '1_visualize_scenarios.feature:19' + it "shows yellow if no scenarios failed but some are pending" do + run_cucumber '1_show_scenarios.feature:19' html.should match /pendingColors\('cucumber-header'\)/ end end describe 'in the content area' do @@ -46,11 +48,11 @@ html.should match '>Scenario: </span><span class="val">Passing Scenario<' html.should match '>Scenario: </span><span class="val">Failing Scenario<' end it "shows the scenario source position" do - html.should match '>features&#x2F;1_visualize_scenarios.feature:9<' + html.should match '>features&#x2F;1_show_scenarios.feature:' end it "shows the passed scenarios in green" do html.should match /passedColors\('scenario_1_1'\)/ end @@ -73,56 +75,37 @@ html.should match '>And </span><span class="step val">I do something</span>' html.should match '>When </span><span class="step val">I do something else</span>' end it "shows the step source position" do - html.should match '>features&#x2F;step_definitions&#x2F;example_steps.rb:4<' + html.should match '>features&#x2F;step_definitions&#x2F;example_steps.rb:' end it "shows the step status" do html.should match 'class="step passed"' html.should match 'class="step pending"' end - it "escapes step names" do + it "escapes HTML output" do html.should match 'I pass an &quot;argument&quot;' end + + it "shows tables in steps" do + html.should match '<td class="step" id="row_-0_0"><div><span class="step param">x</span></div></td>' + html.should match '<td class="step" id="row_-2_1"><div><span class="step param">22</span></div></td>' + end + + it "shows multiline strings in steps" do + html.should match '<pre class=\"val\"> Cuukie is sweet!\n Let&#x27;s try it out.</pre>' + end + + it "shows total duration" do + html.should match /Finished in <strong>\d+m\d+\.\d+s seconds<\/strong>/ + end + + it "shows end-of-features stats" do + run_cucumber '1_show_scenarios.feature' + html.should match /3 scenarios \(1 failed, 1 pending, 1 passed\)/ + html.should match /11 steps \(1 failed, 2 skipped, 1 pending, 7 passed\)/ + end end -end - -require 'rest-client' - -[:GET, :POST, :PUT, :DELETE].each do |method| - Kernel.send :define_method, method do |*args| - args[0] = "http://localhost:4569#{args[0]}" - RestClient.send method.downcase, *args - end -end - -def start_server - Process.detach fork { exec "ruby bin/cuukie_server >/dev/null 2>&1" } - - # wait until it's up - loop do - begin - GET '/ping' - return - rescue; end - end -end - -def stop_server - # the server dies without replying, so we expect an error here - DELETE '/' -rescue -end - -def html - GET('/').body -end - -def run_cucumber(feature = '') - system "cd spec/test_project && - cucumber features/#{feature} \ - --format cuukie \ - --guess" end