sw2at-tw 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b894823442f0180a50a67291e98e94b231a78ab9
4
+ data.tar.gz: 5cdad9bf6f45b01710bb026e59147c92216ded45
5
+ SHA512:
6
+ metadata.gz: 884828ee861944b1a7fb2a3a65bd41f06c5e32c0a75c38e4736e0cc5296ece09c7404706ea52058731a2d97bc6612cc1a2cff86e2f6560fe30cd349849f69103
7
+ data.tar.gz: 2be0a6917551b42aad2d0576fee491299a7b2ef7b5405ae9ab99f01db0eaae21584210470f19f27e0207d85976b558411eb34be5137cd36d7faeb086e97e702e
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem 'sw2at-capybara', '~> 0.0.1'
4
+ gem 'timecop', '~> 0.7.1'
5
+
6
+ group :development do
7
+ gem "shoulda", ">= 0"
8
+ gem "rdoc", "~> 3.12"
9
+ gem "bundler", "~> 1.0"
10
+ gem "jeweler", "~> 2.0.1"
11
+ gem "simplecov", ">= 0"
12
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2015 Vitaly Tarasenko
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,19 @@
1
+ = sw2at-tw
2
+
3
+ Description goes here.
4
+
5
+ == Contributing to sw2at-tw
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
9
+ * Fork the project.
10
+ * Start a feature/bugfix branch.
11
+ * Commit and push until you are happy with your contribution.
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2015 Vitaly Tarasenko. See LICENSE.txt for
18
+ further details.
19
+
data/Rakefile ADDED
@@ -0,0 +1,51 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
17
+ gem.name = "sw2at-tw"
18
+ gem.homepage = "http://github.com/tarvit/sw2at-tw"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{ Swat Test World - Helper for test data generation. }
21
+ gem.description = %Q{ You can define your own strategies for test data generation. And simply create them in RSpec tests. }
22
+ gem.email = "vetal.tarasenko@gmail.com"
23
+ gem.authors = ["Vitaly Tarasenko"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rake/testtask'
29
+ Rake::TestTask.new(:test) do |test|
30
+ test.libs << 'lib' << 'test'
31
+ test.pattern = 'test/**/test_*.rb'
32
+ test.verbose = true
33
+ end
34
+
35
+ desc "Code coverage detail"
36
+ task :simplecov do
37
+ ENV['COVERAGE'] = "true"
38
+ Rake::Task['test'].execute
39
+ end
40
+
41
+ task :default => :test
42
+
43
+ require 'rdoc/task'
44
+ Rake::RDocTask.new do |rdoc|
45
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
46
+
47
+ rdoc.rdoc_dir = 'rdoc'
48
+ rdoc.title = "sw2at-tw #{version}"
49
+ rdoc.rdoc_files.include('README*')
50
+ rdoc.rdoc_files.include('lib/**/*.rb')
51
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
data/lib/sw2at-tw.rb ADDED
@@ -0,0 +1,16 @@
1
+ module Swat
2
+ module TestWorld
3
+ require 'swat/test_world/base'
4
+ require 'swat/test_world/config'
5
+ require 'swat/test_world/generators/install_generator'
6
+
7
+ def self.setup(rspec_config, opts)
8
+ @config = Config.new(rspec_config, opts)
9
+ end
10
+
11
+ def self.config
12
+ @config
13
+ end
14
+
15
+ end
16
+ end
@@ -0,0 +1,68 @@
1
+ module Swat
2
+ module TestWorld
3
+ class Base
4
+ BASE_OPTIONS = {}
5
+ DEFAULT_OPTIONS = {}
6
+ SITUATIONS = {}
7
+
8
+ attr_reader :options
9
+
10
+ def initialize(opts = {})
11
+ @options = init_options(opts)
12
+ init_situation
13
+ end
14
+
15
+ def self.moment
16
+ m = TestWorld.config.options[:moment]
17
+ return unless m
18
+ m.is_a?(Time) ? m : Time.parse(m.to_s)
19
+ end
20
+
21
+ def moment
22
+ self.class.moment
23
+ end
24
+
25
+ alias_method :now, :moment
26
+
27
+ def before_each(example, context)
28
+ #can be implemented in subclass
29
+ end
30
+
31
+ def after_each(example, context)
32
+ #can be implemented in subclass
33
+ end
34
+
35
+ protected
36
+
37
+ def base_options
38
+ self.class::BASE_OPTIONS
39
+ end
40
+
41
+ def default_options
42
+ self.class::DEFAULT_OPTIONS
43
+ end
44
+
45
+ def situations
46
+ self.class::SITUATIONS
47
+ end
48
+
49
+ def init_situation
50
+ raise 'method "init_situation" should be implemented in subclass'
51
+ end
52
+
53
+ private
54
+
55
+ def init_options(opts)
56
+ res = if opts.is_a?(Hash)
57
+ default_options.merge(opts)
58
+ elsif opts.is_a?(Symbol)
59
+ default_options.merge(situations[opts])
60
+ else
61
+ raise 'Invalid TW options passed! should be Hash or Symbol(situation identifier)'
62
+ end
63
+ base_options.merge res
64
+ end
65
+
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,35 @@
1
+ module Swat
2
+ module TestWorld
3
+ require 'swat/test_world/base'
4
+ require 'swat/test_world/rspec_setup'
5
+
6
+ class Config
7
+
8
+ class EmptyTestWorld < TestWorld::Base
9
+ def init_situation; end
10
+ end
11
+
12
+ DEFAULT_OPTIONS = {
13
+ moment: '2014-10-08 12:30:00 UTC',
14
+ klass: EmptyTestWorld,
15
+ }
16
+
17
+ def initialize(rspec_config, opts = {})
18
+ @options = DEFAULT_OPTIONS.merge opts
19
+ rspec_config.extend RspecSetup
20
+ rspec_config.include klass::Helpers if defined? klass::Helpers
21
+ end
22
+
23
+ def options
24
+ @options
25
+ end
26
+
27
+ def klass
28
+ unless options[:klass] < TestWorld::Base
29
+ raise '"klass" should be subclass of TestWorld::Base'
30
+ end
31
+ options[:klass]
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,55 @@
1
+ require 'rails/generators'
2
+
3
+ module Swat
4
+ module TestWorld
5
+ module Generators
6
+ class InstallGenerator < ::Rails::Generators::NamedBase
7
+ source_root File.expand_path('../../templates', __FILE__)
8
+
9
+ desc 'Generates Test World files'
10
+ def install
11
+ create_tw
12
+ if ENV['with_modules']
13
+ create_helpers
14
+ create_methods
15
+ gsub_file main_file, '# You can include your own modules here' do
16
+ <<MODULES
17
+ require 'swat/modules/helpers.rb'
18
+ require 'swat/modules/methods.rb'
19
+ include Methods
20
+ MODULES
21
+ end
22
+ end
23
+ end
24
+
25
+ private
26
+ def create_tw
27
+ template 'test_world_subclass.rb', main_file
28
+ swat_gsub main_file
29
+ end
30
+
31
+ def create_helpers
32
+ file = 'lib/swat/modules/helpers.rb'
33
+ template 'helpers.rb', file
34
+ swat_gsub file
35
+ end
36
+
37
+ def create_methods
38
+ file = 'lib/swat/modules/methods.rb'
39
+ template 'methods.rb', file
40
+ swat_gsub file
41
+ end
42
+
43
+ def swat_gsub(file)
44
+ gsub_file file, 'TwSubclass' do
45
+ name.camelize
46
+ end
47
+ end
48
+
49
+ def main_file
50
+ "lib/swat/#{name}.rb"
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,21 @@
1
+ module Swat
2
+ module TestWorld
3
+ module RspecSetup
4
+
5
+ def init_tw(options = TestWorld.config.klass::BASE_OPTIONS)
6
+ before(:each) do |example|
7
+ Timecop.travel( TestWorld.config.klass.moment ) if TestWorld.config.klass.moment
8
+ TestWorld.config.klass
9
+ @tw = TestWorld.config.klass.new(options)
10
+ @tw.before_each(example, self)
11
+ end
12
+
13
+ after(:each) do |example|
14
+ @tw.after_each(example, self)
15
+ Timecop.return
16
+ end
17
+ end
18
+
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,7 @@
1
+ class TwSubclass
2
+ module Helpers
3
+
4
+ # define methods to be available in test context
5
+
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ class TwSubclass
2
+ module Methods
3
+
4
+ # define methods to be included in @tw instance
5
+
6
+ end
7
+ end
@@ -0,0 +1,25 @@
1
+ require 'swat'
2
+
3
+ # Instance of this class will be available as @tw variable inside of RSpec context
4
+
5
+ class TwSubclass < Swat::TestWorld::Base
6
+ # You can include your own modules here
7
+
8
+ # Define your options and situation below
9
+ BASE_OPTIONS = {}
10
+ DEFAULT_OPTIONS = {}
11
+ SITUATIONS = {}
12
+
13
+ def init_situation
14
+ # implement your situations
15
+ end
16
+
17
+ def before_each(example, context)
18
+ # do something
19
+ end
20
+
21
+ def after_each(example, context)
22
+ # do something
23
+ end
24
+
25
+ end
data/sw2at-tw.gemspec ADDED
@@ -0,0 +1,73 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+ # stub: sw2at-tw 0.0.1 ruby lib
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = "sw2at-tw"
9
+ s.version = "0.0.1"
10
+
11
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib"]
13
+ s.authors = ["Vitaly Tarasenko"]
14
+ s.date = "2015-06-21"
15
+ s.description = " You can define your own strategies for test data generation. And simply create them in RSpec tests. "
16
+ s.email = "vetal.tarasenko@gmail.com"
17
+ s.extra_rdoc_files = [
18
+ "LICENSE.txt",
19
+ "README.rdoc"
20
+ ]
21
+ s.files = [
22
+ ".document",
23
+ "Gemfile",
24
+ "LICENSE.txt",
25
+ "README.rdoc",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "lib/sw2at-tw.rb",
29
+ "lib/swat/test_world/base.rb",
30
+ "lib/swat/test_world/config.rb",
31
+ "lib/swat/test_world/generators/install_generator.rb",
32
+ "lib/swat/test_world/rspec_setup.rb",
33
+ "lib/swat/test_world/templates/helpers.rb",
34
+ "lib/swat/test_world/templates/methods.rb",
35
+ "lib/swat/test_world/templates/test_world_subclass.rb",
36
+ "sw2at-tw.gemspec"
37
+ ]
38
+ s.homepage = "http://github.com/tarvit/sw2at-tw"
39
+ s.licenses = ["MIT"]
40
+ s.rubygems_version = "2.2.2"
41
+ s.summary = "Swat Test World - Helper for test data generation."
42
+
43
+ if s.respond_to? :specification_version then
44
+ s.specification_version = 4
45
+
46
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
47
+ s.add_runtime_dependency(%q<sw2at-capybara>, ["~> 0.0.1"])
48
+ s.add_runtime_dependency(%q<timecop>, ["~> 0.7.1"])
49
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
50
+ s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
51
+ s.add_development_dependency(%q<bundler>, ["~> 1.0"])
52
+ s.add_development_dependency(%q<jeweler>, ["~> 2.0.1"])
53
+ s.add_development_dependency(%q<simplecov>, [">= 0"])
54
+ else
55
+ s.add_dependency(%q<sw2at-capybara>, ["~> 0.0.1"])
56
+ s.add_dependency(%q<timecop>, ["~> 0.7.1"])
57
+ s.add_dependency(%q<shoulda>, [">= 0"])
58
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
59
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
60
+ s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
61
+ s.add_dependency(%q<simplecov>, [">= 0"])
62
+ end
63
+ else
64
+ s.add_dependency(%q<sw2at-capybara>, ["~> 0.0.1"])
65
+ s.add_dependency(%q<timecop>, ["~> 0.7.1"])
66
+ s.add_dependency(%q<shoulda>, [">= 0"])
67
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
68
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
69
+ s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
70
+ s.add_dependency(%q<simplecov>, [">= 0"])
71
+ end
72
+ end
73
+
metadata ADDED
@@ -0,0 +1,159 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sw2at-tw
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Vitaly Tarasenko
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-06-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: sw2at-capybara
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 0.0.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 0.0.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: timecop
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 0.7.1
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 0.7.1
41
+ - !ruby/object:Gem::Dependency
42
+ name: shoulda
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rdoc
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '3.12'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '3.12'
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: '1.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: '1.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: jeweler
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ version: 2.0.1
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ~>
95
+ - !ruby/object:Gem::Version
96
+ version: 2.0.1
97
+ - !ruby/object:Gem::Dependency
98
+ name: simplecov
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: ' You can define your own strategies for test data generation. And simply
112
+ create them in RSpec tests. '
113
+ email: vetal.tarasenko@gmail.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files:
117
+ - LICENSE.txt
118
+ - README.rdoc
119
+ files:
120
+ - .document
121
+ - Gemfile
122
+ - LICENSE.txt
123
+ - README.rdoc
124
+ - Rakefile
125
+ - VERSION
126
+ - lib/sw2at-tw.rb
127
+ - lib/swat/test_world/base.rb
128
+ - lib/swat/test_world/config.rb
129
+ - lib/swat/test_world/generators/install_generator.rb
130
+ - lib/swat/test_world/rspec_setup.rb
131
+ - lib/swat/test_world/templates/helpers.rb
132
+ - lib/swat/test_world/templates/methods.rb
133
+ - lib/swat/test_world/templates/test_world_subclass.rb
134
+ - sw2at-tw.gemspec
135
+ homepage: http://github.com/tarvit/sw2at-tw
136
+ licenses:
137
+ - MIT
138
+ metadata: {}
139
+ post_install_message:
140
+ rdoc_options: []
141
+ require_paths:
142
+ - lib
143
+ required_ruby_version: !ruby/object:Gem::Requirement
144
+ requirements:
145
+ - - '>='
146
+ - !ruby/object:Gem::Version
147
+ version: '0'
148
+ required_rubygems_version: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - '>='
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ requirements: []
154
+ rubyforge_project:
155
+ rubygems_version: 2.2.2
156
+ signing_key:
157
+ specification_version: 4
158
+ summary: Swat Test World - Helper for test data generation.
159
+ test_files: []