rspec_gem 0.0.2 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # RspecGem
2
2
 
3
- Invoke the tests rspec from gems in application rails.}
3
+ Invoke the tests rspec from gems in application rails.
4
4
 
5
5
  ## Installation
6
6
 
@@ -18,6 +18,27 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
- Run the all tests from directory "spec"
21
+ For example, you have rails application of name "rails_app" and gem of name "testing_gem" with the files for testing.
22
22
 
23
- rake rspec_gem:rspec[spec/.]
23
+ Then you should include
24
+
25
+ require "rspec_gem"
26
+ RspecGem.new(File.expand_path("../..", __FILE__), "testing_gem")
27
+
28
+ into file ../testing_gem/lib/testing_gem.rb in your gem.
29
+
30
+ You can use path into rails environment through use method (Usage resource of application, like models)
31
+
32
+ RspecGem.path_rails_environment
33
+
34
+ Finally in your application rails_app invoke command (all tests from directory "spec" from gem testing_gem)
35
+
36
+ rake testing_gem:rspec spec
37
+
38
+ with color
39
+
40
+ rake testing_gem:rspec "spec --color"
41
+
42
+ more precision
43
+
44
+ rake testing_gem:rspec spec/testing_gem_spec.rb
@@ -1,3 +1,3 @@
1
1
  class RspecGem
2
- VERSION = "0.0.2"
2
+ VERSION = "0.1.0"
3
3
  end
data/lib/rspec_gem.rb CHANGED
@@ -3,9 +3,12 @@ require_relative "rspec_gem/version"
3
3
 
4
4
  class RspecGem
5
5
 
6
- def initialize(path, name)
6
+ # create task for your gem
7
+ # path - path into directory of your gem
8
+ # name_of_gem - name of your gem
9
+ def initialize(path, name_of_gem)
7
10
  @@path = path
8
- @@name_of_gem = name
11
+ @@name_of_gem = name_of_gem
9
12
  load File.expand_path("../tasks/rspec_gem.rake", __FILE__) if defined?(Rake)
10
13
  end
11
14
 
@@ -19,6 +22,7 @@ class RspecGem
19
22
  end
20
23
 
21
24
  def path_rails_environment
25
+ return File.expand_path("config/environment", Rails.root) if defined?(Rails)
22
26
  File.expand_path("config/environment", ENV["PWD"])
23
27
  end
24
28
  end
@@ -1,11 +1,12 @@
1
1
  # encoding: utf-8
2
-
3
2
  require "logger"
4
-
5
3
  namespace RspecGem.name_of_gem do
6
- desc "testing gem #{RspecGem.name_of_gem}"
7
- task :rspec, :arg do |key, element|
8
- log = Logger.new(STDOUT)
9
- log.info `rspec #{File.expand_path("../../" + element[:arg], RspecGem.path)}`
4
+ desc "testing gem #{RspecGem.name_of_gem.clone}"
5
+ task :rspec do
6
+ arg = ARGV.last
7
+ task arg.to_sym do ; end
8
+ command = "rspec #{File.expand_path(arg, RspecGem.path)}".clone
9
+ Logger.new(STDOUT).info command
10
+ system(command)
10
11
  end
11
12
  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-09-19"
10
+ gem.date = "2012-09-22"
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,6 +19,5 @@ Gem::Specification.new do |gem|
19
19
  gem.require_paths = ["lib"]
20
20
 
21
21
  gem.add_dependency "rspec"
22
- gem.add_dependency "logger", ">= 1.2.8"
23
22
  gem.add_dependency "rake"
24
23
  end
@@ -21,5 +21,6 @@ group :assets do
21
21
  end
22
22
 
23
23
  gem 'jquery-rails'
24
-
25
24
  gem 'rspec_gem_spec', :path => File.expand_path("../../rspec_gem_spec", __FILE__)
