mithril 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +31 -0
- data/README.md +0 -0
- data/bin/mithril +5 -0
- data/lib/mithril.rb +13 -0
- data/lib/mithril/controllers.rb +7 -0
- data/lib/mithril/controllers/abstract_controller.rb +130 -0
- data/lib/mithril/controllers/mixins.rb +7 -0
- data/lib/mithril/controllers/mixins/actions_base.rb +114 -0
- data/lib/mithril/controllers/mixins/help_actions.rb +46 -0
- data/lib/mithril/controllers/mixins/mixin_with_actions.rb +27 -0
- data/lib/mithril/controllers/proxy_controller.rb +89 -0
- data/lib/mithril/mixin.rb +33 -0
- data/lib/mithril/parsers.rb +7 -0
- data/lib/mithril/parsers/simple_parser.rb +57 -0
- data/lib/mithril/request.rb +11 -0
- data/lib/mithril/version.rb +5 -0
- data/spec/matchers/be_kind_of_spec.rb +50 -0
- data/spec/matchers/construct_spec.rb +49 -0
- data/spec/matchers/respond_to_spec.rb +158 -0
- data/spec/mithril/controllers/_text_controller_helper.rb +81 -0
- data/spec/mithril/controllers/abstract_controller_helper.rb +118 -0
- data/spec/mithril/controllers/abstract_controller_spec.rb +15 -0
- data/spec/mithril/controllers/mixins/actions_base_helper.rb +121 -0
- data/spec/mithril/controllers/mixins/actions_base_spec.rb +18 -0
- data/spec/mithril/controllers/mixins/help_actions_helper.rb +111 -0
- data/spec/mithril/controllers/mixins/help_actions_spec.rb +19 -0
- data/spec/mithril/controllers/mixins/mixin_with_actions_spec.rb +44 -0
- data/spec/mithril/controllers/proxy_controller_helper.rb +111 -0
- data/spec/mithril/controllers/proxy_controller_spec.rb +14 -0
- data/spec/mithril/mixin_helper.rb +54 -0
- data/spec/mithril/mixin_spec.rb +17 -0
- data/spec/mithril/parsers/simple_parser_spec.rb +85 -0
- data/spec/mithril/request_spec.rb +72 -0
- data/spec/mithril_spec.rb +25 -0
- data/spec/spec_helper.rb +15 -0
- data/spec/support/factories/action_factory.rb +7 -0
- data/spec/support/factories/request_factory.rb +11 -0
- data/spec/support/matchers/be_kind_of.rb +23 -0
- data/spec/support/matchers/construct.rb +49 -0
- data/spec/support/matchers/respond_to.rb +52 -0
- metadata +142 -0
@@ -0,0 +1,49 @@
|
|
1
|
+
# spec/support/matchers/construct.rb
|
2
|
+
|
3
|
+
require 'rspec'
|
4
|
+
|
5
|
+
RSpec::Matchers.define :construct do
|
6
|
+
def matches?(actual)
|
7
|
+
@actual = actual
|
8
|
+
return false unless actual.respond_to? :new
|
9
|
+
return false unless self.matches_arity?(actual)
|
10
|
+
true
|
11
|
+
end # method matches?
|
12
|
+
|
13
|
+
def failure_message_for_should
|
14
|
+
"expected #{@actual.inspect} to initialize#{with_arity}"
|
15
|
+
end # method failure_message_for_should
|
16
|
+
|
17
|
+
def failure_message_for_should_not
|
18
|
+
failure_message_for_should.sub(/to initialize with/, 'not to initialize with')
|
19
|
+
end # method failure_message_for_should_not
|
20
|
+
|
21
|
+
def matches_arity?(actual)
|
22
|
+
return true unless @expected_arity
|
23
|
+
|
24
|
+
parameters = actual.allocate.method(:initialize).parameters
|
25
|
+
required = parameters.count { |type, | :req == type }
|
26
|
+
optional = parameters.count { |type, | :opt == type }
|
27
|
+
variadic = parameters.count { |type, | :rest == type }
|
28
|
+
|
29
|
+
if @expected_arity.is_a? Range
|
30
|
+
@expected_arity.min >= required && (0 < variadic || @expected_arity.max <= required + optional)
|
31
|
+
else
|
32
|
+
@expected_arity >= required && (0 < variadic || @expected_arity <= required + optional)
|
33
|
+
end # if-else
|
34
|
+
end # method matches_arity?
|
35
|
+
|
36
|
+
def with(n)
|
37
|
+
@expected_arity = n
|
38
|
+
self
|
39
|
+
end # method with
|
40
|
+
|
41
|
+
def arguments
|
42
|
+
self
|
43
|
+
end # method arguments
|
44
|
+
|
45
|
+
def with_arity
|
46
|
+
@expected_arity.nil?? "" :
|
47
|
+
" with #{@expected_arity} argument#{@expected_arity == 1 ? '' : 's'}"
|
48
|
+
end # method with_arity
|
49
|
+
end # matcher
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# spec/matchers/respond_to.rb
|
2
|
+
|
3
|
+
require 'rspec'
|
4
|
+
|
5
|
+
module RSpec::Matchers::BuiltIn
|
6
|
+
class RespondTo
|
7
|
+
def find_failing_method_names(actual, filter_method)
|
8
|
+
@actual = actual
|
9
|
+
@failing_method_names = @names.__send__(filter_method) do |name|
|
10
|
+
@actual.respond_to?(name) &&
|
11
|
+
matches_arity?(actual, name) &&
|
12
|
+
matches_block?(actual, name)
|
13
|
+
end # send
|
14
|
+
end # method find_failing_method_names
|
15
|
+
|
16
|
+
def matches_arity?(actual, name)
|
17
|
+
return true unless @expected_arity
|
18
|
+
|
19
|
+
parameters = actual.method(name).parameters
|
20
|
+
required = parameters.count { |type, | :req == type }
|
21
|
+
optional = parameters.count { |type, | :opt == type }
|
22
|
+
variadic = parameters.count { |type, | :rest == type }
|
23
|
+
|
24
|
+
if @expected_arity.is_a? Range
|
25
|
+
@expected_arity.min >= required && (0 < variadic || @expected_arity.max <= required + optional)
|
26
|
+
else
|
27
|
+
@expected_arity >= required && (0 < variadic || @expected_arity <= required + optional)
|
28
|
+
end # if-else
|
29
|
+
end # method matches_arity?
|
30
|
+
|
31
|
+
def matches_block?(actual, name)
|
32
|
+
return true unless @expected_block
|
33
|
+
|
34
|
+
parameters = actual.method(name).parameters
|
35
|
+
0 < parameters.count { |type, | :block == type }
|
36
|
+
end # method matches_block?
|
37
|
+
|
38
|
+
def with(n = nil)
|
39
|
+
@expected_arity = n unless n.nil?
|
40
|
+
self
|
41
|
+
end # method with
|
42
|
+
|
43
|
+
def and
|
44
|
+
self
|
45
|
+
end # method and
|
46
|
+
|
47
|
+
def a_block
|
48
|
+
@expected_block = true
|
49
|
+
self
|
50
|
+
end # method a_block
|
51
|
+
end # class RespondTo
|
52
|
+
end # module
|
metadata
ADDED
@@ -0,0 +1,142 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mithril
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Rob "Merlin" Smith
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-02-04 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rspec
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '2.12'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '2.12'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: factory_girl
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '4.2'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '4.2'
|
46
|
+
description: An interactive text engine
|
47
|
+
email: merlin@sleepingkingstudios.com
|
48
|
+
executables:
|
49
|
+
- mithril
|
50
|
+
extensions: []
|
51
|
+
extra_rdoc_files: []
|
52
|
+
files:
|
53
|
+
- lib/mithril/controllers/abstract_controller.rb
|
54
|
+
- lib/mithril/controllers/mixins/actions_base.rb
|
55
|
+
- lib/mithril/controllers/mixins/help_actions.rb
|
56
|
+
- lib/mithril/controllers/mixins/mixin_with_actions.rb
|
57
|
+
- lib/mithril/controllers/mixins.rb
|
58
|
+
- lib/mithril/controllers/proxy_controller.rb
|
59
|
+
- lib/mithril/controllers.rb
|
60
|
+
- lib/mithril/mixin.rb
|
61
|
+
- lib/mithril/parsers/simple_parser.rb
|
62
|
+
- lib/mithril/parsers.rb
|
63
|
+
- lib/mithril/request.rb
|
64
|
+
- lib/mithril/version.rb
|
65
|
+
- lib/mithril.rb
|
66
|
+
- bin/mithril
|
67
|
+
- CHANGELOG.md
|
68
|
+
- README.md
|
69
|
+
- spec/matchers/be_kind_of_spec.rb
|
70
|
+
- spec/matchers/construct_spec.rb
|
71
|
+
- spec/matchers/respond_to_spec.rb
|
72
|
+
- spec/mithril/controllers/_text_controller_helper.rb
|
73
|
+
- spec/mithril/controllers/abstract_controller_helper.rb
|
74
|
+
- spec/mithril/controllers/abstract_controller_spec.rb
|
75
|
+
- spec/mithril/controllers/mixins/actions_base_helper.rb
|
76
|
+
- spec/mithril/controllers/mixins/actions_base_spec.rb
|
77
|
+
- spec/mithril/controllers/mixins/help_actions_helper.rb
|
78
|
+
- spec/mithril/controllers/mixins/help_actions_spec.rb
|
79
|
+
- spec/mithril/controllers/mixins/mixin_with_actions_spec.rb
|
80
|
+
- spec/mithril/controllers/proxy_controller_helper.rb
|
81
|
+
- spec/mithril/controllers/proxy_controller_spec.rb
|
82
|
+
- spec/mithril/mixin_helper.rb
|
83
|
+
- spec/mithril/mixin_spec.rb
|
84
|
+
- spec/mithril/parsers/simple_parser_spec.rb
|
85
|
+
- spec/mithril/request_spec.rb
|
86
|
+
- spec/mithril_spec.rb
|
87
|
+
- spec/spec_helper.rb
|
88
|
+
- spec/support/factories/action_factory.rb
|
89
|
+
- spec/support/factories/request_factory.rb
|
90
|
+
- spec/support/matchers/be_kind_of.rb
|
91
|
+
- spec/support/matchers/construct.rb
|
92
|
+
- spec/support/matchers/respond_to.rb
|
93
|
+
homepage: http://sleepingkingstudios.com
|
94
|
+
licenses: []
|
95
|
+
post_install_message:
|
96
|
+
rdoc_options: []
|
97
|
+
require_paths:
|
98
|
+
- lib
|
99
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
100
|
+
none: false
|
101
|
+
requirements:
|
102
|
+
- - ! '>='
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
|
+
none: false
|
107
|
+
requirements:
|
108
|
+
- - ! '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
requirements: []
|
112
|
+
rubyforge_project:
|
113
|
+
rubygems_version: 1.8.24
|
114
|
+
signing_key:
|
115
|
+
specification_version: 3
|
116
|
+
summary: An interactive text engine
|
117
|
+
test_files:
|
118
|
+
- spec/matchers/be_kind_of_spec.rb
|
119
|
+
- spec/matchers/construct_spec.rb
|
120
|
+
- spec/matchers/respond_to_spec.rb
|
121
|
+
- spec/mithril/controllers/_text_controller_helper.rb
|
122
|
+
- spec/mithril/controllers/abstract_controller_helper.rb
|
123
|
+
- spec/mithril/controllers/abstract_controller_spec.rb
|
124
|
+
- spec/mithril/controllers/mixins/actions_base_helper.rb
|
125
|
+
- spec/mithril/controllers/mixins/actions_base_spec.rb
|
126
|
+
- spec/mithril/controllers/mixins/help_actions_helper.rb
|
127
|
+
- spec/mithril/controllers/mixins/help_actions_spec.rb
|
128
|
+
- spec/mithril/controllers/mixins/mixin_with_actions_spec.rb
|
129
|
+
- spec/mithril/controllers/proxy_controller_helper.rb
|
130
|
+
- spec/mithril/controllers/proxy_controller_spec.rb
|
131
|
+
- spec/mithril/mixin_helper.rb
|
132
|
+
- spec/mithril/mixin_spec.rb
|
133
|
+
- spec/mithril/parsers/simple_parser_spec.rb
|
134
|
+
- spec/mithril/request_spec.rb
|
135
|
+
- spec/mithril_spec.rb
|
136
|
+
- spec/spec_helper.rb
|
137
|
+
- spec/support/factories/action_factory.rb
|
138
|
+
- spec/support/factories/request_factory.rb
|
139
|
+
- spec/support/matchers/be_kind_of.rb
|
140
|
+
- spec/support/matchers/construct.rb
|
141
|
+
- spec/support/matchers/respond_to.rb
|
142
|
+
has_rdoc:
|