minitest-capybara 0.7.2 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 86376b532c4569b87464a8ceb3591ad7468d2216
4
- data.tar.gz: e4f06509913e792d39154d661436d208cf6bddfe
3
+ metadata.gz: f3cad186559582c6b6c245b54214ee2bce8fe6be
4
+ data.tar.gz: 02bb027bc471f6c83f730f8f7211715788068081
5
5
  SHA512:
6
- metadata.gz: 9950cb467f45b29d1d8a26a77ae2d7eb465036085712c1b77f6c9da2a63bea530dc6571bb74f46e4e3464a97d25fc517369f2c3d61e99fe04cec0ce570fc7bd7
7
- data.tar.gz: cbc086315dc445afc1e8ba7929b7772c521de79cb17ee4f02c981ba9d43862031964b32424f05ac1bbcc4b545308a71fb64e56841137ab29ab12073b49a0202b
6
+ metadata.gz: e41c570259fe17200c68cd51fa2823d6f73699d98a5e9a45380338c3c1498fbf7b74fc07c5ddd52ed49123cc0457468182742b5d30481fc05733fd644f3a3508
7
+ data.tar.gz: 221eb2b615a90567e5ce4080daeaea6d393edc7a4f7a048589ace9aa1523fb1c0ab695fa3054dd17ad8577d1e29a2d2eb9f8661c0418d9b22b6fc1b243c4c819
@@ -1,21 +1,21 @@
1
1
  language: ruby
2
2
  cache: bundler
3
3
  rvm:
4
- # - 1.9.3
5
- # - 2.0.0
6
- # - 2.1.0
7
- # - 2.1.1
8
- - 2.1.2
9
- # - jruby
10
- # - rbx-2
4
+ - 2.1
5
+ - 2.2
6
+ - 2.3.0
7
+
8
+ before_install:
9
+ - gem update bundler
10
+
11
11
  deploy:
12
12
  provider: rubygems
13
13
  api_key:
14
14
  secure: beHIrfhi+kpvA67zbiMXx5n2qAUaNUz+y3RO3yB19jIiTm4Zol8DRJH9jKO6YpIwLlolTrGVQsmZHqmmXRghv3qZXeYwLdp0mvyMIYc5w10OiRwDzlS1DFogevDszRDpypP7J48oFn2llRt1mw9HyLE83GFQcTEvxUJ+ENLA3tY=
15
15
  gem: minitest-capybara
16
16
  on:
17
- repo: wojtekmach/minitest-capybara
18
- condition: ./script/unreleased
17
+ tags: true
18
+
19
19
  before_deploy:
20
20
  - echo Deploying...
21
21
 
@@ -1,3 +1,12 @@
1
+ ## HEAD
2
+
3
+ ## v0.8.0
4
+
5
+ * Remove depracation for Minitest::Capybara::Assertions.
6
+ * Better error messages for `assert_content/refute_content`.
7
+ * Remove feature DSL.
8
+ * Add Minitest::Capybara::Test and Minitest::Capybara::Spec classes.
9
+
1
10
  ## v0.7.2
2
11
 
3
12
  * Update exception message to Capybara::Assertions. - @apotonick
@@ -1,4 +1,4 @@
1
- Copyright (c) 2013 Wojciech Mach
1
+ Copyright (c) 2013-2015 Wojciech Mach
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -23,90 +23,50 @@ With this project minitest gets all the good stuff.
23
23
 
24
24
  ## Rails integration
25
25
 