25
+ gem 'rspec'
26
+ gem "rspec-rails"
@@ -0,0 +1,2 @@
1
+ class RspecGemModel < ActiveRecord::Base
2
+ end
@@ -0,0 +1,9 @@
1
+ class CreateRspecGemModels < ActiveRecord::Migration
2
+ def change
3
+ create_table :rspec_gem_models do |t|
4
+ t.string :name
5
+
6
+ t.timestamps
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,22 @@
1
+ # encoding: UTF-8
2
+ # This file is auto-generated from the current state of the database. Instead
3
+ # of editing this file, please use the migrations feature of Active Record to
4
+ # incrementally modify your database, and then regenerate this schema definition.
5
+ #
6
+ # Note that this schema.rb definition is the authoritative source for your
7
+ # database schema. If you need to create the application database on another
8
+ # system, you should be using db:schema:load, not running all the migrations
9
+ # from scratch. The latter is a flawed and unsustainable approach (the more migrations
10
+ # you'll amass, the slower it'll run and the greater likelihood for issues).
11
+ #
12
+ # It's strongly recommended to check this file into your version control system.
13
+
14
+ ActiveRecord::Schema.define(:version => 20120922085657) do
15
+
16
+ create_table "rspec_gem_models", :force => true do |t|
17
+ t.string "name"
18
+ t.datetime "created_at", :null => false
19
+ t.datetime "updated_at", :null => false
20
+ end
21
+
22
+ end
Binary file
@@ -0,0 +1,12 @@
1
+  (0.8ms) begin transaction
2
+  (0.2ms) SAVEPOINT active_record_1
3
+ SQL (13.1ms) INSERT INTO "rspec_gem_models" ("created_at", "name", "updated_at") VALUES (?, ?, ?) [["created_at", Sat, 22 Sep 2012 09:17:48 UTC +00:00], ["name", "example"], ["updated_at", Sat, 22 Sep 2012 09:17:48 UTC +00:00]]
4
+  (0.2ms) RELEASE SAVEPOINT active_record_1
5
+  (0.2ms) SELECT COUNT(*) FROM "rspec_gem_models" 
6
+  (0.3ms) rollback transaction
7
+  (0.8ms) begin transaction
8
+  (0.2ms) SAVEPOINT active_record_1
9
+ SQL (57.5ms) INSERT INTO "rspec_gem_models" ("created_at", "name", "updated_at") VALUES (?, ?, ?) [["created_at", Sat, 22 Sep 2012 09:46:02 UTC +00:00], ["name", "example"], ["updated_at", Sat, 22 Sep 2012 09:46:02 UTC +00:00]]
10
+  (0.2ms) RELEASE SAVEPOINT active_record_1
11
+  (0.2ms) SELECT COUNT(*) FROM "rspec_gem_models" 
12
+  (0.4ms) rollback transaction
@@ -0,0 +1,38 @@
1
+ # This file is copied to spec/ when you run 'rails generate rspec:install'
2
+ ENV["RAILS_ENV"] ||= 'test'
3
+ require File.expand_path("../../config/environment", __FILE__)
4
+ require 'rspec/rails'
5
+ require 'rspec/autorun'
6
+
7
+ # Requires supporting ruby files with custom matchers and macros, etc,
8
+ # in spec/support/ and its subdirectories.
9
+ Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
10
+
11
+ RSpec.configure do |config|
12
+ # ## Mock Framework
13
+ #
14
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
15
+ #
16
+ # config.mock_with :mocha
17
+ # config.mock_with :flexmock
18
+ # config.mock_with :rr
19
+
20
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
21
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
22
+
23
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
24
+ # examples within a transaction, remove the following line or assign false
25
+ # instead of true.
26
+ config.use_transactional_fixtures = true
27
+
28
+ # If true, the base class of anonymous controllers will be inferred
29
+ # automatically. This will be the default behavior in future versions of
30
+ # rspec-rails.
31
+ config.infer_base_class_for_anonymous_controllers = false
32
+
33
+ # Run specs in random order to surface order dependencies. If you find an
34
+ # order dependency and want to debug it, you can fix the order by providing
35
+ # the seed, which is printed after each run.
36
+ # --seed 1234
37
+ config.order = "random"
38
+ end
@@ -1,7 +1,8 @@
1
1
  require_relative "rspec_gem_spec/version"
