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
#assumes use of capybara for request specs | |
require 'spec_helper' | |
describe "StaticPages" do | |
class FlashController < ApplicationController | |
def set_flash | |
flash[:notice] = params[:message] | |
flash[:error] = params[:message] | |
flash[:alert] = params[:message] |
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
# an example, showing how to load for rspec and conditionally load for cucumber | |
# lives in whichever dir you set the other file to load | |
module ImageStepHelpers | |
def page_should_contain_image_link_for(image) | |
page.should have_xpath(%Q(//img[@src="#{image.url}"])) | |
end | |
def image_data_from_file(image) | |
image_file_path = Rails.root.join image.image.path |
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
require 'spec_helper' | |
describe "member password recovery" do | |
# As a member who forgot my password | |
# I want to recover my site access easily | |
# | |
attr_accessor :current_email_address | |
specify "email recovery of a new password" do | |
member = make_activated_member |
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
describe "logger" do | |
before(:each) do | |
@old_flush = controller.logger.auto_flushing | |
@old_level = controller.logger.level | |
controller.logger.auto_flushing=0 | |
controller.logger.level = ActiveSupport::BufferedLogger::Severity::ERROR | |
end | |
it "logs an error" do | |
#would prefer to test this with a test-spy / mock expectations but there's a lot of level-0 logging noise to ignore, so went with reading the log itself |
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
#as seen in https://github.com/mooktakim/heroku_deployment | |
class AppTemplatesController < ApplicationController | |
def app | |
render :inline => "SUCCESS", :layout => 'master' | |
end | |
def cms | |
render :inline => "SUCCESS", :layout => 'cms_admin' | |
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
-module (auctioneer_tests). | |
-include_lib("eunit/include/eunit.hrl"). | |
check_auctioneer_announces_item_to_room_test() -> | |
AuctionRoom = nspy:new(), | |
Auctioneer = auctioneer:start("Penguin", 20, AuctionRoom), | |
timer:sleep(1000), | |
Auctioneer ! stop, | |
ExpectedMessage = {starting_auction, {lot, 1, 20, "Penguin"}, "Next up lot 1, a fine Penguin, starting at 20\n"}, | |
nspy:assert_message_received(AuctionRoom, ExpectedMessage). |
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
describe "when some redirect mappings are present in the Medify::PAGE_REDIRECTS hash" do | |
before(:each) do | |
Medify::PAGE_REDIRECTS['/abstract-reasoning-subtest-advice-by-medify'] = '/advice-pages/abstract-reasoning-subtest-advice-by-medify' | |
Medify::PAGE_REDIRECTS['/decision-analysis-subtest-advice-by-medify'] = '/advice-pages/decision-analysis-subtest-advice-by-medify' | |
end | |
describe "GET :show, :path => abstract-reasoning-subtest-advice-by-medify" do | |
subject {get :show, :path => 'abstract-reasoning-subtest-advice-by-medify'} | |
it {should be_redirect} | |
it {should redirect_to('/advice-pages/abstract-reasoning-subtest-advice-by-medify')} |
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
describe "3 users exist" | |
let(:users) {(1..3).map {User.make}} | |
specify "user count should be 3" do | |
pending "this will fail because users hasn't been called" do | |
User.count.should == 3 | |
end | |
end | |
specify "3 users should exist" do |
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
class Tests | |
SUBTESTS = %w(Abstract Decision Quantitative Verbal) | |
end | |
describe Tests do | |
describe "before assigning @ - " do | |
describe "this doesn't work because the loops are all at the same describe level (the befores override one another)" do | |
Tests::SUBTESTS.each do |test| | |
before(:each) do |