Skip to content

Commit

Permalink
Rename project to mache
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Bassett committed Mar 7, 2017
1 parent e24fe43 commit be1054c
Show file tree
Hide file tree
Showing 17 changed files with 48 additions and 46 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*.gem
.bundle
Gemfile.lock
1 change: 1 addition & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
AllCops:
Exclude:
- "bin/**/*"
- "mache.gemspec"

Metrics/BlockLength:
ExcludedMethods: describe
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
source "https://rubygems.org"

# Specify your gem's dependencies in paper.gemspec
# Specify your gem's dependencies in mache.gemspec
gemspec
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Paper
# Mache

[![Build Status](https://travis-ci.org/nullobject/paper.svg?branch=master)](https://travis-ci.org/nullobject/paper)
[![Build Status](https://travis-ci.org/nullobject/mache.svg?branch=master)](https://travis-ci.org/nullobject/mache)

A [page object](https://martinfowler.com/bliki/PageObject.html) library for writing cleaner acceptance tests with [Capybara](https://github.com/teamcapybara/capybara).

Expand All @@ -27,11 +27,11 @@ Consider the following HTML snippet:
```

To define a page object class to wrap this HTML snippet, we extend the
`Paper::Page` class. The only method our class needs to provide is `path`, this
tells Paper where to go when we want to visit the page.
`Mache::Page` class. The only method our class needs to provide is `path`, this
tells Mache where to go when we want to visit the page.

```ruby
class WelcomePage < Paper::Page
class WelcomePage < Mache::Page
def path
"/welcome"
end
Expand Down Expand Up @@ -60,7 +60,7 @@ that we expect to find on the page using a CSS selector.
Let's define a `main` element:

```ruby
class WelcomePage < Paper::Page
class WelcomePage < Mache::Page
element :main, "body > main"

def path
Expand All @@ -80,12 +80,12 @@ page.main.text # "lorem ipsum"
### Components

For elements that can be shared across an number of page object classes, it may
be useful to define a reusable component by extending the `Paper::Component`
be useful to define a reusable component by extending the `Mache::Component`
class. A component class can contain any number of elements or other
components:

```ruby
class Header < Paper::Component
class Header < Mache::Component
element :title, "h1"
end
```
Expand All @@ -94,7 +94,7 @@ Our page object class can mount our component at a given CSS selector using the
`component` macro:

```ruby
class WelcomePage < Paper::Page
class WelcomePage < Mache::Page
component :header, Header, "header"
element :main, "body > main"

Expand All @@ -117,21 +117,21 @@ page.header.title.text # "Welcome"
Let's look at a more complete example for our `WelcomePage`:

```ruby
class Header < Paper::Component
class Header < Mache::Component
element :title, "h1"
end

class NavItem < Paper::Component
class NavItem < Mache::Component
def selected?
node[:class].include?("selected")
end
end

class Nav < Paper::Component
class Nav < Mache::Component
components :items, NavItem, "a"
end

class WelcomePage < Paper::Page
class WelcomePage < Mache::Page
component :header, Header, "header"
component :nav, Nav, "nav"
element :main, "main"
Expand Down
2 changes: 1 addition & 1 deletion bin/console
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env ruby

require "bundler/setup"
require "paper"
require "mache"

# You can add fixtures and/or initialization code here to make experimenting
# with your gem easier. You can also use a different console, if you like.
Expand Down
3 changes: 3 additions & 0 deletions lib/mache.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
require "mache/component"
require "mache/page"
require "mache/version"
4 changes: 2 additions & 2 deletions lib/paper/component.rb → lib/mache/component.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require "paper/node"
require "mache/node"

module Paper
module Mache
class Component < Node
end
end
4 changes: 2 additions & 2 deletions lib/paper/dsl.rb → lib/mache/dsl.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Paper
# Provides the paper DSL for nodes.
module Mache
# Provides the mache DSL for nodes.
module DSL
def self.included(base)
base.extend ClassMethods
Expand Down
6 changes: 3 additions & 3 deletions lib/paper/node.rb → lib/mache/node.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require "paper/dsl"
require "mache/dsl"

module Paper
# An abstract class that wraps a capybara node object and exposes the paper
module Mache
# An abstract class that wraps a capybara node object and exposes the mache
# DSL. It also delegates any capybara methods to the underlying node object.
class Node
include DSL
Expand Down
4 changes: 2 additions & 2 deletions lib/paper/page.rb → lib/mache/page.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require "capybara"
require "paper/node"
require "mache/node"

module Paper
module Mache
# A page provides a DSL for querying a wrapped capybara node object node. A
# page can also has a path which can be visited.
class Page < Node
Expand Down
3 changes: 3 additions & 0 deletions lib/mache/version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module Mache
VERSION = "1.0.0".freeze
end
3 changes: 0 additions & 3 deletions lib/paper.rb

This file was deleted.

3 changes: 0 additions & 3 deletions lib/paper/version.rb

This file was deleted.

12 changes: 6 additions & 6 deletions paper.gemspec → mache.gemspec
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
lib = File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)

require "paper/version"
require "mache/version"

Gem::Specification.new do |spec|
spec.name = "paper"
spec.version = Paper::VERSION
spec.name = "mache"
spec.version = Mache::VERSION
spec.authors = ["Joshua Bassett"]
spec.email = ["[email protected]"]
spec.summary = "A page objects library for writing cleaner tests"
spec.description = ""
spec.homepage = ""
spec.summary = "A page object library for writing cleaner acceptance tests with Capybara."
spec.description = "Mache provides a DSL for writing page object clases to use in your acceptance tests."
spec.homepage = "https://github.com/nullobject/mache"
spec.license = "MIT"
spec.files = `git ls-files -z`.split("\x0").reject do |f|
f.match(%r{^(test|spec|features)/})
Expand Down
10 changes: 5 additions & 5 deletions spec/integration/page_spec.rb
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
require "rack/file"
require "spec_helper"

class Label < Paper::Component
class Label < Mache::Component
def required?
node[:class].include?("required")
end
end

class Field < Paper::Component
class Field < Mache::Component
component :label, Label, "label"
element :input, "input"
end

class Form < Paper::Component
class Form < Mache::Component
components :fields, Field, "div"
element :button, "button"
end

class Header < Paper::Component
class Header < Mache::Component
element :title, "h1"
end

class MyPage < Paper::Page
class MyPage < Mache::Page
component :header, Header, "header"
component :form, Form, "form"

Expand Down
8 changes: 4 additions & 4 deletions spec/paper/page_spec.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
require "spec_helper"

describe Paper::Page do
describe Mache::Page do
let(:node) { double }
let(:path) { "/my-page" }

subject(:page) { Paper::Page.new(node: node, path: path) }
subject(:page) { Mache::Page.new(node: node, path: path) }

describe ".visit" do
let(:page) { double }

it "creates a new page and visits it" do
expect(Paper::Page).to receive(:new).and_return(page)
expect(Mache::Page).to receive(:new).and_return(page)
expect(page).to receive(:visit)
Paper::Page.visit
Mache::Page.visit
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)

require "paper"
require "mache"

RSpec.configure do |config|
config.mock_with :rspec do |mocks|
Expand Down

0 comments on commit be1054c

Please sign in to comment.