2
2
 
3
3
  require_relative "../../../lib/rspec_gem.rb"
4
- RspecGem.new(__FILE__, "rspec_gem_spec")
4
+
5
+ RspecGem.new(File.expand_path("../..", __FILE__), "rspec_gem_spec")
5
6
 
6
7
  module RspecGemSpec
7
8
  end
@@ -17,4 +17,6 @@ Gem::Specification.new do |gem|
17
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
18
  gem.require_paths = ["lib"]
19
19
 
20
+ gem.add_dependency "rspec_gem"
21
+
20
22
  end
@@ -0,0 +1,8 @@
1
+ require 'spec_helper'
2
+
3
+ describe RspecGemModel do
4
+ it "should properly add new record into model" do
5
+ RspecGemModel.create(name: "example")
6
+ RspecGemModel.count.should eql(1)
7
+ end
8
+ end
@@ -0,0 +1,38 @@
1
+ # This file is copied to spec/ when you run 'rails generate rspec:install'
2
+ ENV["RAILS_ENV"] ||= 'test'
3
+ require RspecGem.path_rails_environment
4
+ require 'rspec/rails'
5
+ require 'rspec/autorun'
6
+
7
+ # Requires supporting ruby files with custom matchers and macros, etc,
8
+ # in spec/support/ and its subdirectories.
9
+ Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
10
+
11
+ RSpec.configure do |config|
12
+ # ## Mock Framework
13
+ #
14
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
15
+ #
16
+ # config.mock_with :mocha
17
+ # config.mock_with :flexmock
18
+ # config.mock_with :rr
19
+
20
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
21
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
22
+
23
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
24
+ # examples within a transaction, remove the following line or assign false
25
+ # instead of true.
26
+ config.use_transactional_fixtures = true
27
+
28
+ # If true, the base class of anonymous controllers will be inferred
29
+ # automatically. This will be the default behavior in future versions of
30
+ # rspec-rails.
31
+ config.infer_base_class_for_anonymous_controllers = false
32
+
33
+ # Run specs in random order to surface order dependencies. If you find an
34
+ # order dependency and want to debug it, you can fix the order by providing
35
+ # the seed, which is printed after each run.
36
+ # --seed 1234
37
+ config.order = "random"
38
+ end
@@ -1,11 +1,8 @@
1
1
  # encoding: utf-8
2
-
2
+ # go into directory rails_app
3
+ # invoke bundle
4
+ # finally invoke command "rake rspec_gem_spec:rspec spec"
3
5
  require 'rspec_gem'
4
6
 
5
7
  RSpec.configuration.color = true
6
8
 
7
- describe RspecGem do
8
- it "rspec_gem" do
9
- puts "rspec_gem"
10
- end
11
- 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.0.2
4
+ version: 0.1.0
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-09-19 00:00:00.000000000 Z
12
+ date: 2012-09-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -27,22 +27,6 @@ dependencies:
27
27
  - - ! '>='
28
28
  - !ruby/object:Gem::Version
29
29
  version: '0'
30
- - !ruby/object:Gem::Dependency
31
- name: logger
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ! '>='
36
- - !ruby/object:Gem::Version
37
- version: 1.2.8
38
- type: :runtime
39
- prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
45
- version: 1.2.8
46
30
  - !ruby/object:Gem::Dependency
47
31
  name: rake
48
32
  requirement: !ruby/object:Gem::Requirement
@@ -82,8 +66,8 @@ files:
82
66
  - spec/rails_app/app/assets/stylesheets/application.css
83
67
  - spec/rails_app/app/controllers/application_controller.rb
84
68
  - spec/rails_app/app/helpers/application_helper.rb
