ghaki-canned-input 2011.11.30.1

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/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2010 Gerald Kalafut
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
data/README ADDED
@@ -0,0 +1,23 @@
1
+ = Ghaki Canned Input - RSpec canned input helpers
2
+
3
+ Ghaki Canned Input is a collection of RSpec canned input mixin helpers.
4
+
5
+ == Download
6
+
7
+ The latest version of Ghaki Canned Input can be found at
8
+
9
+ * git@github.com:ghaki/ghaki-canned-input.git
10
+
11
+ == Installation
12
+
13
+ The preferred method of installing Ghaki Canned Input is through its GEM file.
14
+
15
+ % [sudo] gem install ghaki-canned-input-1.0.0.gem
16
+
17
+ == License
18
+
19
+ Ghaki Canned Input is released under the MIT license.
20
+
21
+ == Support
22
+
23
+ Contact mailto:gerald@kalafut.org
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 2011.11.30.1
@@ -0,0 +1,48 @@
1
+ module Ghaki #:nodoc:
2
+ module CannedInput #:nodoc:
3
+
4
+ module AcceptsDataFrom
5
+
6
+ def it_should_accept_data_from data, name, &block
7
+ _should_accept_with 'should accept', true, data, name, &block
8
+ end
9
+
10
+ def it_should_reject_data_from data, name, &block
11
+ _should_accept_with 'should reject', false, data, name, &block
12
+ end
13
+
14
+ protected
15
+
16
+ def _should_accept_with_hash prefix, state, data, &block
17
+ data.each_pair do |item,rule|
18
+ it prefix + ': ' + rule.to_s do
19
+ block.call(item).should == state
20
+ end
21
+ end
22
+ end
23
+
24
+ def _should_accept_with_array prefix, state, data, &block
25
+ data.each do |item|
26
+ it prefix + ': ' + item.to_s do
27
+ block.call(item).should == state
28
+ end
29
+ end
30
+ end
31
+
32
+ def _should_accept_with prefix, state, cfg_data, cfg_name, &block
33
+ name = cfg_name.to_s
34
+ data = cfg_data[name]
35
+ case data
36
+ when nil then
37
+ raise ArgumentError, 'Missing Acceptance Test Data For: ' + name
38
+ when Array then
39
+ _should_accept_with_array prefix, state, data, &block
40
+ when Hash then
41
+ _should_accept_with_hash prefix, state, data, &block
42
+ else
43
+ raise ArgumentError, 'Invalid Acceptance Test Data For: ' + name
44
+ end
45
+ end
46
+
47
+ end
48
+ end end
@@ -0,0 +1,44 @@
1
+ module Ghaki #:nodoc:
2
+ module CannedInput #:nodoc:
3
+
4
+ module RaisesOnData
5
+
6
+ def it_should_raise_on_data cfg_data, cfg_name, err, msg, &block
7
+ name = cfg_name.to_s
8
+ data = cfg_data[name]
9
+ case data
10
+ when nil then
11
+ raise ArgumentError, 'Missing Acceptance Test Data For: ' + name
12
+ when Array then
13
+ _should_raise_on_data_array data, err, msg, &block
14
+ when Hash then
15
+ _should_raise_on_data_hash data, err, msg, &block
16
+ else
17
+ raise ArgumentError, 'Invalid Acceptance Test Data For: ' + name
18
+ end
19
+ end
20
+
21
+ protected
22
+
23
+ def _should_raise_on_data_it rule, data, err, msg, &block
24
+ it 'should raise on: ' + rule do
25
+ lambda do
26
+ block.call( data )
27
+ end.should raise_error( *([err,msg].compact) )
28
+ end
29
+ end
30
+
31
+ def _should_raise_on_data_hash data, err, msg, &block
32
+ data.each_pair do |item,rule|
33
+ _should_raise_on_data_it rule, item, err, msg, &block
34
+ end
35
+ end
36
+
37
+ def _should_raise_on_data_array data, err, msg, &block
38
+ data.each do |item|
39
+ _should_raise_on_data_it item, item, err, msg, &block
40
+ end
41
+ end
42
+
43
+ end
44
+ end end
@@ -0,0 +1,43 @@
1
+ module Ghaki #:nodoc:
2
+ module CannedInput #:nodoc:
3
+
4
+ module TransformsDataInto
5
+
6
+ def it_should_transform_data_into cfg_data, cfg_name, &block
7
+ name = cfg_name.to_s
8
+ data = cfg_data[name]
9
+ case data
10
+ when nil then
11
+ raise ArgumentError, 'Missing Acceptance Test Data For: ' + name
12
+ when Array then
13
+ _should_transform_data_from_table data, &block
14
+ when Hash then
15
+ _should_transform_data_from_hash data, &block
16
+ else
17
+ raise ArgumentError, 'Invalid Acceptance Test Data For: ' + name
18
+ end
19
+ end
20
+
21
+ protected
22
+
23
+ def _should_transform_data_make rule, get, put, &block
24
+ it 'should transform: ' + rule do
25
+ block.call( get ).should == put
26
+ end
27
+ end
28
+
29
+ def _should_transform_data_from_hash data, &block
30
+ data.each_pair do |input,output|
31
+ _should_transform_data_make input.to_s, input, output, &block
32
+ end
33
+ end
34
+
35
+ def _should_transform_data_from_table data, &block
36
+ data.each do |entry|
37
+ rule = entry['rule'] || entry['input'].to_s
38
+ _should_transform_data_make rule, entry['input'], entry['output'], &block
39
+ end
40
+ end
41
+
42
+ end
43
+ end end
@@ -0,0 +1,10 @@
1
+ require 'ghaki/canned_input/accepts_data_from'
2
+
3
+ describe Ghaki::CannedInput::AcceptsDataFrom do
4
+ include Ghaki::CannedInput::AcceptsDataFrom
5
+
6
+ subject { self }
7
+ it { should respond_to :it_should_accept_data_from }
8
+ it { should respond_to :it_should_reject_data_from }
9
+
10
+ end
@@ -0,0 +1,9 @@
1
+ require 'ghaki/canned_input/raises_on_data'
2
+
3
+ describe Ghaki::CannedInput::RaisesOnData do
4
+ include Ghaki::CannedInput::RaisesOnData
5
+
6
+ subject { self }
7
+ it { should respond_to :it_should_raise_on_data }
8
+
9
+ end
@@ -0,0 +1,9 @@
1
+ require 'ghaki/canned_input/transforms_data_into'
2
+
3
+ describe Ghaki::CannedInput::TransformsDataInto do
4
+ include Ghaki::CannedInput::TransformsDataInto
5
+
6
+ subject { self }
7
+ it { should respond_to :it_should_transform_data_into }
8
+
9
+ end
@@ -0,0 +1,7 @@
1
+ require 'bundler/setup'
2
+ require 'mocha'
3
+
4
+ RSpec.configure do |cfg|
5
+ cfg.mock_with :mocha
6
+ cfg.color_enabled = true
7
+ end
metadata ADDED
@@ -0,0 +1,92 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ghaki-canned-input
3
+ version: !ruby/object:Gem::Version
4
+ version: 2011.11.30.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Gerald Kalafut
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-11-30 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: &71705430 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 2.4.0
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *71705430
25
+ - !ruby/object:Gem::Dependency
26
+ name: mocha
27
+ requirement: &71705140 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: 0.9.12
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *71705140
36
+ - !ruby/object:Gem::Dependency
37
+ name: rdoc
38
+ requirement: &71704860 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: 3.9.4
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *71704860
47
+ description: Collection of RSpec canned input mixin helpers.
48
+ email: gerald@kalafut.org
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files:
52
+ - README
53
+ files:
54
+ - lib/ghaki/canned_input/accepts_data_from.rb
55
+ - lib/ghaki/canned_input/raises_on_data.rb
56
+ - lib/ghaki/canned_input/transforms_data_into.rb
57
+ - README
58
+ - LICENSE
59
+ - VERSION
60
+ - spec/ghaki/canned_input/accepts_data_from_spec.rb
61
+ - spec/ghaki/canned_input/transforms_data_into_spec.rb
62
+ - spec/ghaki/canned_input/raises_on_data_spec.rb
63
+ - spec/spec_helper.rb
64
+ homepage: http://github.com/ghaki
65
+ licenses: []
66
+ post_install_message:
67
+ rdoc_options: []
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ none: false
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ none: false
78
+ requirements:
79
+ - - ! '>='
80
+ - !ruby/object:Gem::Version
81
+ version: 1.3.6
82
+ requirements: []
83
+ rubyforge_project: ghaki-canned-input
84
+ rubygems_version: 1.8.10
85
+ signing_key:
86
+ specification_version: 3
87
+ summary: RSpec canned input helpers
88
+ test_files:
89
+ - spec/ghaki/canned_input/accepts_data_from_spec.rb
90
+ - spec/ghaki/canned_input/transforms_data_into_spec.rb
91
+ - spec/ghaki/canned_input/raises_on_data_spec.rb
92
+ - spec/spec_helper.rb