require 'spec_helper' describe 'Cuukie' do before(:all) { start_server } after(:all) { stop_server_on_port 4569 } describe 'in the content area' do before(:all) { run_cucumber } it "cleans up previous data at the beginning of a run" do run_cucumber html.scan('Feature: Visualize Scenarios').size.should == 1 end it "shows the feature names" do html.should match '>Feature: Visualize Scenarios<' html.should match '>Feature: Show Failed Background<' end it "shows the feature narratives" do html.should match '>As a Cuker
I want to visualize Scenarios and Steps
So that I know which steps are not passing<' end it "shows the scenario names" do html.should match '>Scenario: Passing Scenario<' html.should match '>Scenario: Failing Scenario<' end it "shows the scenario source position" do html.should match '>features/1_show_scenarios.feature:' end it "shows the passed scenarios in green" do html.should match /passedColors\('scenario_1_1'\)/ end it "shows the failed scenarios in red" do html.should match /failedColors\('scenario_3_1'\)/ end it "shows the skipped scenarios in yellow" do # This can happen if there is an error in a Background step. # In this case, all the scenarios past the first one are skipped. html.should match /skippedColors\('scenario_3_2'\)/ end it "assigns a sequential id to feature elements" do html.should match 'id="scenario_1_2"' end it "shows the step names" do html.should match '>And I do something' html.should match '>When I do something else' end it "shows the step source position" do html.should match '>features/step_definitions/main_steps.rb:' end it "shows the step status" do html.should match 'class="step passed"' html.should match 'class="step pending"' end it "shows exception messages" do html.should match /main_steps.rb:7<\/span><\/div>[ \n]*
Crash!<\/pre><\/div>/
    end

    it "shows exception backtraces" do
      html.should match 'backtrace">
./features/step_definitions/main_steps.rb:8:in `/I do'
      html.should match '3_failed_background.feature:7:in `Given I do'
    end

    it "shows exception source snippets" do
      html.should match '
6<\/span>'
      html.should match 'I do something'
    end
    
    it "marks the exception source in snippets" do
      html.should match '8<\/span>  raise'
    end
 
    it "escapes HTML output" do
      html.should match 'I pass an "argument"'
    end
    
    it "shows tables in steps" do
      html.should match '
x
' html.should match '
22
' end it "shows multiline strings in steps" do html.should match '
  Cuukie is sweet!\n  Let's try it out.
' end it "shows total duration" do html.should match /Finished in \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 describe 'in the page header' do it "contains essential information" do run_cucumber html.should match '

Cucumber Features

' html.should match 'Cuukie' end it "shows green if all scenarios passed" do run_cucumber '1_show_scenarios.feature:9' html.should match /passedColors\('cucumber-header'\)/ end it "shows red if any scenario failed" do run_cucumber '1_show_scenarios.feature' html.should match /failedColors\('cucumber-header'\)/ end 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 end