rspec-manumit 0.0.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1e93a6f093eab95a5040967fed5dc37969b1a51d
4
+ data.tar.gz: 60aa6a416d0256d8f4363997ca28262cfe393d63
5
+ SHA512:
6
+ metadata.gz: ab85cdff0f8c6d12b684d2920bc8153b42964979ae3b29cda8a7c3e19a7fabc9a277d0e559a75f677d82ea480e74f3d569bca77cd2e7dd887b977be20373a200
7
+ data.tar.gz: f07e1d22f8d2d3dd0698aaac0f62d0cd8a8f8f0fd5d184a48ca47bc5b108f4d74ceb2381708c9f98bd67ecc2660e66b461b6e0d8966f282742c774c8aced8127
@@ -0,0 +1,20 @@
1
+ Copyright 2015 paresharma
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.
@@ -0,0 +1,33 @@
1
+ ### RSpec Manumit
2
+
3
+ A small gem with some utilities to unlease Capybara, RSpec and some other cool
4
+ testing gems from the world of Ruby to the rest of the world.
5
+
6
+ ### Usage
7
+
8
+ Add to Gemfile:
9
+ ```
10
+ gem 'rspec-manumit', git: 'https://github.com/paresharma/rspec-manumit.git'
11
+ ```
12
+
13
+ Then, run `bundle install`.
14
+
15
+ Create `Rakefile` (if not already created) to the project root.
16
+
17
+ Add the following to the `Rakefile` (if it was already not added, like it would have in a rack application):
18
+ ```
19
+ require 'bundler'
20
+ Bundler.require
21
+ ```
22
+
23
+ Then, run `rake rspec:manumit:init`. This will create `.rspec` file and `spec/` directory.
24
+ Spec directory has a sample feature test (spec/features/hompage_spec.rb)
25
+
26
+ Capybara requires a running server to run the tests, the test server endpoint can be coded to `spec/manumit_helper.rb` file, or can be pass as a command line argument.
27
+ ```
28
+ $ APP_HOST=http://localhost:8080 bundle exec rspec
29
+ ```
30
+
31
+ ### License
32
+
33
+ This project rocks and uses MIT-LICENSE.
@@ -0,0 +1,7 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,4 @@
1
+ require 'rspec/manumit/rake'
2
+
3
+ module RSpec::Manumit
4
+ end
@@ -0,0 +1,43 @@
1
+ require 'fileutils'
2
+
3
+ module RSpec::Manumit
4
+ class ProjectInitializer
5
+ attr_reader :destination, :stream, :template_path
6
+
7
+ MANUMIT_HELPER_FILE = 'spec/manumit_helper.rb'
8
+ FEATURE_SPEC_FILE = 'spec/features/homepage_spec.rb'
9
+
10
+ def initialize
11
+ @destination = Dir.getwd
12
+ @stream = $stdout
13
+ @template_path = File.expand_path('../project_initializer', __FILE__)
14
+ end
15
+
16
+ def run
17
+ system('rspec --init')
18
+ copy_template MANUMIT_HELPER_FILE
19
+ copy_template FEATURE_SPEC_FILE
20
+ end
21
+
22
+ private
23
+
24
+ def copy_template(file)
25
+ destination_file = File.join(destination, file)
26
+ return report_exists(file) if File.exist?(destination_file)
27
+
28
+ report_creating(file)
29
+ FileUtils.mkdir_p(File.dirname(destination_file))
30
+ File.open(destination_file, 'w') do |f|
31
+ f.write File.read(File.join(template_path, file))
32
+ end
33
+ end
34
+
35
+ def report_exists(file)
36
+ stream.puts " exist #{file}"
37
+ end
38
+
39
+ def report_creating(file)
40
+ stream.puts " create #{file}"
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,8 @@
1
+ require 'manumit_helper'
2
+
3
+ RSpec.feature 'Home page', js: true do
4
+ scenario 'visit homepage' do
5
+ visit '/'
6
+ expect(page.status_code).to eq(200)
7
+ end
8
+ end
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+
3
+ require 'capybara/rspec'
4
+ require 'capybara/poltergeist'
5
+
6
+ Capybara.default_driver = Capybara.javascript_driver = :poltergeist
7
+
8
+ # Specify app host here
9
+ # Capybara.app_host = 'http://localhost:9966'
10
+ # Or read it from the environment
11
+ Capybara.app_host = ENV['APP_HOST']
12
+ Capybara.run_server = false
13
+
14
+ # Add rest of the configuration below
@@ -0,0 +1,16 @@
1
+ require_relative './project_initializer'
2
+
3
+ module RSpec::Manumit::Rake
4
+ extend ::Rake::DSL
5
+
6
+ def self.define_tasks
7
+ namespace 'rspec:manumit' do
8
+ desc 'initialize rspec and utilities'
9
+ task :init do
10
+ RSpec::Manumit::ProjectInitializer.new.run
11
+ end
12
+ end
13
+ end
14
+ end
15
+
16
+ RSpec::Manumit::Rake.define_tasks
@@ -0,0 +1,5 @@
1
+ module RSpec
2
+ module Manumit
3
+ VERSION = '0.0.1'
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rspec-manumit
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - paresharma
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-10-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: capybara
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 2.5.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 2.5.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: poltergeist
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 1.7.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 1.7.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 3.3.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 3.3.0
55
+ description: Utilities to hook in Capybara, RSpec and some other cool testing gems
56
+ from the world of Ruby to the rest of the world.
57
+ email:
58
+ - paresh.brahm@gmail.com
59
+ executables: []
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - MIT-LICENSE
64
+ - README.md
65
+ - Rakefile
66
+ - lib/rspec/manumit.rb
67
+ - lib/rspec/manumit/project_initializer.rb
68
+ - lib/rspec/manumit/project_initializer/spec/features/homepage_spec.rb
69
+ - lib/rspec/manumit/project_initializer/spec/manumit_helper.rb
70
+ - lib/rspec/manumit/rake.rb
71
+ - lib/rspec/manumit/version.rb
72
+ homepage: https://github.com/paresharma/rspec-manumit
73
+ licenses:
74
+ - MIT
75
+ metadata: {}
76
+ post_install_message:
77
+ rdoc_options: []
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ requirements: []
91
+ rubyforge_project:
92
+ rubygems_version: 2.4.5
93
+ signing_key:
94
+ specification_version: 4
95
+ summary: Utilities to hook in Capybara, RSpec and some other cool testing gems from
96
+ the world of Ruby to the rest of the world.
97
+ test_files: []