Displaying 20 results from an estimated 2000 matches similar to: "Conditional statement style"
2006 May 04
2
Testing associations
I have a pretty simple model, articles and users.
class Article
belongs_to :user
end
class User
has_many :articles
end
In my unit tests I want to ensure that the associations work properly.
What''s the best way to do this? The obvious thing to do is a test in
each model.
# user_test.rb
def test_add_post
u = users(:first)
before_articles = u.articles.count
u.articles
2006 May 08
3
operator overload on views
In my User auth scheme I have a userlevel. I''ve overloaded the User
class operators like this:
def >(item)
if item.class == "User"
self.userlevel > item.userlevel
else
self.userlevel > item
end
end
(other operators are overloaded in essentially the same way). As I
understand it, using the operator ">" inside the overloaded
2006 May 03
3
create test methods from Controller methods?
Can you somehow create a test that contains methods that relate to the
methods in the controller that is being tested?
Thanks
Chris
--
Posted via http://www.ruby-forum.com/.
2006 May 03
1
Nubee Fixtures + Tests problem
According to the book, @timesheets["first_timesheet"] should be
accesible from within my functional test, but its not!
Timesheets.yml :
first_timesheet:
status: 2
start_date: 2006-04-24
cost: 10
employee: 444
id: 10683
charge: 20
My Test :
class AdminTimesheetsControllerTest < Test::Unit::TestCase
fixtures :timesheets
def test_viewTimesheet
get
2006 May 04
3
@products["car"] is not being recognized in my tests!! help
@products["car"] is not being recognized in my tests:
class ProductsControllerTest < Test::Unit::TestCase
fixtures :products
def test_view_product
post :view_product, :id=>@products["car"].id
assert_template "view_product"
...
end
end
products.yml :
car:
id:1
name:test
Does anyone have any idea why its not working?
Im having to do
2006 May 10
1
model mixin module madness
If I have several models which exhibit the same functionality, it seems
makes sense to create a mixin, ''include'' it in each model and save
myself some work and repeated code.
Where can I define a module which will be available to all models? I
can''t seem to find a documented place for them.
Alternatively, is there a Rails-standard way of achieving the effect?
Ben
2006 Apr 28
1
how do I test links in templates?
Hello everyone!
Sorry, if it''s stupid question, but I can''t figure out how to do this.
I have a set of statements, for example, ''login page should have a
link to register new user'' and ''login page should have a link to
password recovery''. How do I transform it into tests? Where it should
go? It does not look like functional tests or
2008 Oct 20
5
Combining all possible values of variables into a new...
I'm trying to create a new column in my data.frame where subjects are categorized depending on values on four other columns. In any other case I would just nest a few ifelse statements, however, in this case i have 4*6*2*3=144 combinations and i get weird 'context overflow' errors. So I wonder if there is a more efficient way of doing this.
For illustrational purposes, let's say
2012 May 24
1
svychisq using two frames
Hello,
I?m hoping you have a few minutes to help out someone very new to R. I?ve
done some searching, but cannot find this particular issue.
I have survey data from two different time periods (years). Both years are
stratified samples and have the same variables (and variable names), but are
different people in the community answering in the different years.
Everything loads into the survey
2016 Apr 06
2
LTO renaming of constants with inline assembly
On Wed, Apr 6, 2016 at 11:16 AM, Peter Collingbourne <peter at pcc.me.uk>
wrote:
> On Wed, Apr 6, 2016 at 10:49 AM, Teresa Johnson <tejohnson at google.com>
> wrote:
>
>>
>>
>> On Wed, Apr 6, 2016 at 10:46 AM, Peter Collingbourne <peter at pcc.me.uk>
>> wrote:
>>
>>> I suspect that the right way to do promotion/renaming of this
2008 Mar 21
1
Problem with Makefile.win and environment variable
Dear all,
When porting my package to WinXP I have the following problem:
I need to create an environment variable "MYVAR=c:\mypath" which I have
saved in the control panel "System->My Computer" (under the `Advanced' tab).
I have two files which need to access MYVAR: config.win, Makefile.win
While "config.win" does recognize MYVAR correctly,
2016 Apr 13
2
LTO renaming of constants with inline assembly
I still wonder if this would be an issue in _standard_ (not thin) LTO?
This test seems to be OK on my (slightly modified) standard LTO flow, but I do wonder for a more general case.
Sergei
---
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
From: llvm-dev [mailto:llvm-dev-bounces at lists.llvm.org] On Behalf Of Peter Collingbourne
2016 Apr 06
2
LTO renaming of constants with inline assembly
On Wed, Apr 6, 2016 at 10:46 AM, Peter Collingbourne <peter at pcc.me.uk>
wrote:
> I suspect that the right way to do promotion/renaming of this sort is to
> rename at the MC layer just before writing the symbol table to the object
> file.
>
I think that is too late - how would the symbols be distinguished in the
LTO case below after the IR is linked but before we renamed the
2016 Apr 06
2
LTO renaming of constants with inline assembly
I encountered an issue with ThinLTO handling of inline assembly, where the
inline assembly referenced a constant that was a local variable. The local
var was renamed because it was promoted in ThinLTO mode, but the inline
assembly copy was not renamed and we ended up with an undef at link time.
It looks like this is a general problem with inline assembly and LTO.
Wondering if it is a known issue.
2007 Feb 14
2
Problem with a template file
Hi,
I''ve got a problem when using templates in Puppet.
In my node declarations, i set (or not) some special variables to
activate (or not) some part of my configuration. When i don''t need the
configuration part, i don''t declare the variable.
I then use something like this in my templates:
...
<% if defined? myvar %>
...
myvalue = <%= myvar %>
...
<%
2011 Mar 02
2
[1.4] Comparing value of string with spaces?
Hello
I haven't found an example on how to compare the value of a string
variable with spaces in it, and the While loop below never exits:
========== extensions.conf
exten => start,n,Set(MYVAR="Dummy value")
exten => start,n,NoOp(${MYVAR})
;BAD TOO
;exten => start,n,While(!$[${MYVAR} : "Some string"])
exten => start,n,While($[${MYVAR} != "Some
2013 Mar 21
2
Howto create variable from the name of another one and get content of it
Hello,
I have a variable created like
... Set(__myVar=${ARG1})
... Set(__${myVar}STATUS=)
If ARG1 is abcd, variable is abcdSTATUS and should be empty. This is OK.
Now I would like to get the value of abcdSTATUS. How to do it?
${${myVar}STATUS}} isn't working, nor ${{myvar}STATUS}
Thanks for any hint
--
Daniel
2000 Dec 20
2
Names
I am trying to create a set of vectors which have similar names. They have
a common part and an extra unique part. I am sure I have seen questions on
this before but I have been unable to find it in the archive. There are
examples of sets of names for columns of a data frame, but not for
individual vectors.
Suppose I want vectors named myvar.1 myvar.2 etc.
I tried:
>
2019 Dec 27
2
AGI: "Get variable" returns variable VALUE vs "Get full variable" returns variable NAME - bug or my misunderstanding?
Just trying out a node agi package (https://github.com/sergey12313/ts-agi/ ,
and it wasn't behaving as I expected, but when turning on agi debug, it
looks like it might be Asterisk (using 17.1.0)
This works as expected
<Local/1000 at default-00000020;2>AGI Rx << SET VARIABLE myVar "Hello World!!!"
<Local/1000 at default-00000020;2>AGI Tx >> 200 result=1
2013 Mar 25
2
ifelse can't return a list? Please explain (R-2.15.3)
I hope you are doing well.
For me, this was an unexpected problem. I've hoped for quite a few
wrong things today, but I'm only asking you about this one. Why does
ifelse(1, list(a, b, c), list(x, y, z))
return a list with only a, not list(a, b, c) as I hoped. I wish it
would either
cause an error or return the whole list, not just the first thing.
Working example:
> x <- 1
>