Class: OpenIdAuthenticationTest

Inherits:
Test::Unit::TestCase show all
Defined in:
lib/vendor/plugins/open_id_authentication/test/open_id_authentication_test.rb

Instance Attribute Summary

Attributes included from Spec::Example::ExampleGroupMethods

#location

Attributes included from Spec::Example::Subject::ExampleGroupMethods

#explicit_subject_block

Instance Method Summary collapse

Methods inherited from Test::Unit::TestCase

example_method?, #initialize, #run, suite, test_method?

Methods included from Spec::Example::ExampleGroupMethods

build_description_from, #describe, #described_class, #described_type, #description, #description_args, #description_parts, #example, #example_group_hierarchy, #example_implementations, #example_proxies, #examples, #include_constants_in, #inherited, #it_should_behave_like, #let, #nested_descriptions, #notify, #number_of_examples, #options, #pending_implementation, #run, #set_description, #xexample

Methods included from Spec::Example::ArgsAndOptions

#add_options, #args_and_options, #set_location

Methods included from Spec::Example::PredicateMatchers

#define_methods_from_predicate_matchers, #predicate_matchers

Methods included from Spec::Example::Subject::ExampleGroupMethods

#its, #subject

Methods included from Spec::Example::BeforeAndAfterHooks

#after_all_parts, #after_each_parts, after_suite_parts, #after_suite_parts, #append_after, #append_before, #before_all_parts, #before_each_parts, before_suite_parts, #before_suite_parts, #prepend_after, #prepend_before

Methods included from Spec::Example::ExampleMethods

#description, #eval_each_fail_fast, #eval_each_fail_slow, #execute, #expect, #initialize, #instance_variable_hash, #options, #run_after_each, #run_before_each, #set_instance_variables_from_hash, #violated

Methods included from Spec::Example::ModuleReopeningFix

#child_modules, #include, #included

Methods included from Spec::Example::Pending

#pending

Methods included from Spec::Matchers

#be, #be_a, #be_a_kind_of, #be_an_instance_of, #be_close, #change, clear_generated_description, #eql, #equal, #exception_from, #exist, #fail, #fail_with, generated_description, #have, #have_at_least, #have_at_most, #include, #map_specs, #match, #method_missing, #raise_error, #respond_to, #run_with, #satisfy, #simple_matcher, #throw_symbol, #with_ruby, #wrap_expectation

Methods included from Spec::Matchers::DSL

#create, #define

Methods included from Spec::Example::Subject::ExampleMethods

#__should_for_example_group__, #__should_not_for_example_group__, #should, #should_not, #subject

Constructor Details

This class inherits a constructor from Test::Unit::TestCase

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Spec::Matchers

Instance Method Details

#setupObject



4
5
6
7
8
9
# File 'lib/vendor/plugins/open_id_authentication/test/open_id_authentication_test.rb', line 4

def setup
  @controller = Class.new do
    include OpenIdAuthentication
    def params() {} end
  end.new
end

#test_authentication_should_be_invalid_when_the_identity_url_is_invalidObject



23
24
25
26
27
28
# File 'lib/vendor/plugins/open_id_authentication/test/open_id_authentication_test.rb', line 23

def test_authentication_should_be_invalid_when_the_identity_url_is_invalid
  @controller.send(:authenticate_with_open_id, "!") do |result, identity_url|
    assert result.invalid?, "Result expected to be invalid but was not"
    assert_equal "Sorry, but this does not appear to be a valid OpenID", result.message
  end
end

#test_authentication_should_begin_when_the_identity_server_is_presentObject



42
43
44
45
# File 'lib/vendor/plugins/open_id_authentication/test/open_id_authentication_test.rb', line 42

def test_authentication_should_begin_when_the_identity_server_is_present
  @controller.expects(:begin_open_id_authentication)
  @controller.send(:authenticate_with_open_id, "http://someone.example.com")
end

#test_authentication_should_fail_when_the_identity_server_is_missingObject



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/vendor/plugins/open_id_authentication/test/open_id_authentication_test.rb', line 11

def test_authentication_should_fail_when_the_identity_server_is_missing
  open_id_consumer = mock()
  open_id_consumer.expects(:begin).raises(OpenID::OpenIDError)
  @controller.expects(:open_id_consumer).returns(open_id_consumer)
  @controller.expects(:logger).returns(mock(:error => true))

  @controller.send(:authenticate_with_open_id, "http://someone.example.com") do |result, identity_url|
    assert result.missing?
    assert_equal "Sorry, the OpenID server couldn't be found", result.message
  end
end

#test_authentication_should_fail_when_the_identity_server_times_outObject



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/vendor/plugins/open_id_authentication/test/open_id_authentication_test.rb', line 30

def test_authentication_should_fail_when_the_identity_server_times_out
  open_id_consumer = mock()
  open_id_consumer.expects(:begin).raises(Timeout::Error, "Identity Server took too long.")
  @controller.expects(:open_id_consumer).returns(open_id_consumer)
  @controller.expects(:logger).returns(mock(:error => true))

  @controller.send(:authenticate_with_open_id, "http://someone.example.com") do |result, identity_url|
    assert result.missing?
    assert_equal "Sorry, the OpenID server couldn't be found", result.message
  end
end