rspec_gem 0.2.1 → 0.2.3
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/README.md +11 -7
- data/bin/rspec_gem +0 -0
- data/lib/rspec_gem/version.rb +1 -1
- data/lib/rspec_gem.rb +47 -0
- data/rspec_gem.gemspec +4 -3
- metadata +20 -4
data/README.md
CHANGED
|
@@ -22,14 +22,18 @@ For example, you have rails application of name "rails_app" and gem of name "tes
|
|
|
22
22
|
|
|
23
23
|
### 0.2.x
|
|
24
24
|
|
|
25
|
-
You can
|
|
25
|
+
You can require rails rails environment by use method (include resource of application, like models)
|
|
26
26
|
|
|
27
|
-
RspecGem.
|
|
27
|
+
RspecGem.require_rails_environment
|
|
28
|
+
|
|
29
|
+
or faster environment
|
|
30
|
+
|
|
31
|
+
RspecGem.require_model_environment
|
|
28
32
|
|
|
29
|
-
which you
|
|
33
|
+
which you add into file spec_helper.rb which is included in your gem, for example:
|
|
30
34
|
|
|
31
35
|
require "rspec_gem"
|
|
32
|
-
|
|
36
|
+
RspecGem.require_rails_environment
|
|
33
37
|
|
|
34
38
|
Finally in your application rails_app invoke command (all tests from directory "spec" from gem testing_gem)
|
|
35
39
|
|
|
@@ -37,9 +41,9 @@ Finally in your application rails_app invoke command (all tests from directory "
|
|
|
37
41
|
|
|
38
42
|
with color
|
|
39
43
|
|
|
40
|
-
$ rspec_gem testing_gem "spec --color"
|
|
44
|
+
$ bundle exec rspec_gem testing_gem "spec --color"
|
|
41
45
|
|
|
42
|
-
more
|
|
46
|
+
more precisely
|
|
43
47
|
|
|
44
48
|
$ rspec_gem testing_gem spec/testing_gem_spec.rb
|
|
45
49
|
|
|
@@ -64,6 +68,6 @@ with color
|
|
|
64
68
|
|
|
65
69
|
$ RAILS_ENV=test rake testing_gem:rspec "spec --color"
|
|
66
70
|
|
|
67
|
-
more
|
|
71
|
+
more precisely
|
|
68
72
|
|
|
69
73
|
$ RAILS_ENV=test rake testing_gem:rspec spec/testing_gem_spec.rb
|
data/bin/rspec_gem
CHANGED
|
File without changes
|
data/lib/rspec_gem/version.rb
CHANGED
data/lib/rspec_gem.rb
CHANGED
|
@@ -25,6 +25,53 @@ class RspecGem
|
|
|
25
25
|
return File.expand_path("config/environment", Rails.root) if defined?(Rails)
|
|
26
26
|
File.expand_path("config/environment", ENV["PWD"])
|
|
27
27
|
end
|
|
28
|
+
|
|
29
|
+
# require full rails environment
|
|
30
|
+
def require_rails_environment
|
|
31
|
+
require File.expand_path("config/environment", ENV["PWD"])
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# require simply environment without active records
|
|
35
|
+
def require_unit_environment
|
|
36
|
+
require "active_support"
|
|
37
|
+
require "active_support/dependencies"
|
|
38
|
+
%w{ extensions helpers mailers models presenters }.each do |dir|
|
|
39
|
+
ActiveSupport::Dependencies.autoload_paths <<
|
|
40
|
+
File.expand_path("app/#{dir}", ENV["PWD"])
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# require active record with database
|
|
45
|
+
def require_model_environment
|
|
46
|
+
require_unit_environment
|
|
47
|
+
ENV["RAILS_ENV"] ||= "test"
|
|
48
|
+
|
|
49
|
+
# ActiveRecord
|
|
50
|
+
require "yaml"
|
|
51
|
+
require "active_record"
|
|
52
|
+
ActiveRecord::Base.establish_connection(
|
|
53
|
+
YAML.load(File.read(ENV["PWD"] + "/config/database.yml"))["test"]
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
# DatabaseCleaner
|
|
57
|
+
require "database_cleaner"
|
|
58
|
+
RSpec.configure do |config|
|
|
59
|
+
config.before(:suite) do
|
|
60
|
+
DatabaseCleaner.strategy = :transaction
|
|
61
|
+
DatabaseCleaner.clean_with(:truncation)
|
|
62
|
+
end
|
|
63
|
+
config.before(:each) do
|
|
64
|
+
DatabaseCleaner.start
|
|
65
|
+
end
|
|
66
|
+
config.after(:each) do
|
|
67
|
+
DatabaseCleaner.clean
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# configurations into database
|
|
72
|
+
ActiveRecord::Base.send(:configurations=, YAML::load(ERB.new(IO.read(ENV["PWD"] + "/config/database.yml")).result))
|
|
73
|
+
end
|
|
74
|
+
|
|
28
75
|
end
|
|
29
76
|
|
|
30
77
|
end
|
data/rspec_gem.gemspec
CHANGED
|
@@ -7,7 +7,7 @@ Gem::Specification.new do |gem|
|
|
|
7
7
|
gem.name = "rspec_gem"
|
|
8
8
|
gem.version = RspecGem::VERSION
|
|
9
9
|
gem.platform = Gem::Platform::RUBY
|
|
10
|
-
gem.date = "2012-10-
|
|
10
|
+
gem.date = "2012-10-05"
|
|
11
11
|
gem.authors = ["michal szyma"]
|
|
12
12
|
gem.email = ["raglub.ruby@gmail.com"]
|
|
13
13
|
gem.description = %q{Invoke the tests rspec from gems in application rails.}
|
|
@@ -19,7 +19,8 @@ Gem::Specification.new do |gem|
|
|
|
19
19
|
gem.test_files = gem.files.grep(%r{^(spec)/})
|
|
20
20
|
gem.require_paths = ["lib"]
|
|
21
21
|
|
|
22
|
-
gem.add_dependency "rspec"
|
|
22
|
+
gem.add_dependency "rspec", ">= 2.0.0"
|
|
23
23
|
gem.add_dependency "rake"
|
|
24
|
-
gem.add_dependency "logger"
|
|
24
|
+
gem.add_dependency "logger", ">= 1.2.8"
|
|
25
|
+
gem.add_dependency "database_cleaner"
|
|
25
26
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rspec_gem
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.3
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2012-10-
|
|
12
|
+
date: 2012-10-05 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: rspec
|
|
@@ -18,7 +18,7 @@ dependencies:
|
|
|
18
18
|
requirements:
|
|
19
19
|
- - ! '>='
|
|
20
20
|
- !ruby/object:Gem::Version
|
|
21
|
-
version:
|
|
21
|
+
version: 2.0.0
|
|
22
22
|
type: :runtime
|
|
23
23
|
prerelease: false
|
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -26,7 +26,7 @@ dependencies:
|
|
|
26
26
|
requirements:
|
|
27
27
|
- - ! '>='
|
|
28
28
|
- !ruby/object:Gem::Version
|
|
29
|
-
version:
|
|
29
|
+
version: 2.0.0
|
|
30
30
|
- !ruby/object:Gem::Dependency
|
|
31
31
|
name: rake
|
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -45,6 +45,22 @@ dependencies:
|
|
|
45
45
|
version: '0'
|
|
46
46
|
- !ruby/object:Gem::Dependency
|
|
47
47
|
name: logger
|
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
|
49
|
+
none: false
|
|
50
|
+
requirements:
|
|
51
|
+
- - ! '>='
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: 1.2.8
|
|
54
|
+
type: :runtime
|
|
55
|
+
prerelease: false
|
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
57
|
+
none: false
|
|
58
|
+
requirements:
|
|
59
|
+
- - ! '>='
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: 1.2.8
|
|
62
|
+
- !ruby/object:Gem::Dependency
|
|
63
|
+
name: database_cleaner
|
|
48
64
|
requirement: !ruby/object:Gem::Requirement
|
|
49
65
|
none: false
|
|
50
66
|
requirements:
|