spec/unit/views/components/attributes_table_spec.rb in activeadmin-0.6.0 vs spec/unit/views/components/attributes_table_spec.rb in activeadmin-0.6.1

- old
+ new

@@ -44,12 +44,20 @@ row("Id") { post.id } row("Title"){ post.title } row("Body") { post.body } end } - } - + }, + "when you create each row with a custom block that returns nil" => proc { + render_arbre_component(assigns) { + attributes_table_for post do + row("Id") { text_node post.id; nil } + row("Title"){ text_node post.title; nil } + row("Body") { text_node post.body; nil } + end + } + }, }.each do |context_title, table_decleration| context context_title do let(:table) { instance_eval &table_decleration } it "should render a div wrapper with the class '.attributes_table'" do @@ -66,19 +74,19 @@ table.find_by_tag("tr").size.should == 3 end describe "rendering the rows" do [ - ["Id" , "2"], + ["Id" , "1"], ["Title" , "Hello World"], ["Body" , "<span class=\"empty\">Empty</span>"] ].each_with_index do |set, i| - let(:title){ set[0] } - let(:content){ set[1] } - let(:current_row){ table.find_by_tag("tr")[i] } - describe "for #{set[0]}" do + let(:title){ set[0] } + let(:content){ set[1] } + let(:current_row){ table.find_by_tag("tr")[i] } + it "should have the title '#{set[0]}'" do current_row.find_by_tag("th").first.content.should == title end it "should have the content '#{set[1]}'" do current_row.find_by_tag("td").first.content.chomp.strip.should == content @@ -109,14 +117,14 @@ } table.find_by_tag("td").first.content.chomp.strip.should == "<span class=\"id\">1</span>" end it "should check if an association exists when an attribute has id in it" do - post.author = User.new(:username => "john_doe") + post.author = User.new :username => 'john_doe', :first_name => 'John', :last_name => 'Doe' table = render_arbre_component(assigns) { attributes_table_for post, :author_id } - table.find_by_tag("td").first.content.should == "john_doe" + table.find_by_tag('td').first.content.should == 'John Doe' end end end