slimkeyfy 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +34 -0
- data/.rspec +3 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +22 -0
- data/LICENSE +21 -0
- data/README.md +172 -0
- data/bin/slimkeyfy +5 -0
- data/lib/.DS_Store +0 -0
- data/lib/slimkeyfy/console/command_line.rb +90 -0
- data/lib/slimkeyfy/console/io_action.rb +30 -0
- data/lib/slimkeyfy/console/printer.rb +50 -0
- data/lib/slimkeyfy/console/translate.rb +101 -0
- data/lib/slimkeyfy/console.rb +8 -0
- data/lib/slimkeyfy/slimutils/file_utils.rb +61 -0
- data/lib/slimkeyfy/slimutils/hash_merging.rb +84 -0
- data/lib/slimkeyfy/slimutils/key_generator.rb +70 -0
- data/lib/slimkeyfy/slimutils/yaml_processor.rb +56 -0
- data/lib/slimkeyfy/slimutils.rb +8 -0
- data/lib/slimkeyfy/transformer/base_transformer.rb +42 -0
- data/lib/slimkeyfy/transformer/controller_transformer.rb +20 -0
- data/lib/slimkeyfy/transformer/slim_transformer.rb +92 -0
- data/lib/slimkeyfy/transformer/whitespacer.rb +48 -0
- data/lib/slimkeyfy/transformer/word.rb +49 -0
- data/lib/slimkeyfy/transformer.rb +9 -0
- data/lib/slimkeyfy/version.rb +3 -0
- data/lib/slimkeyfy.rb +12 -0
- data/slimkeyfy.gemspec +21 -0
- data/vendor/bundle/bin/htmldiff +25 -0
- data/vendor/bundle/bin/ldiff +25 -0
- data/vendor/bundle/bin/rspec +23 -0
- data/vendor/bundle/build_info/diff-lcs-1.2.5.info +1 -0
- data/vendor/bundle/build_info/rspec-3.0.0.info +1 -0
- data/vendor/bundle/build_info/rspec-core-3.0.2.info +1 -0
- data/vendor/bundle/build_info/rspec-expectations-3.0.2.info +1 -0
- data/vendor/bundle/build_info/rspec-mocks-3.0.2.info +1 -0
- data/vendor/bundle/build_info/rspec-support-3.0.2.info +1 -0
- data/vendor/bundle/gems/diff-lcs-1.2.5/.autotest +3 -0
- data/vendor/bundle/gems/diff-lcs-1.2.5/.gemtest +0 -0
- data/vendor/bundle/gems/diff-lcs-1.2.5/.hoerc +2 -0
- data/vendor/bundle/gems/diff-lcs-1.2.5/.rspec +2 -0
- data/vendor/bundle/gems/diff-lcs-1.2.5/.travis.yml +22 -0
- data/vendor/bundle/gems/diff-lcs-1.2.5/Contributing.rdoc +64 -0
- data/vendor/bundle/gems/diff-lcs-1.2.5/Gemfile +20 -0
- data/vendor/bundle/gems/diff-lcs-1.2.5/History.rdoc +152 -0
- data/vendor/bundle/gems/diff-lcs-1.2.5/License.rdoc +39 -0
- data/vendor/bundle/gems/diff-lcs-1.2.5/Manifest.txt +38 -0
- data/vendor/bundle/gems/diff-lcs-1.2.5/README.rdoc +85 -0
- data/vendor/bundle/gems/diff-lcs-1.2.5/Rakefile +41 -0
- data/vendor/bundle/gems/diff-lcs-1.2.5/autotest/discover.rb +1 -0
- data/vendor/bundle/gems/diff-lcs-1.2.5/bin/htmldiff +32 -0
- data/vendor/bundle/gems/diff-lcs-1.2.5/bin/ldiff +6 -0
- data/vendor/bundle/gems/diff-lcs-1.2.5/docs/COPYING.txt +339 -0
- data/vendor/bundle/gems/diff-lcs-1.2.5/docs/artistic.txt +127 -0
- data/vendor/bundle/gems/diff-lcs-1.2.5/lib/diff/lcs/array.rb +7 -0
- data/vendor/bundle/gems/diff-lcs-1.2.5/lib/diff/lcs/block.rb +37 -0
- data/vendor/bundle/gems/diff-lcs-1.2.5/lib/diff/lcs/callbacks.rb +322 -0
- data/vendor/bundle/gems/diff-lcs-1.2.5/lib/diff/lcs/change.rb +177 -0
- data/vendor/bundle/gems/diff-lcs-1.2.5/lib/diff/lcs/htmldiff.rb +149 -0
- data/vendor/bundle/gems/diff-lcs-1.2.5/lib/diff/lcs/hunk.rb +276 -0
- data/vendor/bundle/gems/diff-lcs-1.2.5/lib/diff/lcs/internals.rb +301 -0
- data/vendor/bundle/gems/diff-lcs-1.2.5/lib/diff/lcs/ldiff.rb +195 -0
- data/vendor/bundle/gems/diff-lcs-1.2.5/lib/diff/lcs/string.rb +5 -0
- data/vendor/bundle/gems/diff-lcs-1.2.5/lib/diff/lcs.rb +805 -0
- data/vendor/bundle/gems/diff-lcs-1.2.5/lib/diff-lcs.rb +3 -0
- data/vendor/bundle/gems/rspec-3.0.0/License.txt +24 -0
- data/vendor/bundle/gems/rspec-3.0.0/README.md +47 -0
- data/vendor/bundle/gems/rspec-3.0.0/lib/rspec.rb +3 -0
- data/vendor/bundle/gems/rspec-core-3.0.2/.document +5 -0
- data/vendor/bundle/gems/rspec-core-3.0.2/.yardopts +7 -0
- data/vendor/bundle/gems/rspec-core-3.0.2/Changelog.md +1466 -0
- data/vendor/bundle/gems/rspec-core-3.0.2/License.txt +25 -0
- data/vendor/bundle/gems/rspec-core-3.0.2/README.md +243 -0
- data/vendor/bundle/gems/rspec-core-3.0.2/exe/rspec +4 -0
- data/vendor/bundle/gems/rspec-expectations-3.0.2/.document +5 -0
- data/vendor/bundle/gems/rspec-expectations-3.0.2/.yardopts +6 -0
- data/vendor/bundle/gems/rspec-expectations-3.0.2/Changelog.md +749 -0
- data/vendor/bundle/gems/rspec-expectations-3.0.2/License.txt +24 -0
- data/vendor/bundle/gems/rspec-expectations-3.0.2/README.md +278 -0
- data/vendor/bundle/gems/rspec-mocks-3.0.2/.document +5 -0
- data/vendor/bundle/gems/rspec-mocks-3.0.2/.yardopts +6 -0
- data/vendor/bundle/gems/rspec-mocks-3.0.2/Changelog.md +733 -0
- data/vendor/bundle/gems/rspec-mocks-3.0.2/License.txt +24 -0
- data/vendor/bundle/gems/rspec-mocks-3.0.2/README.md +380 -0
- data/vendor/bundle/gems/rspec-support-3.0.2/Changelog.md +30 -0
- data/vendor/bundle/gems/rspec-support-3.0.2/LICENSE.txt +22 -0
- data/vendor/bundle/gems/rspec-support-3.0.2/README.md +17 -0
- data/vendor/bundle/specifications/diff-lcs-1.2.5.gemspec +68 -0
- data/vendor/bundle/specifications/rspec-3.0.0.gemspec +43 -0
- data/vendor/bundle/specifications/rspec-core-3.0.2.gemspec +66 -0
- data/vendor/bundle/specifications/rspec-expectations-3.0.2.gemspec +51 -0
- data/vendor/bundle/specifications/rspec-mocks-3.0.2.gemspec +48 -0
- data/vendor/bundle/specifications/rspec-support-3.0.2.gemspec +42 -0
- metadata +153 -0
@@ -0,0 +1,25 @@
|
|
1
|
+
(The MIT License)
|
2
|
+
|
3
|
+
Copyright (c) 2012 Chad Humphries, David Chelimsky, Myron Marston
|
4
|
+
Copyright (c) 2009 Chad Humphries, David Chelimsky
|
5
|
+
Copyright (c) 2006 David Chelimsky, The RSpec Development Team
|
6
|
+
Copyright (c) 2005 Steven Baker
|
7
|
+
|
8
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
9
|
+
a copy of this software and associated documentation files (the
|
10
|
+
"Software"), to deal in the Software without restriction, including
|
11
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
12
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
13
|
+
permit persons to whom the Software is furnished to do so, subject to
|
14
|
+
the following conditions:
|
15
|
+
|
16
|
+
The above copyright notice and this permission notice shall be
|
17
|
+
included in all copies or substantial portions of the Software.
|
18
|
+
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
20
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
21
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
22
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
23
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
24
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
25
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,243 @@
|
|
1
|
+
# rspec-core [![Build Status](https://secure.travis-ci.org/rspec/rspec-core.png?branch=master)](http://travis-ci.org/rspec/rspec-core) [![Code Climate](https://codeclimate.com/github/rspec/rspec-core.png)](https://codeclimate.com/github/rspec/rspec-core)
|
2
|
+
|
3
|
+
rspec-core provides the structure for writing executable examples of how your
|
4
|
+
code should behave, and an `rspec` command with tools to constrain which
|
5
|
+
examples get run and tailor the output.
|
6
|
+
|
7
|
+
## install
|
8
|
+
|
9
|
+
gem install rspec # for rspec-core, rspec-expectations, rspec-mocks
|
10
|
+
gem install rspec-core # for rspec-core only
|
11
|
+
rspec --help
|
12
|
+
|
13
|
+
## basic structure
|
14
|
+
|
15
|
+
RSpec uses the words "describe" and "it" so we can express concepts like a conversation:
|
16
|
+
|
17
|
+
"Describe an order."
|
18
|
+
"It sums the prices of its line items."
|
19
|
+
|
20
|
+
```ruby
|
21
|
+
RSpec.describe Order do
|
22
|
+
it "sums the prices of its line items" do
|
23
|
+
order = Order.new
|
24
|
+
order.add_entry(LineItem.new(:item => Item.new(
|
25
|
+
:price => Money.new(1.11, :USD)
|
26
|
+
)))
|
27
|
+
order.add_entry(LineItem.new(:item => Item.new(
|
28
|
+
:price => Money.new(2.22, :USD),
|
29
|
+
:quantity => 2
|
30
|
+
)))
|
31
|
+
expect(order.total).to eq(Money.new(5.55, :USD))
|
32
|
+
end
|
33
|
+
end
|
34
|
+
```
|
35
|
+
|
36
|
+
The `describe` method creates an [ExampleGroup](http://rubydoc.info/gems/rspec-core/RSpec/Core/ExampleGroup). Within the
|
37
|
+
block passed to `describe` you can declare examples using the `it` method.
|
38
|
+
|
39
|
+
Under the hood, an example group is a class in which the block passed to
|
40
|
+
`describe` is evaluated. The blocks passed to `it` are evaluated in the
|
41
|
+
context of an _instance_ of that class.
|
42
|
+
|
43
|
+
## nested groups
|
44
|
+
|
45
|
+
You can also declare nested nested groups using the `describe` or `context`
|
46
|
+
methods:
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
RSpec.describe Order do
|
50
|
+
context "with no items" do
|
51
|
+
it "behaves one way" do
|
52
|
+
# ...
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
context "with one item" do
|
57
|
+
it "behaves another way" do
|
58
|
+
# ...
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
```
|
63
|
+
|
64
|
+
## aliases
|
65
|
+
|
66
|
+
You can declare example groups using either `describe` or `context`.
|
67
|
+
For a top level example group, `describe` and `context` are available
|
68
|
+
off of `RSpec`. For backwards compatibility, they are also available
|
69
|
+
off of the `main` object and `Module` unless you disable monkey
|
70
|
+
patching.
|
71
|
+
|
72
|
+
You can declare examples within a group using any of `it`, `specify`, or
|
73
|
+
`example`.
|
74
|
+
|
75
|
+
## shared examples and contexts
|
76
|
+
|
77
|
+
Declare a shared example group using `shared_examples`, and then include it
|
78
|
+
in any group using `include_examples`.
|
79
|
+
|
80
|
+
```ruby
|
81
|
+
RSpec.shared_examples "collections" do |collection_class|
|
82
|
+
it "is empty when first created" do
|
83
|
+
expect(collection_class.new).to be_empty
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
RSpec.describe Array do
|
88
|
+
include_examples "collections", Array
|
89
|
+
end
|
90
|
+
|
91
|
+
RSpec.describe Hash do
|
92
|
+
include_examples "collections", Hash
|
93
|
+
end
|
94
|
+
```
|
95
|
+
|
96
|
+
Nearly anything that can be declared within an example group can be declared
|
97
|
+
within a shared example group. This includes `before`, `after`, and `around`
|
98
|
+
hooks, `let` declarations, and nested groups/contexts.
|
99
|
+
|
100
|
+
You can also use the names `shared_context` and `include_context`. These are
|
101
|
+
pretty much the same as `shared_examples` and `include_examples`, providing
|
102
|
+
more accurate naming when you share hooks, `let` declarations, helper methods,
|
103
|
+
etc, but no examples.
|
104
|
+
|
105
|
+
## metadata
|
106
|
+
|
107
|
+
rspec-core stores a metadata hash with every example and group, which
|
108
|
+
contains their descriptions, the locations at which they were
|
109
|
+
declared, etc, etc. This hash powers many of rspec-core's features,
|
110
|
+
including output formatters (which access descriptions and locations),
|
111
|
+
and filtering before and after hooks.
|
112
|
+
|
113
|
+
Although you probably won't ever need this unless you are writing an
|
114
|
+
extension, you can access it from an example like this:
|
115
|
+
|
116
|
+
```ruby
|
117
|
+
it "does something" do
|
118
|
+
expect(example.metadata[:description]).to eq("does something")
|
119
|
+
end
|
120
|
+
```
|
121
|
+
|
122
|
+
### `described_class`
|
123
|
+
|
124
|
+
When a class is passed to `describe`, you can access it from an example
|
125
|
+
using the `described_class` method, which is a wrapper for
|
126
|
+
`example.metadata[:described_class]`.
|
127
|
+
|
128
|
+
```ruby
|
129
|
+
RSpec.describe Widget do
|
130
|
+
example do
|
131
|
+
expect(described_class).to equal(Widget)
|
132
|
+
end
|
133
|
+
end
|
134
|
+
```
|
135
|
+
|
136
|
+
This is useful in extensions or shared example groups in which the specific
|
137
|
+
class is unknown. Taking the collections shared example group from above, we can
|
138
|
+
clean it up a bit using `described_class`:
|
139
|
+
|
140
|
+
```ruby
|
141
|
+
RSpec.shared_examples "collections" do
|
142
|
+
it "is empty when first created" do
|
143
|
+
expect(described_class.new).to be_empty
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
RSpec.describe Array do
|
148
|
+
include_examples "collections"
|
149
|
+
end
|
150
|
+
|
151
|
+
RSpec.describe Hash do
|
152
|
+
include_examples "collections"
|
153
|
+
end
|
154
|
+
```
|
155
|
+
|
156
|
+
## the `rspec` command
|
157
|
+
|
158
|
+
When you install the rspec-core gem, it installs the `rspec` executable,
|
159
|
+
which you'll use to run rspec. The `rspec` command comes with many useful
|
160
|
+
options.
|
161
|
+
Run `rspec --help` to see the complete list.
|
162
|
+
|
163
|
+
## store command line options `.rspec`
|
164
|
+
|
165
|
+
You can store command line options in a `.rspec` file in the project's root
|
166
|
+
directory, and the `rspec` command will read them as though you typed them on
|
167
|
+
the command line.
|
168
|
+
|
169
|
+
## autotest integration
|
170
|
+
|
171
|
+
rspec-core no longer ships with an Autotest extension, if you require Autotest
|
172
|
+
integration, please use the `rspec-autotest` gem and see [rspec/rspec-autotest](https://github.com/rspec/rspec-autotest)
|
173
|
+
for details
|
174
|
+
|
175
|
+
## get started
|
176
|
+
|
177
|
+
Start with a simple example of behavior you expect from your system. Do
|
178
|
+
this before you write any implementation code:
|
179
|
+
|
180
|
+
```ruby
|
181
|
+
# in spec/calculator_spec.rb
|
182
|
+
RSpec.describe Calculator do
|
183
|
+
describe '#add' do
|
184
|
+
it 'returns the sum of its arguments' do
|
185
|
+
expect(Calculator.new.add(1, 2)).to eq(3)
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|
189
|
+
```
|
190
|
+
|
191
|
+
Run this with the rspec command, and watch it fail:
|
192
|
+
|
193
|
+
```
|
194
|
+
$ rspec spec/calculator_spec.rb
|
195
|
+
./spec/calculator_spec.rb:1: uninitialized constant Calculator
|
196
|
+
```
|
197
|
+
|
198
|
+
Implement the simplest solution:
|
199
|
+
|
200
|
+
```ruby
|
201
|
+
# in lib/calculator.rb
|
202
|
+
class Calculator
|
203
|
+
def add(a,b)
|
204
|
+
a + b
|
205
|
+
end
|
206
|
+
end
|
207
|
+
```
|
208
|
+
|
209
|
+
Be sure to require the implementation file in the spec:
|
210
|
+
|
211
|
+
```ruby
|
212
|
+
# in spec/calculator_spec.rb
|
213
|
+
# - RSpec adds ./lib to the $LOAD_PATH
|
214
|
+
require "calculator"
|
215
|
+
```
|
216
|
+
|
217
|
+
Now run the spec again, and watch it pass:
|
218
|
+
|
219
|
+
```
|
220
|
+
$ rspec spec/calculator_spec.rb
|
221
|
+
.
|
222
|
+
|
223
|
+
Finished in 0.000315 seconds
|
224
|
+
1 example, 0 failures
|
225
|
+
```
|
226
|
+
|
227
|
+
Use the `documentation` formatter to see the resulting spec:
|
228
|
+
|
229
|
+
```
|
230
|
+
$ rspec spec/calculator_spec.rb --format doc
|
231
|
+
Calculator
|
232
|
+
#add
|
233
|
+
returns the sum of its arguments
|
234
|
+
|
235
|
+
Finished in 0.000379 seconds
|
236
|
+
1 example, 0 failures
|
237
|
+
```
|
238
|
+
|
239
|
+
## Also see
|
240
|
+
|
241
|
+
* [http://github.com/rspec/rspec](http://github.com/rspec/rspec)
|
242
|
+
* [http://github.com/rspec/rspec-expectations](http://github.com/rspec/rspec-expectations)
|
243
|
+
* [http://github.com/rspec/rspec-mocks](http://github.com/rspec/rspec-mocks)
|