Created
September 27, 2012 16:38
-
-
Save partydrone/3795013 to your computer and use it in GitHub Desktop.
Cucumber tests fail for controller that doesn't inherit from ApplicationController
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Admin | |
class BaseController < ApplicationController | |
filter_access_to :index | |
def index | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Matcher failed: has_selector?("h1", {:text=>"Patents"}) (MiniTest::Assertion) | |
(eval):6:in `must_have_selector' | |
./features/step_definitions/web_steps.rb:6:in `/^I should see "(.*?)"$/' | |
features/patents_administration.feature:5:in `Then I should see "Patents"' | |
Failing Scenarios: | |
cucumber -p guard features/patents_administration.feature:3 # Scenario: Patents index |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% title "Patents" %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Feature: Patents Administration | |
Scenario: Patents index | |
Given I am on the admin patents page | |
Then I should see "Patents" | |
And the title should be "Wavetronix - Patents" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Admin | |
class PatentsController < BaseController | |
before_filter :find_patent | |
def index | |
end | |
private | |
def find_patent | |
@patent = Patent.find(params[:id]) if params[:id] | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Given /^I am on the (.*?) page$/ do |text| | |
visit eval("#{text.downcase.gsub(/\s/, '_')}_path(locale: 'en')") | |
end | |
Then /^I should see "(.*?)"$/ do |text| | |
page.must_have_selector('h1', text: text) | |
end | |
Then /^the title should be "(.*?)"$/ do |text| | |
page.must_have_selector('title', text: text) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Trying to implement this feature using BDD, the first step fails as expected: I need to implement
Admin::PatentsController
. Because it inherits fromAdmin::BaseController
—which has its own index action and view—Admin::PatentsController
inherits that action and view as well. When I override theBaseController
implementation by explicitly defining an index action and view for thePatentsController
, I can see the change in the browser—that it picks up the new index action and view, but the Cucumber step fails because it appears to still be looking at theBaseController
index action and view.Is there a better way to test this?