Skip to content

Commit

Permalink
Improved the speed of our feature import scenarios, which were taking…
Browse files Browse the repository at this point in the history
… forever to run before.
  • Loading branch information
baphled committed Apr 21, 2010
1 parent 85752a7 commit 0fc2378
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 19 deletions.
18 changes: 9 additions & 9 deletions features/plain/feature_import.feature
Expand Up @@ -100,10 +100,10 @@ Feature: Users should not have to manually input their features if they have alr
When the project is viewed
Then I should see a import link
When I click import
And select the features feature
And select the "Tag cloud"
And the feature is visible
And we click import projects
Then a flash message 'We need to a way to store our stories within a project, this will help organise our stories.' should be displayed
Then a flash message 'Feature: Something different, was created' should be displayed

Scenario: All scenario's should display the steps associated to it
Given there is a project
Expand Down Expand Up @@ -154,7 +154,7 @@ Feature: Users should not have to manually input their features if they have alr

Scenario: A step should be highlighted if it already exists in the system
Given there is a project
And the step "When I click new projects" is created
And the step "Then the tags cloud should be displayed" is created
And the project does have a project location
When the project is viewed
Then I should see a import link
Expand All @@ -174,7 +174,7 @@ Feature: Users should not have to manually input their features if they have alr
When I click import
Then I should see a list of features that will be imported
And we click import projects
Then a flash message 'We need to a way to store our stories within a project, this will help organise our stories.' should be displayed
Then a flash message 'Something different' should be displayed
And each imported stories step should be added

Scenario: A feature should not be viewable if the feature is already added
Expand All @@ -185,7 +185,7 @@ Feature: Users should not have to manually input their features if they have alr
When I click import
Then I should see a list of features that will be imported
And we click import projects
Then a flash message 'We need to a way to store our stories within a project, this will help organise our stories.' should be displayed
Then a flash message 'Something different' should be displayed
And each imported stories step should be added
When the project is viewed
Then I should see a import link
Expand All @@ -194,7 +194,7 @@ Feature: Users should not have to manually input their features if they have alr

Scenario: A message should be displayed to the user if there are no features to import
Given there is a project
And the project does have a project location
And the project does have a project location with no features to import
And there are no features to import
When the project is viewed
Then I should see a import link
Expand All @@ -209,7 +209,7 @@ Feature: Users should not have to manually input their features if they have alr
When I click import
Then I should see a list of features that will be imported
And we click import projects
Then a flash message 'We need to a way to store our stories within a project, this will help organise our stories.' should be displayed
Then a flash message 'Something different' should be displayed
And we should be redirected to the projects import page

Scenario: When importing features, we should be able to find feature regardless of the feature directory structure
Expand Down Expand Up @@ -277,8 +277,8 @@ Feature: Users should not have to manually input their features if they have alr
When the project is viewed
Then I should see a import link
When I click import
And we click import "enhancements"
Then the features scenario "Basic pages we want to visit to check for JS enabled" should be saved
And we click import "most used"
Then the features scenario "Our actions that we want to check states for" should be saved

Scenario: A feature should not be submittable if a duplicate scenario is found in the new feature
Given there is a project
Expand Down
24 changes: 14 additions & 10 deletions features/step_definitions/projects_steps.rb
Expand Up @@ -16,11 +16,11 @@
end

Given /^the project does have a project location$/ do
@project.location.should_not be_nil
@project.update_attribute(:location, "#{RAILS_ROOT}/spec/fixtures/")
end

Given /^a step already exists$/ do
response.should contain "When I click new projects"
response.should contain "Then the tags cloud should be displayed"
end

Given /^there are no features to import$/ do
Expand Down Expand Up @@ -48,6 +48,10 @@
Feature.stub!(:imports_found).with("#{RAILS_ROOT}")
end

Given /^the project does have a project location with no features to import$/ do
@project.update_attribute(:location,"#{RAILS_ROOT}/spec/fixtures/features")
end

When /^the project already exists$/ do
@project.should_receive(:save).and_return false
end
Expand Down Expand Up @@ -95,7 +99,7 @@

When /^I click import$/ do
file = "#{RAILS_ROOT}/features/plain/enhancements.feature"
result ||= {:file => File.basename(file), :feature => FeatureFile.new(file).export}
result = {:file => File.basename(file), :feature => FeatureFile.new(file).export}
@project.stub!(:import_features).and_return [result]
click_link 'Import'
end
Expand Down Expand Up @@ -309,18 +313,18 @@
response.should contain "Scenario: #{Story.find(3).scenario}"
end

When /^select the features feature$/ do
click_link 'feature import'
When /^select the "([^\"]*)"$/ do |link|
click_link 'Tag cloud'
end

When /^the feature is visible$/ do
response.should have_selector :div do |content|
content.should have_selector :h3, :content => "Feature: projects"
content.should have_selector :h3, :content => "Feature: tag cloud"
end
end

When /^we click import projects$/ do
click_button 'Import projects'
click_button 'Import tag cloud'
end

Then /^we scenario should display that is is already added$/ do
Expand All @@ -343,11 +347,11 @@
end

Then /^it should be highlighted$/ do
response.should have_selector :b, :content => "When I click new projects"
response.should have_selector :b, :content => "Then the tags cloud should be displayed"
end

Then /^each imported stories step should be added$/ do
assert(Step.find_by_title("Given I can view the projects page").title)
assert(Step.find_by_title("Then the tags cloud should be displayed").title)
end

Then /^the project feature will be not be selectable\.$/ do
Expand Down Expand Up @@ -387,7 +391,7 @@
end

Then /^it should include features from all sub directories within the feature directory$/ do
response.should contain "Feature: hover functionality"
response.should contain "Feature: most used"
end

Then /^the "([^\"]*)" "([^\"]*)" "([^\"]*)" should have an error class$/ do |model, attribute, input|
Expand Down

0 comments on commit 0fc2378

Please sign in to comment.