Permalink
Browse files

Refactored cucumber features a bit so test-setup details are hidden a…

…way from scenarios
  • Loading branch information...
1 parent 7a01aa2 commit ed7ded86fcde6408a43e2aa6c2e5247991d2079c @colszowka colszowka committed Sep 12, 2011
View
3 features/config_adapters.feature
@@ -6,8 +6,7 @@ Feature:
that can be loaded at once.
Background:
- Given I cd to "project"
- Given a file named "test/simplecov_config.rb" with:
+ Given SimpleCov for Test/Unit is configured with:
"""
require 'simplecov'
"""
View
5 features/config_autoload.feature
@@ -12,19 +12,18 @@ Feature:
by doing a 'require "simplecov"'
Scenario:
- Given I cd to "project"
Given a file named ".simplecov" with:
"""
SimpleCov.start do
add_filter 'test.rb'
add_filter 'spec.rb'
end
"""
- And a file named "test/simplecov_config.rb" with:
+ Given SimpleCov for Test/Unit is configured with:
"""
require 'simplecov'
"""
- And a file named "spec/simplecov_config.rb" with:
+ Given SimpleCov for RSpec is configured with:
"""
require 'simplecov'
"""
View
5 features/config_command_name.feature
@@ -7,15 +7,14 @@ Feature: Custom names for individual test suites
config can be given a custom command name using SimpleCov.command_name.
Scenario:
- Given I cd to "project"
- Given a file named "test/simplecov_config.rb" with:
+ Given SimpleCov for Test/Unit is configured with:
"""
require 'simplecov'
SimpleCov.start do
command_name "I'm in UR Unitz"
end
"""
- And a file named "spec/simplecov_config.rb" with:
+ Given SimpleCov for RSpec is configured with:
"""
require 'simplecov'
SimpleCov.start do
View
3 features/config_coverage_dir.feature
@@ -7,8 +7,7 @@ Feature:
in your project's root.
Scenario:
- Given I cd to "project"
- Given a file named "test/simplecov_config.rb" with:
+ Given SimpleCov for Test/Unit is configured with:
"""
require 'simplecov'
SimpleCov.start do
View
5 features/config_deactivate_merging.feature
@@ -9,15 +9,14 @@ Feature:
output directories instead (see SimpleCov.coverage_dir), but it is possible :)
Scenario:
- Given I cd to "project"
- Given a file named "test/simplecov_config.rb" with:
+ Given SimpleCov for Test/Unit is configured with:
"""
require 'simplecov'
SimpleCov.start do
use_merging false
end
"""
- And a file named "spec/simplecov_config.rb" with:
+ Given SimpleCov for RSpec is configured with:
"""
require 'simplecov'
SimpleCov.start do
View
5 features/config_merge_timeout.feature
@@ -13,15 +13,14 @@ Feature:
in the report.
Scenario:
- Given I cd to "project"
- Given a file named "test/simplecov_config.rb" with:
+ Given SimpleCov for Test/Unit is configured with:
"""
require 'simplecov'
SimpleCov.start do
merge_timeout 1
end
"""
- And a file named "spec/simplecov_config.rb" with:
+ Given SimpleCov for RSpec is configured with:
"""
require 'simplecov'
SimpleCov.start do
View
6 features/config_project_name.feature
@@ -5,11 +5,9 @@ Feature:
If this is not sufficient for you, you can specify a custom name using
SimpleCov.project_name('xyz')
- Background:
- Given I cd to "project"
Scenario: Guessed name
- Given a file named "test/simplecov_config.rb" with:
+ Given SimpleCov for Test/Unit is configured with:
"""
require 'simplecov'
SimpleCov.start
@@ -19,7 +17,7 @@ Feature:
Then I should see "Code coverage for Project"
Scenario: Custom name
- Given a file named "test/simplecov_config.rb" with:
+ Given SimpleCov for Test/Unit is configured with:
"""
require 'simplecov'
SimpleCov.start { project_name "Superfancy 2.0" }
View
3 features/config_styles.feature
@@ -6,8 +6,7 @@ Feature:
preference or project requirements.
Background:
- Given I cd to "project"
- Given a file named "test/simplecov_config.rb" with:
+ Given SimpleCov for Test/Unit is configured with:
"""
require 'simplecov'
"""
View
3 features/cucumber_basic.feature
@@ -5,8 +5,7 @@ Feature:
the user a coverage report after running `cucumber features`
Scenario:
- Given I cd to "project"
- Given a file named "features/support/simplecov_config.rb" with:
+ Given SimpleCov for Cucumber is configured with:
"""
require 'simplecov'
SimpleCov.start
View
5 features/merging_test_unit_and_rspec.feature
@@ -6,16 +6,15 @@ Feature:
the joined results of all test suites that are using SimpleCov.
Scenario:
- Given I cd to "project"
- Given a file named "test/simplecov_config.rb" with:
+ Given SimpleCov for Test/Unit is configured with:
"""
require 'simplecov'
SimpleCov.start do
add_filter 'test.rb'
add_filter 'spec.rb'
end
"""
- And a file named "spec/simplecov_config.rb" with:
+ And SimpleCov for RSpec is configured with:
"""
require 'simplecov'
SimpleCov.start do
View
3 features/rspec_basic.feature
@@ -5,8 +5,7 @@ Feature:
the user a coverage report after running `rspec`
Scenario:
- Given I cd to "project"
- Given a file named "spec/simplecov_config.rb" with:
+ Given SimpleCov for RSpec is configured with:
"""
require 'simplecov'
SimpleCov.start
View
3 features/rspec_groups_and_filters_basic.feature
@@ -5,8 +5,7 @@ Feature:
coverage report that respects those settings after running rspec
Scenario:
- Given I cd to "project"
- Given a file named "spec/simplecov_config.rb" with:
+ Given SimpleCov for RSpec is configured with:
"""
require 'simplecov'
SimpleCov.start do
View
3 features/rspec_groups_and_filters_complex.feature
@@ -7,8 +7,7 @@ Feature: Sophisticated grouping and filtering on RSpec
to specific groups.
Scenario:
- Given I cd to "project"
- Given a file named "spec/simplecov_config.rb" with:
+ Given SimpleCov for RSpec is configured with:
"""
require 'simplecov'
SimpleCov.start do
View
5 features/rspec_without_simplecov.feature
@@ -3,15 +3,12 @@ Feature:
Running specs without simplecov configuration
- Background:
- Given I cd to "project"
-
Scenario: No config at all
When I successfully run `bundle exec rspec spec`
Then no coverage report should have been generated
Scenario: Configured, but not started
- Given a file named "spec/simplecov_config.rb" with:
+ Given SimpleCov for RSpec is configured with:
"""
require 'simplecov'
SimpleCov.configure do
View
23 features/step_definitions/simplecov_steps.rb
@@ -1,3 +1,26 @@
+# Just a shortcut to make framework setup more readable
+# The test project is using separate config files to avoid specifying all of
+# test/spec_helper in the features every time.
+Given /^SimpleCov for (.*) is configured with:$/ do |framework, config_body|
+ framework_dir = case framework
+ when /RSpec/i
+ "spec"
+ when /Test\/Unit/i
+ "test"
+ when /Cucumber/i
+ "features/support"
+ else
+ raise ArgumentError, "Could not identify test framework #{framework}!"
+ end
+
+ steps %Q{
+ Given a file named "#{framework_dir}/simplecov_config.rb" with:
+ """
+ #{config_body}
+ """
+ }
+end
+
When /^I open the coverage report generated with `([^`]+)`$/ do |command|
steps %Q{
When I successfully run `#{command}`
View
1 features/support/env.rb
@@ -23,4 +23,5 @@
FileUtils.rm_rf 'project'
FileUtils.cp_r File.join(this_dir, '../../test/faked_project/'), 'project'
end
+ Given 'I cd to "project"'
end
View
3 features/test_unit_basic.feature
@@ -5,8 +5,7 @@ Feature:
the user a coverage report after running `rake test`
Scenario:
- Given I cd to "project"
- Given a file named "test/simplecov_config.rb" with:
+ Given SimpleCov for Test/Unit is configured with:
"""
require 'simplecov'
SimpleCov.start
View
3 features/test_unit_groups_and_filters_basic.feature
@@ -5,8 +5,7 @@ Feature:
coverage report that respects those settings after running tests
Scenario:
- Given I cd to "project"
- Given a file named "test/simplecov_config.rb" with:
+ Given SimpleCov for Test/Unit is configured with:
"""
require 'simplecov'
SimpleCov.start do
View
3 features/test_unit_groups_and_filters_complex.feature
@@ -7,8 +7,7 @@ Feature: Sophisticated grouping and filtering on Test/Unit
to specific groups.
Scenario:
- Given I cd to "project"
- Given a file named "test/simplecov_config.rb" with:
+ Given SimpleCov for Test/Unit is configured with:
"""
require 'simplecov'
SimpleCov.start do
View
5 features/test_unit_without_simplecov.feature
@@ -3,15 +3,12 @@ Feature:
Running unit tests without simplecov configuration
- Background:
- Given I cd to "project"
-
Scenario: No config at all
When I successfully run `bundle exec rake test`
Then no coverage report should have been generated
Scenario: Configured, but not started
- Given a file named "test/simplecov_config.rb" with:
+ Given SimpleCov for Test/Unit is configured with:
"""
require 'simplecov'
SimpleCov.configure do

0 comments on commit ed7ded8

Please sign in to comment.