spec/cuukie_spec.rb in cuukie-0.1.1 vs spec/cuukie_spec.rb in cuukie-0.1.2
- old
+ new
@@ -1,101 +1,93 @@
-describe 'The Cuukie header' do
- before(:all) do
- start_server
- end
+describe 'Cuukie' do
+ before(:all) { start_server }
+ after(:all) { stop_server }
- after(:all) do
- stop_server
- end
-
- it "contains essential information" do
- run_cucumber
- html.should match '<h1>Cucumber Features</h1>'
- html.should match '<title>Cuukie</title>'
- end
+ describe 'on the page header' do
+ it "contains essential information" do
+ run_cucumber
+ html.should match '<h1>Cucumber Features</h1>'
+ html.should match '<title>Cuukie</title>'
+ end
- it "is red if any steps failed" do
- run_cucumber 'spec/test_project/features/create_user.feature'
- html.should match /failedColors\('cucumber-header'\)/
- end
+ it "is green if all scenarios passed" do
+ run_cucumber '1_visualize_scenarios.feature:9'
+ html.should match /passedColors\('cucumber-header'\)/
+ end
- it "is yellow if no steps failed but some are pending" do
- run_cucumber 'spec/test_project/features/create_user.feature:17'
- html.should match /pendingColors\('cucumber-header'\)/
- end
+ it "is red if any scenario failed" do
+ run_cucumber '1_visualize_scenarios.feature'
+ html.should match /failedColors\('cucumber-header'\)/
+ end
- it "is green if all steps passed" do
- run_cucumber 'spec/test_project/features/create_user.feature:6'
- html.should match /passedColors\('cucumber-header'\)/
+ it "is yellow if no scenarios failed but some are pending" do
+ run_cucumber '1_visualize_scenarios.feature:19'
+ html.should match /pendingColors\('cucumber-header'\)/
+ end
end
-end
-describe 'The Cuukie content panel' do
- before(:all) do
- start_server
- run_cucumber
- end
-
- after(:all) do
- stop_server
- end
+ 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: Create User').size.should == 1
- end
+ 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: Create User<'
- html.should match '>Feature: Delete User<'
- end
+ it "shows the feature names" do
+ html.should match '>Feature: Visualize Scenarios<'
+ html.should match '>Feature: Multiple Features<'
+ end
- it "shows the feature narratives" do
- html.should match '>As an Administrator<br/>I want to create a new User<br/>So that he will love me<bbr/r><'
- end
+ it "shows the feature narratives" do
+ html.should match '>As a Cuker<br/>I want to visualize Scenarios and Steps<br/>So that I know which steps are not passing<bbr/r><'
+ end
- it "shows the scenario names" do
- html.should match '>Scenario: </span><span class="val">New User<'
- html.should match '>Scenario: </span><span class="val">Existing User<'
- end
+ it "shows the scenario names" do
+ 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 '>spec/test_project/features/create_user.feature:6<'
- end
+ it "shows the scenario source position" do
+ html.should match '>features/1_visualize_scenarios.feature:9<'
+ end
- it "shows the passed scenarios in green" do
- html.should match /passedColors\('scenario_1_1'\)/
- 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_1_2'\)/
- end
+ it "shows the failed scenarios in red" do
+ html.should match /failedColors\('scenario_3_1'\)/
+ end
- it "shows the pending scenarios in yellow" do
- html.should match /pendingColors\('scenario_1_3'\)/
- 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 scenarios" do
- html.should match 'id="scenario_1_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 '>Given </span><span class="step val">I am on the Admin page</span>'
- html.should match '>When </span><span class="step val">I create a new User</span>'
- end
+ it "shows the step names" do
+ 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 '>spec/test_project/features/step_definitions/example_steps.rb:4<'
- end
+ it "shows the step source position" do
+ html.should match '>features/step_definitions/example_steps.rb:4<'
+ end
- it "shows the step status" do
- html.should match 'class="step passed"'
- html.should match 'class="step pending"'
- 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
- html.should match 'I press "Delete"'
+ it "escapes step names" do
+ html.should match 'I pass an "argument"'
+ end
end
end
require 'rest-client'
@@ -126,11 +118,11 @@
def html
GET('/').body
end
-def run_cucumber(features = 'spec/test_project/features')
- system "cucumber #{features} \
- --require spec/test_project/features/step_definitions/ \
- --require lib/cuukie/formatter --format Cuukie \
+def run_cucumber(feature = '')
+ system "cd spec/test_project &&
+ cucumber features/#{feature} \
+ --format cuukie \
--guess"
end