Skip to content

Commit

Permalink
Fixed doc's
Browse files Browse the repository at this point in the history
  • Loading branch information
Bert Hajee authored and Bert Hajee committed Jun 18, 2013
2 parents f81b8f2 + fdde9af commit 2bfad36
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ rvm:
- 1.9.3
- 2.0.0
# - jruby-19mode
- rbx-19mode
# - rbx-19mode
script: bundle exec rspec spec
# matrix:
# allow_failures:
Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ There are a lot of ways you can do this. PageRecord is one of these ways. PageRe
TODO explain how it helps in testing

##Documentation
Look at [the yard documentation](http://rubydoc.info/github/appdrones/page_record) for details.
Look at [the yard documentation](http://rubydoc.info/github/appdrones/page_record/PageRecord) for details.

##Markup
For [PageRecord](http://rubydoc.info/github/appdrones/page_record/) to recognise the data on the page, the page __must__ follow certain `html` formatting guidelines.
For [PageRecord](http://rubydoc.info/github/appdrones/page_record/PageRecord) to recognise the data on the page, the page __must__ follow certain `html` formatting guidelines.

__Every__ record on the page __must__ have a `data-type-id='x'` attribute.

Expand All @@ -22,7 +22,7 @@ __Every__ record on the page __must__ have a `data-type-id='x'` attribute.
...
<tag>
```
Where `1` is the `id` of the record and `type` is the type of record. See [PageRecord::Base.type](http://rubydoc.info/github/appdrones/page_record/PageRecord/Base#page-class_method) for information regarding the `type`.
Where `1` is the `id` of the record and `type` is the type of record. See [PageRecord::Base.type](http://rubydoc.info/github/appdrones/page_record/PageRecord/Base#type-class_method) for information regarding the `type`.

__Every__ attribute of a record, __must__ have a `data-attribute-for='name'` attribute. This tag __must__ be contained inside a tag contaning the `data-type-id='x'`

Expand All @@ -38,7 +38,7 @@ Where `attr` is the name of the attribute.
##attributes

###reading the attributes
With [PageRecord](http://rubydoc.info/github/appdrones/page_record/), you can easily access the attributes of a record on the page. After you've got a valid instance of [PageRecord::Base](http://rubydoc.info/github/appdrones/page_record/Base), you can access all attributes in a normal ruby-like way.
With [PageRecord](http://rubydoc.info/github/appdrones/page_record/PageRecord), you can easily access the attributes of a record on the page. After you've got a valid instance of [PageRecord::Base](http://rubydoc.info/github/appdrones/page_record/PageRecord/Base), you can access all attributes in a normal ruby-like way.

```ruby
champion = TeamPage.find(1)
Expand All @@ -53,7 +53,7 @@ Not only can you access the attributes for reading, you can also set the attribu
```

###specifying the attributes
When you define you page class as a subclass of [PageRecord::Base](http://rubydoc.info/github/appdrones/page_record/Base), it automagicaly looks for a host class. To get the name of your host class, PageRecord removes the `Page` part of you class name and tries to use that class as a host class.
When you define you page class as a subclass of [PageRecord::Base](http://rubydoc.info/github/appdrones/page_record/PageRecord/Base), it automagicaly looks for a host class. To get the name of your host class, PageRecord removes the `Page` part of you class name and tries to use that class as a host class.

Example:

Expand Down Expand Up @@ -144,7 +144,7 @@ TeamPage.save?
```

##Using PageRecord together with Rspec
To use [PageRecord](http://rubydoc.info/github/appdrones/page_record/) with Rspec, you need to require it in your `spec_helper.rb` file. To make it work, it needs to be required __after__ capybara.
To use [PageRecord](http://rubydoc.info/github/appdrones/page_record/PageRecord) with Rspec, you need to require it in your `spec_helper.rb` file. To make it work, it needs to be required __after__ capybara.

```ruby
require 'capybara'
Expand All @@ -154,7 +154,7 @@ require 'page_record/rspec'
Also, you need te make sure your page definitions are included. A good place to store them would be in your support directory.

##Using PageRecord together with Cucumber
To use [PageRecord](http://rubydoc.info/github/appdrones/page_record/) with Cucumber, you need to require it in your `env.rb` file. To make it work, it needs to be required __after__ capybara.
To use [PageRecord](http://rubydoc.info/github/appdrones/page_record/PageRecord) with Cucumber, you need to require it in your `env.rb` file. To make it work, it needs to be required __after__ capybara.

```ruby
require 'capybara'
Expand All @@ -163,7 +163,7 @@ require 'page_record/cucumber'
Also, you need te make sure your page definitions are included. A good place to store them would be in your support directory.

##Using PageRecord standalone
If you are using [PageRecord](http://rubydoc.info/github/appdrones/page_record/) outside of Rspec or Cucumber, you also need to require the right files.
If you are using [PageRecord](http://rubydoc.info/github/appdrones/page_record/PageRecord) outside of Rspec or Cucumber, you also need to require the right files.

```ruby
require 'capybara'
Expand Down
2 changes: 1 addition & 1 deletion page_record.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "rake"
spec.add_development_dependency "rspec"
spec.add_development_dependency "sinatra"
spec.add_development_dependency "debugger"
# spec.add_development_dependency "debugger"

spec.add_dependency "capybara" , '~>2.1.0'
spec.add_dependency "activesupport"
Expand Down
24 changes: 12 additions & 12 deletions spec/page_record_spec.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
require_relative './spec_helper'

describe PageRecord::PageRecord do
describe PageRecord::Base do

include_context "page with single table with 3 records" # Default context

before do
class TeamPage < PageRecord::PageRecord; end
PageRecord::PageRecord.page = page
class TeamPage < PageRecord::Base; end
PageRecord::Base.page = page
end

describe ".type" do
Expand All @@ -17,7 +17,7 @@ def self.attribute_names
[ 'id' , 'name', 'points', 'ranking', 'goals']
end
end
class CamelCasePage < PageRecord::PageRecord; end
class CamelCasePage < PageRecord::Base; end
end

it "returns the internal type of the class" do
Expand All @@ -30,7 +30,7 @@ class CamelCasePage < PageRecord::PageRecord; end

describe ".attributes" do
before do
class TeamPage < PageRecord::PageRecord
class TeamPage < PageRecord::Base
attributes ['country', 'stadium']
end
end
Expand Down Expand Up @@ -67,17 +67,17 @@ class TeamPage < PageRecord::PageRecord

describe ".page=" do
before do
PageRecord::PageRecord.page = nil # reset for the spec
PageRecord::Base.page = nil # reset for the spec
end

subject {PageRecord::PageRecord.page = page }
subject {PageRecord::Base.page = page }

it "sets the page when called on PageRecord::PageRecord" do
expect{PageRecord::PageRecord.page = page}.to change{PageRecord::PageRecord.page}.from(nil).to(page)
it "sets the page when called on PageRecord::Base" do
expect{PageRecord::Base.page = page}.to change{PageRecord::Base.page}.from(nil).to(page)
end

it "sets the page when called on subclass" do
expect{TeamPage.page = page}.to change{PageRecord::PageRecord.page}.from(nil).to(page)
expect{TeamPage.page = page}.to change{PageRecord::Base.page}.from(nil).to(page)
end


Expand All @@ -86,8 +86,8 @@ class TeamPage < PageRecord::PageRecord
describe ".page" do


it "gets the page on PageRecord::PageRecord" do
expect(PageRecord::PageRecord.page).to eq page
it "gets the page on PageRecord::Base" do
expect(PageRecord::Base.page).to eq page
end

it "gets the page on subclass" do
Expand Down

0 comments on commit 2bfad36

Please sign in to comment.