This file contains hidden or 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 Contact < NoTable | |
| # Define our "fields" | |
| column :id, :integer | |
| column :name, :string | |
| column :email, :string | |
| column :message, :string | |
| validates_presence_of :email, :name, :message |
This file contains hidden or 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 ProjectsControllerTest < ActionController::TestCase | |
| def setup | |
| set_test_host('secondary-domain.com') | |
| end | |
| test "routes do not exist for secondary-domain.com" do | |
| assert_not_routing('/projects' , { :controller => "projects", :action => "index" }) | |
| assert_not_routing('/projects/1' , { :controller => "projects", :action => "show", :id => "1" }) | |
| end |
This file contains hidden or 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
| # Helper Method for setting the requesting host in a Rails functional test | |
| # Mocks the proper response for the domain() method, as well as the | |
| # @request.host value. | |
| def set_test_host(host) | |
| @request.host = host | |
| domain = host.split('.').last(2).join('.') | |
| ActionController::TestRequest.any_instance.stubs(:domain).returns(domain) | |
| end |
This file contains hidden or 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
| # Assert that a specified route does not exist inside a functional test | |
| def assert_not_routing(path, options, defaults={}, extras={}, message=nil) | |
| assert_raise ActionController::RoutingError do | |
| assert_routing(path, options, defaults, extras, message) | |
| end | |
| end |
This file contains hidden or 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
| sudo gem update --system |
This file contains hidden or 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
| # Load Webrat 0.7.0 | |
| require 'webrat' | |
| # I'm going to be contrary and use Test/Unit instead of RSpec | |
| require 'test/unit/assertions' | |
| # Add Test/Unit assertions to Cucumber | |
| World(Test::Unit::Assertions) | |
| # Here is where we configure Webrat to use Selenium. |
This file contains hidden or 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 ActiveSupport::TestCase | |
| # Helper method_missing override to create nicely-named collections of factory objects | |
| # For example: create_factory_collection_for_current_students(15,true) | |
| # will call create_factory_collection(:current_students, 15, true) | |
| def method_missing(requested_method, *args) | |
| if requested_method.to_s =~ /\Acreate_factory_collection_for_(\w+)\Z/ | |
| __send__("create_factory_collection", $1, *args) | |
| else | |
| # Otherwise handle normally # |
This file contains hidden or 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
| # Stubs saving or creating methods in the database for Models associated with Database views. | |
| # In these cases, we specify the ID in the factory so we can still use them for associations. | |
| # If we didn't stub these actions out, the Factory would try to create them in the (read-only) view | |
| # when creating associations. | |
| database_view_models = ['Current::Course','Current::CurrentStudent'] | |
| methods_to_override = [:save, :save!, :create, :create!] | |
| database_view_models.each do |klass| | |
| methods_to_override.each do |method| |
NewerOlder