Skip to content

Commit

Permalink
Cucumber steps all pass. The few remaining fixes were all typos or mi…
Browse files Browse the repository at this point in the history
…nor syntax changes, but I've also added two new steps in content_negotiation.

I had to update the cucumber files again, and I've clarified one feature that had a nested when in it. Otherwise, I've tried to cause as little change as possible.
  • Loading branch information
will-r committed Jan 25, 2010
1 parent 929cc51 commit bff6b96
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 22 deletions.
8 changes: 4 additions & 4 deletions config/environments/cucumber.rb
Expand Up @@ -21,9 +21,9 @@
# ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test

config.gem 'cucumber-rails', :lib => false, :version => '>=0.2.3' unless File.directory?(File.join(Rails.root, 'vendor/plugins/cucumber-rails'))
config.gem 'database_cleaner', :lib => false, :version => '>=0.2.3' unless File.directory?(File.join(Rails.root, 'vendor/plugins/database_cleaner'))
config.gem 'cucumber-rails', :lib => false, :version => '>=0.2.4' unless File.directory?(File.join(Rails.root, 'vendor/plugins/cucumber-rails'))
config.gem 'database_cleaner', :lib => false, :version => '>=0.4.3' unless File.directory?(File.join(Rails.root, 'vendor/plugins/database_cleaner'))
config.gem 'webrat', :lib => false, :version => '>=0.6.0' unless File.directory?(File.join(Rails.root, 'vendor/plugins/webrat'))
config.gem 'rspec', :lib => false, :version => '>=1.2.9' unless File.directory?(File.join(Rails.root, 'vendor/plugins/rspec'))
config.gem 'rspec-rails', :lib => false, :version => '>=1.2.9' unless File.directory?(File.join(Rails.root, 'vendor/plugins/rspec-rails'))
config.gem 'rspec', :lib => false, :version => '>=1.3.0' unless File.directory?(File.join(Rails.root, 'vendor/plugins/rspec'))
config.gem 'rspec-rails', :lib => false, :version => '>=1.3.2' unless File.directory?(File.join(Rails.root, 'vendor/plugins/rspec-rails'))

4 changes: 2 additions & 2 deletions features/admin/content_negotiation.feature
Expand Up @@ -13,12 +13,12 @@ Feature: Proper content negotiation
Given I am logged in as "admin"
When I send an "Accept" header of "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-ms-application, application/vnd.ms-xpsdocument, application/xaml+xml, application/x-ms-xbap, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*"
And I go to admin:pages as xml
Then I should see "<?xml" when I view the page source
Then I should see an xml document

Scenario: Requesting children via Ajax
Given I am logged in as "admin"
When I send an "Accept" header of "text/javascript, text/html, application/xml, text/xml, */*"
And I send an "X-Requested-With" header of "XMLHttpRequest"
And I request the children of page "home"
Then I should not see "Radiant CMS"
And I should see "<tr" when I view the page source
And I should see "<tr>" tags in the page source
2 changes: 1 addition & 1 deletion features/admin/pages_management.feature
Expand Up @@ -71,7 +71,7 @@ Feature: Managing pages
Scenario: Change page type
Given I am logged in as "existing"
When I edit the "virtual" page
And I select "&lt;normal&gt;" from "Page type"
And I select "<normal>" from "Page type"
And I press "Save and Continue Editing"
Then I should see "Edit Page"
And "&lt;normal&gt;" should be selected for "Page type"
4 changes: 2 additions & 2 deletions features/admin/user_permissions.feature
Expand Up @@ -45,7 +45,7 @@ Feature: User authentication and permissions
Scenario Outline: Admins and designers can see and edit snippets
Given I am logged in as "<username>"
And I should see "Design"
When I follow "Design" within "navigation"
When I follow "Design" within "#navigation"
And I follow "Snippets"
And I should not see "You must have designer privileges"
And I follow "first"
Expand All @@ -59,7 +59,7 @@ Feature: User authentication and permissions
Scenario Outline: Admins and designers can see and edit layouts
Given I am logged in as "<username>"
And I should see "Design"
When I follow "Design" within "navigation"
When I follow "Design" within "#navigation"
And I follow "Layouts"
And I should not see "You must have designer privileges"
And I follow "Main"
Expand Down
4 changes: 2 additions & 2 deletions features/admin/user_preferences.feature
Expand Up @@ -14,5 +14,5 @@ Feature: Edit user preferences
| admin |
| another |
| existing |
| designer |
| non_admin |
| designer |
| non-admin |
15 changes: 14 additions & 1 deletion features/step_definitions/admin/content_negotiation_steps.rb
Expand Up @@ -26,8 +26,21 @@
visit "/admin/pages/#{parent_page.id}/children", :get, {"level" => "0"}
end

