Skip to content

Commit

Permalink
Cleanup action view extension spec.
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbytables committed Dec 14, 2012
1 parent 1707dba commit 37dad85
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 17 deletions.
7 changes: 7 additions & 0 deletions spec/factories/dummy_models.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FactoryGirl.define do
factory :dummy_model do
sequence(:id) { |n| n }
email "[email protected]"
name "robert"
end
end
19 changes: 2 additions & 17 deletions spec/lib/action_view_extension_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,7 @@
describe 'Action View Extension' do
let(:action_view) { ActionView::Base.new }
let(:objects) do
3.times.map do |n|
num = n+1
DummyModel.new.tap do |d|
d.id = num # Wat
d.email = "robert#{num}@example.com"
d.name = "robert#{num}"
end
end
3.times.map { FactoryGirl.build(:dummy_model) }
end

it 'includes to actionview' do
Expand All @@ -23,14 +16,6 @@
end

doc = Nokogiri::HTML(table)
doc.at_xpath('//table').should be_present
doc.at_xpath('//tr').xpath('.//th').length.should == 2

trs = doc.at_xpath('//tbody').xpath('.//tr').to_a
trs.each_with_index do |tr, index|
tds = tr.xpath('.//td')
objects[index].name.should == tds[0].text
objects[index].email.should == tds[1].text
end
expect(doc.at_xpath('//table')).to be_present
end
end
3 changes: 3 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
require 'table_cloth'
require 'awesome_print'
require 'nokogiri'
require 'factory_girl'
require 'pry'

Dir['./spec/support/**/*.rb'].each {|f| require f }

FactoryGirl.find_definitions

ActionView::Base.send :include, TableClothViewMocks

RSpec.configure do |config|
Expand Down
1 change: 1 addition & 0 deletions table_cloth.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Gem::Specification.new do |gem|
gem.add_development_dependency('awesome_print')
gem.add_development_dependency('nokogiri')
gem.add_development_dependency('pry')
gem.add_development_dependency('factory_girl')
gem.add_development_dependency('guard-rspec')
gem.add_development_dependency('rake')

Expand Down

0 comments on commit 37dad85

Please sign in to comment.