85
- - spec/rails_app/app/mailers/.gitkeep
86
69
  - spec/rails_app/app/models/.gitkeep
70
+ - spec/rails_app/app/models/rspec_gem_model.rb
87
71
  - spec/rails_app/app/views/layouts/application.html.erb
88
72
  - spec/rails_app/config.ru
89
73
  - spec/rails_app/config/application.rb
@@ -101,14 +85,21 @@ files:
101
85
  - spec/rails_app/config/initializers/wrap_parameters.rb
102
86
  - spec/rails_app/config/locales/en.yml
103
87
  - spec/rails_app/config/routes.rb
88
+ - spec/rails_app/db/development.sqlite3
89
+ - spec/rails_app/db/migrate/20120922085657_create_rspec_gem_models.rb
90
+ - spec/rails_app/db/schema.rb
104
91
  - spec/rails_app/db/seeds.rb
92
+ - spec/rails_app/db/test.sqlite3
93
+ - spec/rails_app/log/test.log
94
+ - spec/rails_app/spec/spec_helper.rb
105
95
  - spec/rspec_gem_spec.rb
106
96
  - spec/rspec_gem_spec/Gemfile
107
97
  - spec/rspec_gem_spec/Rakefile
108
98
  - spec/rspec_gem_spec/lib/rspec_gem_spec.rb
109
99
  - spec/rspec_gem_spec/lib/rspec_gem_spec/version.rb
110
100
  - spec/rspec_gem_spec/rspec_gem_spec.gemspec
111
- - spec/rspec_gem_spec/spec/rspec_gem_spec_spec.rb
101
+ - spec/rspec_gem_spec/spec/models/rspec_gem_model_spec.rb
102
+ - spec/rspec_gem_spec/spec/spec_helper.rb
112
103
  homepage: https://github.com/raglub/rspec_gem
113
104
  licenses: []
114
105
  post_install_message:
@@ -141,8 +132,8 @@ test_files:
141
132
  - spec/rails_app/app/assets/stylesheets/application.css
142
133
  - spec/rails_app/app/controllers/application_controller.rb
143
134
  - spec/rails_app/app/helpers/application_helper.rb
144
- - spec/rails_app/app/mailers/.gitkeep
145
135
  - spec/rails_app/app/models/.gitkeep
136
+ - spec/rails_app/app/models/rspec_gem_model.rb
146
137
  - spec/rails_app/app/views/layouts/application.html.erb
147
138
  - spec/rails_app/config.ru
148
139
  - spec/rails_app/config/application.rb
@@ -160,11 +151,18 @@ test_files:
160
151
  - spec/rails_app/config/initializers/wrap_parameters.rb
161
152
  - spec/rails_app/config/locales/en.yml
162
153
  - spec/rails_app/config/routes.rb
154
+ - spec/rails_app/db/development.sqlite3
155
+ - spec/rails_app/db/migrate/20120922085657_create_rspec_gem_models.rb
156
+ - spec/rails_app/db/schema.rb
163
157
  - spec/rails_app/db/seeds.rb
158
+ - spec/rails_app/db/test.sqlite3
159
+ - spec/rails_app/log/test.log
160
+ - spec/rails_app/spec/spec_helper.rb
164
161
  - spec/rspec_gem_spec.rb
165
162
  - spec/rspec_gem_spec/Gemfile
166
163
  - spec/rspec_gem_spec/Rakefile
167
164
  - spec/rspec_gem_spec/lib/rspec_gem_spec.rb
168
165
  - spec/rspec_gem_spec/lib/rspec_gem_spec/version.rb
169
166
  - spec/rspec_gem_spec/rspec_gem_spec.gemspec
170
- - spec/rspec_gem_spec/spec/rspec_gem_spec_spec.rb
167
+ - spec/rspec_gem_spec/spec/models/rspec_gem_model_spec.rb
168
+ - spec/rspec_gem_spec/spec/spec_helper.rb
File without changes