Then /^(?:|I )should see "<{0,1}([^>"]*)>{0,1}" tags in the page source$/ do |text|
response.body.should have_tag(text)
end

Then /^(?:|I )should see an xml document$/ do
webrat.adapter.xml_content_type?.should be_true
end

Then /^(?:|I )should not see an xml document$/ do
webrat.adapter.xml_content_type?.should_not be_true
end

def set_headers
@request_headers.each do |k,v|
header(k, v)
end unless @request_headers.blank?
end
end

18 changes: 10 additions & 8 deletions features/step_definitions/web_steps.rb
Expand Up @@ -152,7 +152,8 @@
if defined?(Spec::Rails::Matchers)
content.should contain(text)
else
assert content.include?(text)
hc = Webrat::Matchers::HasContent.new(text)
assert hc.matches?(content), hc.failure_message
end
end
end
Expand All @@ -162,7 +163,7 @@
if defined?(Spec::Rails::Matchers)
response.should contain(regexp)
else
assert_contain regexp
assert_match(regexp, response_body)
end
end

Expand All @@ -172,7 +173,7 @@
if defined?(Spec::Rails::Matchers)
content.should contain(regexp)
else
assert content =~ regexp
assert_match(regexp, content)
end
end
end
Expand All @@ -181,16 +182,17 @@
if defined?(Spec::Rails::Matchers)
response.should_not contain(text)
else
assert_not_contain text
assert_not_contain(text)
end
end

Then /^(?:|I )should not see "([^\"]*)" within "([^\"]*)"$/ do |text, selector|
within(selector) do |content|
if defined?(Spec::Rails::Matchers)
content.should_not contain(text)
content.should_not contain(text)
else
assert !content.include?(text)
hc = Webrat::Matchers::HasContent.new(text)
assert !hc.matches?(content), hc.negative_failure_message
end
end
end
Expand All @@ -200,7 +202,7 @@
if defined?(Spec::Rails::Matchers)
response.should_not contain(regexp)
else
assert_not_contain regexp
assert_not_contain(regexp)
end
end

Expand All @@ -210,7 +212,7 @@
if defined?(Spec::Rails::Matchers)
content.should_not contain(regexp)
else
assert content !~ regexp
assert_no_match(regexp, content)
end
end
end
Expand Down
9 changes: 7 additions & 2 deletions features/support/env.rb
Expand Up @@ -15,7 +15,6 @@

require 'webrat'
require 'webrat/core/matchers'
require 'cucumber/webrat/element_locator' # Deprecated in favor of #tableish - remove this line if you don't use #element_at or #table_at

Webrat.configure do |config|
config.mode = :rails
Expand Down Expand Up @@ -46,4 +45,10 @@
# after each scenario, which can lead to hard-to-debug failures in
# subsequent scenarios. If you do this, we recommend you create a Before
# block that will explicitly put your database in a known state.
Cucumber::Rails::World.use_transactional_fixtures = true
Cucumber::Rails::World.use_transactional_fixtures = true

# How to clean your database when transactions are turned off. See
# http://github.com/bmabey/database_cleaner for more info.
require 'database_cleaner'
DatabaseCleaner.strategy = :truncation

0 comments on commit bff6b96

Please sign in to comment.