26
- Check out [minitest-rails-capybara](https://github.com/blowmage/minitest-rails-capybara)
26
+ `minitest-capybara` (and `capybara`) works with Rails out of the box, remember to require `capybara/rails`.
27
27
 
28
- ## Usage
29
-
30
- See example app: https://github.com/wojtekmach/minitest-capybara-example
31
-
32
- Add to Gemfile:
33
-
34
- ```ruby
35
- # Gemfile
36
- group :test do
37
- gem "minitest-capybara"
38
- end
39
- ```
40
-
41
- ```ruby
42
- # features/my_feature.rb
43
- require 'test_helper'
28
+ See example Rails app: <https://github.com/wojtekmach/minitest-capybara-example>.
44
29
 
45
- feature "My Super Feature" do
46
- given(:lion) { ... }
30
+ For more features check out: [minitest-rails-capybara](https://github.com/blowmage/minitest-rails-capybara).
47
31
 
48
- background do
49
- visit "/feature"
50
- end
51
-
52
- scenario "this awesome feature" do
53
- page.must_have_content("Awesome Feature")
54
- end
55
- end
56
- ```
32
+ ## Usage
57
33
 
58
- Or if you prefer to create seperate test class for acceptance tests.
34
+ With minitest/test:
59
35
 
60
36
  ```ruby
61
- # test/test_helper.rb
62
- require "capybara/rails"
37
+ class HomeTest < Minitest::Capybara::Test
38
+ def test_home
39
+ visit "/"
63
40
 
64
- # for just minitest/unit
65
- class AcceptanceTest < Minitest::Test
66
- include Capybara::DSL
67
- include Capybara::Assertions
41
+ assert_content "Homepage"
68
42
 
69
- def teardown
70
- Capybara.reset_session!
71
- Capybara.use_default_driver
72
- end
73
- end
43
+ within ".login" do
44
+ refute_content "Signed in as"
45
+ end
74
46
 
75
- # for minitest/spec
76
- class AcceptanceSpec < Minitest::Spec
77
- include Capybara::DSL
78
- include Capybara::Assertions
47
+ assert_link "Sign in"
48
+ assert_link find(".login"), "Sign in"
79
49
 
80
- def teardown
81
- Capybara.reset_session!
82
- Capybara.use_default_driver
50
+ assert_selector 'li:first', text: "Item 1"
83
51
  end
84
52
  end
85
53
  ```
86
54
 
87
- and you can use it like this:
55
+ With minitest/spec:
88
56
 
89
57
  ```ruby
90
- # test/acceptance/home_test.rb
91
- require "test_helper"
92
-
93
- class HomeTest < AcceptanceSpec
94
- it "home test" do
58
+ class HomeSpec < Minitest::Capybara::Spec
59
+ it "works" do
95
60
  visit "/"
96
61
 
97
- assert_content "Homepage"
98
62
  page.must_have_content "Homepage"
99
63
 
100
64
  within ".login" do
101
- refute_content "Signed in as"
102
65
  page.wont_have_content "Signed in as"
103
66
  end
104
67
 
105
- assert_link "Sign in"
106
- assert_link find(".login"), "Sign in"
107
68
  find(".login").must_have_link("Sign in")
108
69
 
109
- assert_selector 'li:first', text: "Item 1"
110
70
  page.must_have_selector 'li:first', text: "Item 1"
111
71
  end
112
72
  end
@@ -121,7 +81,7 @@ Switching drivers is easy with [minitest-metadata]:
121
81
  ```ruby
122
82
  require 'minitest-metadata'
123
83
 
124
- class AcceptanceSpec
84
+ class AcceptanceSpec < Minitest::Capybara::Spec
125
85
  before do
126
86
  if metadata[:js]
127
87
  Capybara.current_driver = Capybara.javascript_driver
@@ -131,7 +91,7 @@ class AcceptanceSpec
131
91
  end
132
92
  end
133
93
 
134
- class HomeTest < AcceptanceSpec
94
+ class HomeSpec < AcceptanceSpec
135
95
  it "home with ajax", js: true do
136
96
  visit "/"
137
97
  page.must_have_content "AJAX enabled..."
@@ -141,25 +101,4 @@ end
141
101
 
142
102
  ## License
143
103
 
144
- (The MIT License)
145
-
146
- Copyright (c) Wojciech Mach
147
-
148
- Permission is hereby granted, free of charge, to any person obtaining
149
- a copy of this software and associated documentation files (the
150
- 'Software'), to deal in the Software without restriction, including
151
- without limitation the rights to use, copy, modify, merge, publish,
152
- distribute, sublicense, and/or sell copies of the Software, and to
153
- permit persons to whom the Software is furnished to do so, subject to
154
- the following conditions:
155
-
156
- The above copyright notice and this permission notice shall be
157
- included in all copies or substantial portions of the Software.
158
-
159
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
160
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
161
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
162
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
163
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
164
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
165
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
104
+ minitest-capybara is released under the [MIT License](LICENSE.txt).
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.2
1
+ 0.8.0
@@ -6,13 +6,13 @@ module Capybara
6
6
 
7
7
  def assert_text(*args)
8
8
  node, *args = prepare_args(args)
9
- assert node.has_text?(*args), message { "Expected to include #{args.first.inspect}" }
9
+ assert node.has_text?(*args), message { "Expected to find text #{args.first.inspect} in #{node.text.inspect}" }
10
10
  end
11
11
  alias_method :assert_content, :assert_text
12
12
 
13
13
  def refute_text(*args)
14
14
  node, *args = prepare_args(args)
15
- assert node.has_no_text?(*args), message { "Expected not to include #{args.first.inspect}" }
15
+ assert node.has_no_text?(*args), message { "Expected not to find text #{args.first.inspect} in #{node.text.inspect}" }
16
16
  end
17
17
  alias_method :assert_no_text, :refute_text
18
18
  alias_method :refute_content, :refute_text
@@ -1,5 +1,5 @@
1
- require "minitest/capybara/version"
2
1
  require "capybara"
2
+ require "minitest/capybara/version"
3
3
 
4
4
  module Minitest
5
5
  module Capybara
@@ -22,15 +22,25 @@ end
22
22
  require "capybara/assertions"
23
23
  require "capybara/expectations"
24
24
 
25
- # :stopdoc:
26
25
  module Minitest
27
26
  module Capybara
28
- def self.const_missing const
29
- if :Assertions == const
30
- warn "Minitest::Capybara::Assertions is deprecated. Please use Capybara::Assertions instead."
31
- ::Capybara::Assertions
32
- else
33
- super const
27
+ class Test < Minitest::Test
28
+ include ::Capybara::DSL
29
+ include ::Capybara::Assertions
30
+
31
+ def teardown
32
+ ::Capybara.reset_session!
33
+ ::Capybara.use_default_driver
34
+ end
35
+ end
36
+
37
+ class Spec < Minitest::Spec
38
+ include ::Capybara::DSL
39
+ include ::Capybara::Assertions
40
+
41
+ def teardown
42
+ ::Capybara.reset_session!
43
+ ::Capybara.use_default_driver
34
44
  end
35
45
  end
36
46
  end
@@ -1,24 +1,27 @@
1
- require 'test_helper'
2
-
3
- Capybara.app = lambda { |env| [200, {}, "<div><h1>foo</h1><a href='/'>bar</a></div>"] }
1
+ require "test_helper"
4
2
 
5
3
  describe "Assertions" do
6
4
  include Capybara::DSL
7
5
  include Capybara::Assertions
8
6
 
9
- before do
10
- visit "/"
11
- end
12
-
13
7
  it "defines all the assertions that Capybara does" do
14
- assert_(:assertions)
8
+ Minitest::Capybara.assertions.each do |assertion|
9
+ assert self.respond_to?("assert_#{assertion}"),
10
+ "The assertion assert_#{assertion} is not defined."
11
+ end
15
12
  end
16
13
 
17
14
  it "defines all the refutations that Capybara does" do
18
- refute_(:refutations)
15
+ Minitest::Capybara.refutations.each do |refutation|
16
+ assert self.respond_to?("refute_#{refutation}"),
17
+ "The assertion refute_#{refutation} is not defined."
18
+ end
19
19
  end
20
20
 
21
21
  it "defines all the negative assertions that Capybara does" do
22
- assert_no_(:refutations)
22
+ Minitest::Capybara.refutations.each do |refutation|
23
+ assert self.respond_to?("assert_no_#{refutation}"),
24
+ "The assertion assert_no_#{refutation} is not defined."
25
+ end
23
26
  end
24
27
  end
@@ -1,20 +1,20 @@
1
- require 'test_helper'
2
-
3
- Capybara.app = lambda { |env| [200, {}, "<div><h1>foo</h1><a href='/'>bar</a></div>"] }
1
+ require "test_helper"
4
2
 
5
3
  describe "Expectations" do
6
4
  include Capybara::DSL
7
5
  include Capybara::Assertions
8
6
 
9
- before do
10
- visit "/"
11
- end
12
-
13
7
  it "defines all the must expectations that Capybara does" do
14
- must_have_(:assertions)
8
+ Minitest::Capybara.assertions.each do |assertion|
9
+ assert page.respond_to?("must_have_#{assertion}"),
10
+ "The expectation must_have_#{assertion} is not defined."
11
+ end
15
12
  end
16
13
 
17
14
  it "defines all the wont expectations that Capybara does" do
18
- wont_have_(:refutations)
15
+ Minitest::Capybara.refutations.each do |refutation|
16
+ assert page.respond_to?("wont_have_#{refutation}"),
17
+ "The expectation wont_have_#{refutation} is not defined."
18
+ end
19
19
  end
20
20
  end
@@ -2,10 +2,7 @@ require 'test_helper'
2
2
 
3
3
  Capybara.app = lambda { |env| [200, {}, "<div><h1>foo</h1><a href='/'>bar</a></div>"] }
4
4
 
5
- describe "app" do
6
- include Capybara::DSL
7
- include Capybara::Assertions
8
-
5
+ class AppTest < Minitest::Capybara::Spec
9
6
  before do
10
7
  visit "/"
11
8
  end
@@ -14,12 +11,14 @@ describe "app" do
14
11
 
15
12
  it "supports assert_content" do
16
13
  assert_content("foo").must_equal true
17
- proc { assert_content("BAD") }.must_raise Minitest::Assertion
14
+ e = proc { assert_content("BAD") }.must_raise Minitest::Assertion
15
+ e.message.must_equal "Expected to find text \"BAD\" in \"foobar\"."
18
16
  end
19
17
 
20
18
  it "supports refute_content" do
21
19
  refute_content("BAD").must_equal true
22
- proc { refute_content("foo") }.must_raise Minitest::Assertion
20
+ e = proc { refute_content("foo") }.must_raise Minitest::Assertion
21
+ e.message.must_equal "Expected not to find text \"foo\" in \"foobar\"."
23
22
  end
24
23
 
25
24
  it "supports assert_selector" do
@@ -1,4 +1,2 @@
1
1
  require "minitest/autorun"
2
- require "support/helper"
3
2
  require "minitest/capybara"
4
- require "minitest/features"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitest-capybara
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.2
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wojciech Mach
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-06 00:00:00.000000000 Z
11
+ date: 2015-12-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capybara
@@ -72,19 +72,11 @@ files:
72
72
  - lib/minitest-capybara.rb
73
73
  - lib/minitest/capybara.rb
74
74
  - lib/minitest/capybara/version.rb
75
- - lib/minitest/features.rb
76
- - lib/minitest/features/acceptance_spec.rb
77
- - lib/minitest/features/dsl.rb
78
75
  - minitest-capybara.gemspec
79
- - script/unreleased
80
76
  - test/capybara/assertions_test.rb
81
- - test/capybara/assertions_using_features_spec.rb
82
77
  - test/capybara/expectations_test.rb
83
- - test/capybara/expectations_using_features_spec.rb
84
78
  - test/minitest/base_node_test.rb
85
79
  - test/minitest/capybara_test.rb
86
- - test/minitest/features_test.rb
87
- - test/support/helper.rb
88
80
  - test/test_helper.rb
89
81
  homepage: ''
90
82
  licenses: []
@@ -111,11 +103,7 @@ specification_version: 4
111
103
  summary: Capybara matchers support for minitest unit and spec
112
104
  test_files:
113
105
  - test/capybara/assertions_test.rb
114
- - test/capybara/assertions_using_features_spec.rb
115
106
  - test/capybara/expectations_test.rb
116
- - test/capybara/expectations_using_features_spec.rb
117
107
  - test/minitest/base_node_test.rb
118
108
  - test/minitest/capybara_test.rb
119
- - test/minitest/features_test.rb
120
- - test/support/helper.rb
121
109
  - test/test_helper.rb
@@ -1,2 +0,0 @@
1
- require 'minitest/features/acceptance_spec'
2
- require 'minitest/features/dsl'
@@ -1,6 +0,0 @@
1
- module Minitest
2
- module AcceptanceSpec
3
- include ::Capybara::DSL
4
- include ::Capybara::Assertions
5
- end
6
- end
@@ -1,28 +0,0 @@
1
- module Minitest
2
- module Features
3
- module DSL
4
-
5
- include AcceptanceSpec
6
-
7
- ##
8
- # describe is 'defined' in Object
9
- # therefore it is available anywhere
10
- # so that allows us to simply
11
- # alias feature to describe.
12
- alias :feature :describe
13
-
14
- end
15
- end
16
-
17
- module Spec::DSL
18
- ##
19
- # Pure simple old Ruby#Module alias method
20
- #
21
- alias :scenario :it
22
- alias :background :before
23
- alias :given :let
24
- end
25
-
26
- end
27
-
28
- Object.send(:include, Minitest::Features::DSL)
@@ -1,6 +0,0 @@
1
- #!/bin/sh
2
- # Exits with 0 if current gem is not yet released, 1 otherwise.
3
-
4
- if git tag | grep --silent `cat VERSION`; then
5
- exit 1
6
- fi
@@ -1,27 +0,0 @@
1
- require 'test_helper'
2
-
3
- app = lambda { |env|
4
- [200, { "X-Content-Type" => "Capybara" },"<div><h1>foo</h1><a href='/'>bar</a></div>"]
5
- }
6
-
7
- Capybara.app = app
8
-
9
- feature "Assertions" do
10
-
11
- background do
12
- visit "/"
13
- end
14
-
15
- scenario "defines all assertions capybara does" do
16
- assert_(:assertions)
17
- end
18
-
19
- scenario "defines all refutations that Capybara does" do
20
- refute_(:refutations)
21
- end
22
-
23
- scenario "defines all negative assertions that Capybara does" do
24
- assert_no_(:refutations)
25
- end
26
-
27
- end
@@ -1,24 +0,0 @@
1
- require 'test_helper'
2
-
3
- Capybara.app = lambda { |env| [200, {}, "<div><h1>foo</h1><a href='/'>bar</a></div>"] }
4
-
5
- feature "Expectations" do
6
-
7
- given(:bob) { "Hi 'am bob" }
8
- background do
9
- visit "/"
10
- end
11
-
12
- scenario "defines all the must expectations that Capybara does" do
13
- must_have_(:assertions)
14
- end
15
-
16
- scenario "defines all the wont expectations that Capybara does" do
17
- wont_have_(:refutations)
18
- end
19
-
20
- scenario "bob" do
21
- bob.must_be_kind_of String
22
- end
23
-
24
- end
@@ -1,27 +0,0 @@
1
- require 'test_helper'
2
-
3
- feature "Testing Features" do
4
-
5
- scenario "I am a scenario" do
6
- :it_works.must_equal :it_works
7
- end
8
-
9
- scenario "it must include AcceptanceSpec" do
10
- self.class.must_include Minitest::AcceptanceSpec
11
- end
12
-
13
- feature "must work if nested" do
14
- scenario "it works" do
15
- :it_works.must_equal :it_works
16
- end
17
- end
18
-
19
- end
20
-
21
- feature "Testing methods" do
22
-
23
- given(:bob) { self.class }
24
-
25
- scenario { bob.must_respond_to :background }
26
-
27
- end
@@ -1,56 +0,0 @@
1
- module Helper
2
-
3
- def capybara(m)
4
- Minitest::Capybara.send(m)
5
- end
6
-
7
- def notice(msg)
8
- "The #{msg} is not defined."
9
- end
10
-
11
- ##
12
- # method_name matches anything apart from have
13
- # it must be an assertion
14
- # if it matches it must be an expectation
15
- #
16
- def or_message(method_name, msg)
17
- if method_name =! Regexp.new("have")
18
- notice("assertions " + msg)
19
- else
20
- notice("expectation "+ msg)
21
- end
22
- end
23
-
24
- ##
25
- # Ask either self or page
26
- #
27
- def respond_to(m)
28
- self.respond_to?(m) || page.respond_to?(m)
29
- end
30
-
31
- ##
32
- # callee here works but __method__ would not.
33
- # that's because callee changes accordingly as
34
- # self changes.
35
- # id2name simply converts a symbol to a string.
36
- # _method_ creates a method to be looked up
37
- # _method_ = "refute_method_name"
38
- #
39
- def assert_(method_name)
40
- callee = send(:__callee__).id2name
41
- capybara(method_name).each do |assertion|
42
- _method_ = "#{callee}#{assertion}"
43
-
44
- assert respond_to(_method_),
45
- or_message(callee, _method_)
46
- end
47
- end
48
-
49
- alias :refute_ :assert_
50
- alias :assert_no_ :assert_
51
- alias :must_have_ :assert_
52
- alias :wont_have_ :assert_
53
-
54
- end
55
-
56
- Object.send(:include, Helper)