minitest-capybara 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in minitest-matchers-capybara.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,83 @@
1
+ # minitest-capybara
2
+
3
+ Capybara matchers support for minitest unit & spec
4
+
5
+ ## Why?
6
+
7
+ Capybara has good support for RSpec. If you want to use it with minitest,
8
+ you can of course write:
9
+
10
+ ```ruby
11
+ assert page.has_content?("Hello")
12
+ ```
13
+
14
+ but:
15
+
16
+ 1. it's kinda ugly
17
+ 2. you don't have meaningfull error messages.
18
+
19
+ With this project minitest gets all the good stuff.
20
+
21
+ ## Usage
22
+
23
+ Add to Gemfile:
24
+
25
+ ```ruby
26
+ # Gemfile
27
+ group :test do
28
+ gem "minitest-matchers-capybara"
29
+ end
30
+ ```
31
+
32
+ Next, I like to create seperate test class for acceptance tests.
33
+ Note, Rails 4.0 will support minitest/spec out of the box, so you would just
34
+ subclass `ActiveSupport::TestCase` instead of `MiniTest::Spec.`
35
+
36
+ ```ruby
37
+ # test/test_helper.rb
38
+ require "capybara/rails"
39
+
40
+ class AcceptanceTest < MiniTest::Spec
41
+ include Capybara::RSpecMatchers
42
+ include Capybara::DSL
43
+ end
44
+ ```
45
+
46
+ Finally, you can use it like this:
47
+
48
+ ```ruby
49
+ # test/acceptance/home_test.rb
50
+ require "test/test_helper"
51
+
52
+ class HomeTest < AcceptanceTest
53
+ it "home test" do
54
+ visit "/"
55
+ must_have_content "Homepage"
56
+ end
57
+ end
58
+ ```
59
+
60
+ ## License
61
+
62
+ (The MIT License)
63
+
64
+ Copyright (c) Wojciech Mach
65
+
66
+ Permission is hereby granted, free of charge, to any person obtaining
67
+ a copy of this software and associated documentation files (the
68
+ 'Software'), to deal in the Software without restriction, including
69
+ without limitation the rights to use, copy, modify, merge, publish,
70
+ distribute, sublicense, and/or sell copies of the Software, and to
71
+ permit persons to whom the Software is furnished to do so, subject to
72
+ the following conditions:
73
+
74
+ The above copyright notice and this permission notice shall be
75
+ included in all copies or substantial portions of the Software.
76
+
77
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
78
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
79
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
80
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
81
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
82
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
83
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << 'lib'
6
+ t.pattern = 'test/**/*_test.rb'
7
+ t.verbose = false
8
+ end
9
+
10
+ task :default => :test
@@ -0,0 +1,17 @@
1
+ require "minitest/matchers"
2
+ require "capybara/dsl"
3
+ require "capybara/rspec/matchers"
4
+
5
+ module Minitest
6
+ module Capybara
7
+ VERSION = "0.1.0"
8
+ end
9
+ end
10
+
11
+ Capybara::RSpecMatchers.module_eval do
12
+ def self.included(base)
13
+ instance_methods.each do |name|
14
+ base.register_matcher name, name
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "minitest-capybara"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "minitest-capybara"
7
+ s.version = Minitest::Capybara::VERSION
8
+ s.authors = ["Wojciech Mach"]
9
+ s.email = ["wojtek@wojtekmach.pl"]
10
+ s.homepage = ""
11
+ s.summary = %q{Capybara matchers support for minitest unit and spec}
12
+ s.description = s.summary
13
+
14
+ s.rubyforge_project = "minitest-capybara"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ s.add_dependency "minitest-matchers", ">= 1.2"
22
+ s.add_dependency "capybara", ">= 1.0"
23
+ end
@@ -0,0 +1,29 @@
1
+ require "rack"
2
+ require "minitest/matchers"
3
+ require "minitest-matchers-capybara"
4
+ require "minitest/autorun"
5
+
6
+ describe "test" do
7
+ include Capybara::RSpecMatchers
8
+
9
+ it "supports have_selector" do
10
+ subject = "<h1>hello <a>asd</a></h1>"
11
+ args = [:css, "h1 a", {:text => "asd"}]
12
+
13
+ assert_have_selector subject, *args
14
+ subject.must_have_selector *args
15
+ end
16
+ end
17
+
18
+ Capybara.app = lambda { |env| [200, {}, "<p><h1>foo</h1></p>"] }
19
+
20
+ describe "app" do
21
+ include Capybara::RSpecMatchers
22
+ include Capybara::DSL
23
+
24
+ it "works" do
25
+ visit "/"
26
+ assert_have_content(page, "foo").must_equal true
27
+ proc { refute_have_content page, "foo" }.must_raise MiniTest::Assertion
28
+ end
29
+ end
metadata ADDED
@@ -0,0 +1,76 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: minitest-capybara
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Wojciech Mach
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-02-09 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: minitest-matchers
16
+ requirement: &70327771207080 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '1.2'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70327771207080
25
+ - !ruby/object:Gem::Dependency
26
+ name: capybara
27
+ requirement: &70327771206520 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '1.0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70327771206520
36
+ description: Capybara matchers support for minitest unit and spec
37
+ email:
38
+ - wojtek@wojtekmach.pl
39
+ executables: []
40
+ extensions: []
41
+ extra_rdoc_files: []
42
+ files:
43
+ - .gitignore
44
+ - Gemfile
45
+ - README.md
46
+ - Rakefile
47
+ - lib/minitest-capybara.rb
48
+ - minitest-capybara.gemspec
49
+ - test/minitest-capybara_test.rb
50
+ homepage: ''
51
+ licenses: []
52
+ post_install_message:
53
+ rdoc_options: []
54
+ require_paths:
55
+ - lib
56
+ required_ruby_version: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ required_rubygems_version: !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ! '>='
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ requirements: []
69
+ rubyforge_project: minitest-capybara
70
+ rubygems_version: 1.8.11
71
+ signing_key:
72
+ specification_version: 3
73
+ summary: Capybara matchers support for minitest unit and spec
74
+ test_files:
75
+ - test/minitest-capybara_test.rb
76
+ has_rdoc: