Skip to content

Instantly share code, notes, and snippets.

odule Foo
class Bar
include ActionController::UrlWriter
def inst_path
root_path
end
def self.some_path
root_path
aa = Artist.last
gigs = aa.gigs
gigs.last
id = gigs.last.id
Gig.find(id)
@mock_comments_scope = mock('comments scope')
@mock_comments_scope.stub!(:today).and_return :this_is_today
@post.stub!(:comments).and_return @mock_comments_scope
### Feature:
Feature: Test cucumber issue
Background:
Given a news article
Scenario: comments has not passed moderation
Then there should be 1 news article in the database
@current
# Sets up the Rails environment for Cucumber
ENV["RAILS_ENV"] ||= "test"
require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
require 'cucumber/rails/world'
require 'cucumber/formatter/unicode' # Comment out this line if you don't want Cucumber Unicode support
Cucumber::Rails.use_transactional_fixtures
Cucumber::Rails.bypass_rescue # Comment out this line if you want Rails own error handling
# (e.g. rescue_action_in_public / rescue_responses / rescue_from)
require 'webrat'
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe CommentsController do
describe "create" do
describe "with valid parameters" do
it "should redirect to the enclosing resource page after successful submit when nested in aliased url" do
news_article = Factory.create(:news_article)
post(:create,
:comment => {},
:news_article_id => news_article.to_param)
# comments_controller_spec.rb
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe CommentsController do
describe "create" do
describe "with valid parameters" do
it "should redirect to the enclosing resource page after successful submit when nested in aliased url" do
news_article = Factory.create(:news_article)
post(:create,
:comment => {},
>: rake spec:generate
(in /Users/tomtt/created/projects/test/resources_controller_spec/vendor/plugins/resources_controller)
cd /Users/tomtt/created/projects/test/resources_controller_spec
** Generating rspec_scaffold for resource: author
** Migrating up
** Replacing app/controllers/authors_controller.rb with:
class AuthorsController < ApplicationController
resources_controller_for :authors
end
>: garlic all
Skipping resources_controller, as it exists
Skipping rails, as it exists
Skipping rspec, as it exists
Skipping rspec-rails, as it exists
Updating resources_controller...
>: curl -X POST http://lather.local/comments/moderation_callback
not found[15:51][tomtt@tomtts-macbook:~/created/projects/five/lather(master)]
>: curl -X POST http://lather-stage.dmgstage1.com/comments/moderation_callback
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />