remarkable 3.1.3 → 3.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/remarkable/matchers.rb +3 -2
- data/lib/remarkable/messages.rb +3 -3
- data/lib/remarkable/pending.rb +8 -6
- data/lib/remarkable/version.rb +1 -1
- data/spec/base_spec.rb +0 -7
- data/spec/matchers_spec.rb +50 -0
- metadata +3 -2
data/lib/remarkable/matchers.rb
CHANGED
@@ -18,8 +18,9 @@ module Remarkable
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
target
|
22
|
-
target.send :extend, Remarkable::
|
21
|
+
metaclass = (class << target; self; end)
|
22
|
+
target.send :extend, Remarkable::Pending unless metaclass.ancestors.include?(Remarkable::Pending)
|
23
|
+
target.send :extend, Remarkable::Macros unless metaclass.ancestors.include?(Remarkable::Macros)
|
23
24
|
|
24
25
|
if defined?(base::Matchers)
|
25
26
|
target.send :include, base::Matchers
|
data/lib/remarkable/messages.rb
CHANGED
@@ -80,7 +80,7 @@ module Remarkable
|
|
80
80
|
|
81
81
|
# Converts an array to a sentence
|
82
82
|
#
|
83
|
-
def array_to_sentence(array, inspect=false)
|
83
|
+
def array_to_sentence(array, inspect=false, empty_default='')
|
84
84
|
words_connector = Remarkable.t 'remarkable.core.helpers.words_connector'
|
85
85
|
two_words_connector = Remarkable.t 'remarkable.core.helpers.two_words_connector'
|
86
86
|
last_word_connector = Remarkable.t 'remarkable.core.helpers.last_word_connector'
|
@@ -89,7 +89,7 @@ module Remarkable
|
|
89
89
|
|
90
90
|
case array.length
|
91
91
|
when 0
|
92
|
-
|
92
|
+
empty_default
|
93
93
|
when 1
|
94
94
|
array[0].to_s
|
95
95
|
when 2
|
@@ -97,7 +97,7 @@ module Remarkable
|
|
97
97
|
else
|
98
98
|
"#{array[0...-1].join(words_connector)}#{last_word_connector}#{array[-1]}"
|
99
99
|
end
|
100
|
-
end
|
100
|
+
end
|
101
101
|
|
102
102
|
end
|
103
103
|
end
|
data/lib/remarkable/pending.rb
CHANGED
@@ -5,12 +5,14 @@ module Remarkable
|
|
5
5
|
# We cannot put the alias method in the module because it's a Ruby 1.8 bug
|
6
6
|
# http://coderrr.wordpress.com/2008/03/28/alias_methodmodule-bug-in-ruby-18/
|
7
7
|
#
|
8
|
-
def self.extended(base) #:nodoc:
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
8
|
+
def self.extended(base) #:nodoc:
|
9
|
+
if base.respond_to?(:example)
|
10
|
+
class << base
|
11
|
+
alias_method :example_without_pending, :example
|
12
|
+
alias_method :example, :example_with_pending
|
13
|
+
alias :it :example
|
14
|
+
alias :specify :example
|
15
|
+
end
|
14
16
|
end
|
15
17
|
end
|
16
18
|
|
data/lib/remarkable/version.rb
CHANGED
data/spec/base_spec.rb
CHANGED
@@ -38,11 +38,4 @@ describe Remarkable::Base do
|
|
38
38
|
it 'should allow Macros and Matchers to be added to any class' do
|
39
39
|
MatchersSandbox.new.should respond_to(:contain)
|
40
40
|
end
|
41
|
-
|
42
|
-
it 'should raise an error if include matchers is called without target and rspec is not loaded' do
|
43
|
-
Remarkable.stub!(:rspec_defined?).and_return(false)
|
44
|
-
lambda {
|
45
|
-
Remarkable.include_matchers!(String)
|
46
|
-
}.should raise_error(ArgumentError, "You haven't supplied the target to include_matchers! and RSpec is not loaded, so we cannot infer one.")
|
47
|
-
end
|
48
41
|
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe Remarkable::Matchers do
|
4
|
+
it 'should include matchers in a specified target' do
|
5
|
+
klass = Class.new
|
6
|
+
|
7
|
+
module Foo
|
8
|
+
module Matchers
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
Remarkable.include_matchers!(Foo, klass)
|
13
|
+
klass.ancestors.should include(Foo::Matchers)
|
14
|
+
|
15
|
+
meta = (class << klass; self; end)
|
16
|
+
meta.ancestors.should include(Remarkable::Macros)
|
17
|
+
meta.ancestors.should include(Remarkable::Pending)
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should include matchers in Remarkable::Matchers' do
|
21
|
+
klass = Class.new
|
22
|
+
|
23
|
+
module Foo
|
24
|
+
module Matchers
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
Remarkable.include_matchers!(Foo, klass)
|
29
|
+
Remarkable::Matchers.ancestors.should include(Foo::Matchers)
|
30
|
+
(class << Remarkable::Matchers; self; end).ancestors.should include(Foo::Matchers)
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should raise an error if include matchers is called without target and rspec is not loaded' do
|
34
|
+
Remarkable.stub!(:rspec_defined?).and_return(false)
|
35
|
+
lambda {
|
36
|
+
Remarkable.include_matchers!(String)
|
37
|
+
}.should raise_error(ArgumentError, "You haven't supplied the target to include_matchers! and RSpec is not loaded, so we cannot infer one.")
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'should not include modules twice' do
|
41
|
+
klass = Class.new
|
42
|
+
meta = (class << klass; self; end)
|
43
|
+
|
44
|
+
meta.should_receive(:ancestors).twice.and_return([Remarkable::Pending, Remarkable::Macros])
|
45
|
+
klass.should_not_receive(:extend).with(Remarkable::Pending)
|
46
|
+
klass.should_not_receive(:extend).with(Remarkable::Macros)
|
47
|
+
|
48
|
+
Remarkable.include_matchers!(Module.new, klass)
|
49
|
+
end
|
50
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: remarkable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1.
|
4
|
+
version: 3.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carlos Brando
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2009-05-
|
13
|
+
date: 2009-05-29 00:00:00 +02:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -91,6 +91,7 @@ test_files:
|
|
91
91
|
- spec/i18n_spec.rb
|
92
92
|
- spec/base_spec.rb
|
93
93
|
- spec/spec_helper.rb
|
94
|
+
- spec/matchers_spec.rb
|
94
95
|
- spec/macros_spec.rb
|
95
96
|
- spec/spec.opts
|
96
97
|
- spec/pending_spec.rb
|