orderly 0.0.2
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/.gitignore +17 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +36 -0
- data/Rakefile +2 -0
- data/lib/orderly.rb +16 -0
- data/lib/orderly/version.rb +3 -0
- data/orderly.gemspec +24 -0
- data/spec/lib/orderly_spec.rb +38 -0
- data/spec/spec_helper.rb +17 -0
- data/spec/test_app.rb +27 -0
- metadata +105 -0
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 John Gesimondo
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# Orderly
|
2
|
+
|
3
|
+
Rspec matcher for asserting that this appears_before(that) in rspec request specs
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add these lines to your application's Gemfile (in this order):
|
8
|
+
|
9
|
+
gem 'rspec-rails'
|
10
|
+
gem 'orderly'
|
11
|
+
|
12
|
+
And then execute:
|
13
|
+
|
14
|
+
$ bundle
|
15
|
+
|
16
|
+
Or install it yourself as:
|
17
|
+
|
18
|
+
$ gem install orderly
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
|
22
|
+
In an rspec request spec, do
|
23
|
+
|
24
|
+
this.should appear_before(that)
|
25
|
+
|
26
|
+
or, to assert that something does not appear before
|
27
|
+
|
28
|
+
this.should_not appear_before(that)
|
29
|
+
|
30
|
+
Error handling in place for cases where this or that does not appear on the page.
|
31
|
+
|
32
|
+
## Todo
|
33
|
+
- Add TravisCI
|
34
|
+
|
35
|
+
## Contributing
|
36
|
+
Patches welcome! Submit a pull request.
|
data/Rakefile
ADDED
data/lib/orderly.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require "orderly/version"
|
2
|
+
require "rspec/expectations"
|
3
|
+
|
4
|
+
module Orderly
|
5
|
+
RSpec::Matchers.define :appear_before do |later_content|
|
6
|
+
match do |earlier_content|
|
7
|
+
begin
|
8
|
+
page.body.index(earlier_content) < page.body.index(later_content)
|
9
|
+
rescue ArgumentError
|
10
|
+
raise "Could not locate later content on page: #{later_content}"
|
11
|
+
rescue NoMethodError
|
12
|
+
raise "Could not locate earlier content on page: #{earlier_content}"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/orderly.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/orderly/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["John Gesimondo"]
|
6
|
+
gem.email = ["john@jmondo.com"]
|
7
|
+
gem.description = %q{orderly: an rspec assertion for request specs to assert that one piece of content appears on the page before another.}
|
8
|
+
gem.summary = %q{Assert this is before that}
|
9
|
+
gem.homepage = "https://github.com/jmondo/orderly"
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(spec)/})
|
14
|
+
gem.name = "orderly"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = Orderly::VERSION
|
17
|
+
|
18
|
+
gem.rubyforge_project = "orderly"
|
19
|
+
|
20
|
+
gem.add_development_dependency "rspec"
|
21
|
+
gem.add_development_dependency "capybara"
|
22
|
+
gem.add_development_dependency "mocha"
|
23
|
+
gem.add_development_dependency "sinatra"
|
24
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'capybara'
|
3
|
+
|
4
|
+
describe Orderly do
|
5
|
+
let(:this) { "<p>One piece of content</p>" }
|
6
|
+
let(:that) { "<p>Another piece of content</p>" }
|
7
|
+
|
8
|
+
let(:page) do
|
9
|
+
Capybara::Session.new(:rack_test, TestApp)
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "appear_before" do
|
13
|
+
it "asserts this is before that" do
|
14
|
+
page.visit "/thisthenthat"
|
15
|
+
this.should appear_before(that)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "asserts this is not before that" do
|
19
|
+
page.visit "/thatthenthis"
|
20
|
+
this.should_not appear_before(that)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "handles for this missing" do
|
24
|
+
page.visit "/thisnothat"
|
25
|
+
error_text = "Could not locate later content on page: #{that}"
|
26
|
+
expect { this.should appear_before(that) }.to raise_error error_text
|
27
|
+
expect { this.should_not appear_before(that) }.to raise_error error_text
|
28
|
+
end
|
29
|
+
|
30
|
+
it "handles for this missing" do
|
31
|
+
page.visit "/thatnothis"
|
32
|
+
error_text = "Could not locate earlier content on page: #{this}"
|
33
|
+
expect { this.should appear_before(that) }.to raise_error error_text
|
34
|
+
expect { this.should_not appear_before(that) }.to raise_error error_text
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# Require this file using `require "spec_helper.rb"` to ensure that it is only
|
4
|
+
# loaded once.
|
5
|
+
#
|
6
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
7
|
+
|
8
|
+
require 'orderly'
|
9
|
+
require 'capybara'
|
10
|
+
require 'test_app'
|
11
|
+
|
12
|
+
RSpec.configure do |config|
|
13
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
14
|
+
config.run_all_when_everything_filtered = true
|
15
|
+
config.filter_run :focus
|
16
|
+
config.mock_with :mocha
|
17
|
+
end
|
data/spec/test_app.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'sinatra/base'
|
2
|
+
require 'rack'
|
3
|
+
|
4
|
+
class TestApp < Sinatra::Base
|
5
|
+
set :root, File.dirname(__FILE__)
|
6
|
+
set :static, true
|
7
|
+
|
8
|
+
this = "<p>One piece of content</p>"
|
9
|
+
that = "<p>Another piece of content</p>"
|
10
|
+
|
11
|
+
get '/thisthenthat' do
|
12
|
+
this + that
|
13
|
+
end
|
14
|
+
|
15
|
+
get '/thatthenthis' do
|
16
|
+
that + this
|
17
|
+
end
|
18
|
+
|
19
|
+
get '/thatnothis' do
|
20
|
+
that
|
21
|
+
end
|
22
|
+
|
23
|
+
get '/thisnothat' do
|
24
|
+
this
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: orderly
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- John Gesimondo
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-07-13 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rspec
|
16
|
+
requirement: &70320858742920 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70320858742920
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: capybara
|
27
|
+
requirement: &70320858742500 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70320858742500
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: mocha
|
38
|
+
requirement: &70320858742080 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70320858742080
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: sinatra
|
49
|
+
requirement: &70320858741660 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70320858741660
|
58
|
+
description: ! 'orderly: an rspec assertion for request specs to assert that one piece
|
59
|
+
of content appears on the page before another.'
|
60
|
+
email:
|
61
|
+
- john@jmondo.com
|
62
|
+
executables: []
|
63
|
+
extensions: []
|
64
|
+
extra_rdoc_files: []
|
65
|
+
files:
|
66
|
+
- .gitignore
|
67
|
+
- .rspec
|
68
|
+
- Gemfile
|
69
|
+
- LICENSE
|
70
|
+
- README.md
|
71
|
+
- Rakefile
|
72
|
+
- lib/orderly.rb
|
73
|
+
- lib/orderly/version.rb
|
74
|
+
- orderly.gemspec
|
75
|
+
- spec/lib/orderly_spec.rb
|
76
|
+
- spec/spec_helper.rb
|
77
|
+
- spec/test_app.rb
|
78
|
+
homepage: https://github.com/jmondo/orderly
|
79
|
+
licenses: []
|
80
|
+
post_install_message:
|
81
|
+
rdoc_options: []
|
82
|
+
require_paths:
|
83
|
+
- lib
|
84
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
85
|
+
none: false
|
86
|
+
requirements:
|
87
|
+
- - ! '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
+
none: false
|
92
|
+
requirements:
|
93
|
+
- - ! '>='
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
requirements: []
|
97
|
+
rubyforge_project: orderly
|
98
|
+
rubygems_version: 1.8.10
|
99
|
+
signing_key:
|
100
|
+
specification_version: 3
|
101
|
+
summary: Assert this is before that
|
102
|
+
test_files:
|
103
|
+
- spec/lib/orderly_spec.rb
|
104
|
+
- spec/spec_helper.rb
|
105
|
+
- spec/test_app.rb
|