{"id":21101172,"url":"https://github.com/brentgreeff/funktional","last_synced_at":"2025-11-11T19:13:39.591Z","repository":{"id":613628,"uuid":"251760","full_name":"brentgreeff/funktional","owner":"brentgreeff","description":"An alternative Rails testing framework for Test/Unit","archived":false,"fork":false,"pushed_at":"2018-01-08T05:55:05.000Z","size":85,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-11-16T09:33:55.153Z","etag":null,"topics":["integration-testing","rails"],"latest_commit_sha":null,"homepage":"http://www.brentgreeff.com/rails-plugins/funktional","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/brentgreeff.png","metadata":{"files":{"readme":"README.rdoc","changelog":null,"contributing":null,"funding":null,"license":"MIT-LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2009-07-15T12:00:30.000Z","updated_at":"2019-09-02T08:27:21.000Z","dependencies_parsed_at":"2022-07-05T03:31:07.811Z","dependency_job_id":null,"html_url":"https://github.com/brentgreeff/funktional","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brentgreeff%2Ffunktional","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brentgreeff%2Ffunktional/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brentgreeff%2Ffunktional/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brentgreeff%2Ffunktional/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/brentgreeff","download_url":"https://codeload.github.com/brentgreeff/funktional/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225444760,"owners_count":17475353,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["integration-testing","rails"],"created_at":"2024-11-19T23:41:13.407Z","updated_at":"2025-11-11T19:13:39.397Z","avatar_url":"https://github.com/brentgreeff.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"= Funktional\n\n== Deprecated: \n\nBack in the days when controller specs were a good idea and Rspec wasn't all mighty, there was a little testing framework that could.\n\nRspec has added many great features over the years. Although I really enjoyed coding this, request specs are a superior solution.\n\n== A Rails testing framework with a railsy syntax\n\n== Install\n* Via the gem\n      gem install funktional\n\n* With braid\n      braid add git://github.com/brentgreeff/funktional.git -p\n\n\n* add a setup line to 'test/test_helper.rb'\n\n      class ActiveSupport::TestCase\n        setup :funktional\n      end\n\nDone!\n\n\n== For extra flavour, add:\n  * should_pricot (Hpricot matchers in Test::Unit)\n  * hash_factory (Super simple factories for your tests)\n  * matchy (RSpec matchers in Test::Unit)\n\n\n== Contexts\n\n\nContexts, Don't Repeat Yourself, share common setup steps between your tests.\n\n      context \"On a hot summer day\" do\n        before { day :hot }\n        \n        context \"in the middle of July\" do\n          before { Time.now = 'July 15' }\n          \n          should \"be on the beach\" do\n            assert_equal 'beach', @me.location\n          end\n          \n          should \"be drinking lemonade\" do\n            assert_equal 'lemonade', @me.drinking\n          end\n        end\n      end\n\n\n== Unit tests\n\n=== Define domain logic through validations.\n\n* Start off with a valid instance\n\n      context \"A Company\" do\n        setup { @company = create_company }\n        \n        should \"respond to fax no\" do\n          @company.should_respond_to :fax_no\n        end\n        \n        should \"require a name\" do\n          @company.should_require_a :name, 'please enter the name'\n        end\n        \n        should \"require an address\" do\n          @company.should_require_an :address, 'please enter the address'\n        end\n        \n        should \"not allow creative accounting\" do\n          @company.creative_accounting = true\n          @company.should_have_invalid :books, 'no creative accounting please'\n        end\n        \n        should \"not require a telephone no if an address is present\" do\n          @company.address = an_address\n          @company.should_not_require_a :telephone_no\n        end\n        \n        should \"not have a name longer than 80 characters\" do\n          @company.name = 81.random_characters\n          @company.should_have_invalid :name, 'max is 80'\n          # random_characters is a small useful helper method.\n        end\n      end\n\n\n=== Email\n\n      should \"send email\" do\n        should :send_email =\u003e {\n          :from =\u003e 'me@example.com',\n          :to =\u003e 'you@example.com',\n          :subject =\u003e 'Your order',\n          :containing =\u003e \"important info\"\n        }\n      end\n      \n      should \"not send email\" do\n        should_not :send_email do\n          # do something here\n        end\n      end\n\n=== Object creation\n\n      should \"create something\" do\n        should :create =\u003e Something do\n          # Do something\n        end\n      end\n      \n      should \"delete something\" do\n        should :delete =\u003e Something do\n          # Do something\n        end\n      end\n      \n      should \"not delete something\" do\n        should_not :delete =\u003e Something do\n          # Do something\n        end\n      end\n      \n      should \"not create something\" do\n        should_not :create =\u003e Something do\n          # Do something\n        end\n      end\n\n\n== Testing Controllers\n\n=== Routing\n\n      should :route =\u003e '/onions/new' do\n        controller 'onions'\n        action 'new'\n      end\n\n* you need to pass the method if its not a :get request\n\n      should :route =\u003e '/onions', :method =\u003e :post do\n        controller 'onions'\n        action 'create'\n      end\n\n=== Render\n\n      should \"show the new order page\" do\n        get :new\n        should :render =\u003e 'orders/new'\n      end\n\nThe default 'should :render' checks for a http status code of 200\n\n* What about other codes?\n      \n      should \"return the not found page when the id does not exist\" do\n        get :show, :id =\u003e 'something does not exist'\n        should :render_404 =\u003e 'public/404'\n      end\n\n=== Redirection\n\n      should \"go to the login page if not logged in\" do\n        logout\n        get :new\n        should :redirect_to =\u003e '/login'\n      end\n\n=== Initializing a new object\n\n      should \"assign a new order\" do\n        get :new\n        should :assign_new =\u003e Order\n      end\n\n=== Loading Objects\n\n      should \"load order by id\" do\n        get :edit, :id =\u003e @order.id\n        assigned(Order).should_be @order\n      end\n\n* This checks the object assigned is of the correct type.\n\n=== Testing the attributes of an assigned object.\n\n      should \"associate the current user as the editor\" do\n        login_as @user = create_user\n        put :update, :id =\u003e @article.id\n        \n        assigned(Article).editor.should_be @user\n      end\n      \n      should \"chain as long as you like\" do\n        assigned(Article).editor.first_name.should_be 'pete'\n      end\n\n* If you pass a Symbol its just a value based assertion.\n\n      should \"load a collection\" do\n        get :index\n        assigned(:records).should_be [@record_1, @record_2]\n      end\n\n=== Flash messages\n\n      should \"notify the user when order was created\" do\n        post :create, :order =\u003e attrib\n        flashed(:notice).should_be 'Yay, Order created!'\n      end\n\n\n== Controller Helpers\n\nThere are also some helpers for manipulating attributes.\n\nI tend to define an attrib method in my funtional tests\nto represent valid attributes passed to create or update a resource.\n\n* eg:\n\n      def attrib\n        {\n          :first_name =\u003e 'Jim',\n          :last_name =\u003e 'Bean'\n        }\n      end\n\nSometimes you want to tests different values, especially invalid ones,\nto get away from all the merge noise, I have defined these helpers:\n\n      missing_attrib\n      blank_attrib\n      replace_attrib\n      add_attrib\n\n\n* Means you can write tests like the following:\n      \n      should_not :create =\u003e Order do\n        post :create, :order =\u003e blank_attrib(:cc_no)\n      end\n      should :render =\u003e 'orders/new'\n\n\n== All funktional assertions are also available as class methods.\n\n      context \"When doing it all\" do\n        before { :hit_a_controller }\n        \n        should :render =\u003e 'somethings/new'\n        \n        should :render_404 =\u003e 'public/404'\n        \n        should :render_404    # (defaults to 'public/404')\n        \n        should :redirect_to =\u003e '/somethings'\n        \n        element('h1').should_be 'Something'   # (you need should_pricot for this one).\n        \n        count('#friends ol.remaining').should_be 'Not Many'   # (should_pricot here too)\n        \n        flashed(:notice).should_be 'Cool'\n        \n        should :assign_new =\u003e Something\n        \n        assigned(Something).name.should_be 'something'\n        \n        assigned(:something).should_be { @something }\n        \n        should :create =\u003e Something\n        \n        should :delete =\u003e Something\n        \n        should_not :create =\u003e Something\n        \n        should_not :delete =\u003e Something\n        \n        should :send_email =\u003e {\n          :from =\u003e 'me@example.com',\n          :to =\u003e 'you@example.com'\n        }\n        \n        should_not :send_email\n      end\n\n\nCopyright (c) 2009 [Brent Greeff], released under the MIT license\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrentgreeff%2Ffunktional","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrentgreeff%2Ffunktional","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrentgreeff%2Ffunktional/lists"}