我最初使用shoulda-matchers为我的模型和控制器编写测试,但后来我意识到我必须使用mongoid-rspec,因为我使用的是Mongoid。
问题在于,如果我将shoulda-matchers
替换为mongoid-rspec
,我的模型测试就可以了,但我得到了NoMethodError
responds_with
方法。
我是否可以指定将shoulda-matchers
用于控制器,mongoid-rspec
用于模型,还是更好的解决方案?
答案 0 :(得分:0)
只要import win32com.client
word = win32com.client.Dispatch('Word.Application')
doc = word.Documents.Add('example.html')
doc.SaveAs('example.doc', FileFormat=0)
doc.Close()
word.Quit()
没有定义与public class CustomerForm extends Activity {
private final static int CONTACT_PICKER = 1;
private EditText txtMailContacto;
private EditText txtNombreContacto;
private EditText txtTelefono;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_customer_form);
txtMailContacto = (EditText) findViewById(R.id.txtMailContacto);
txtTelefono = (EditText) findViewById(R.id.txtTelefono);
txtNombreContacto = (EditText) findViewById(R.id.txtNombreContacto);
}
public void pickContact(View v)
{
Intent contactPickerIntent = new Intent(Intent.ACTION_PICK,
ContactsContract.CommonDataKinds.Phone.CONTENT_URI);
startActivityForResult(contactPickerIntent, CONTACT_PICKER);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// check whether the result is ok
if (resultCode == RESULT_OK) {
// Check for the request code, we might be usign multiple startActivityForReslut
switch (requestCode) {
case CONTACT_PICKER:
contactPicked(data);
break;
}
} else {
Log.e("MainActivity", "Failed to pick contact");
}
}
private void contactPicked(Intent data) {
Cursor cursor = null;
try {
String mail = null ;
String phoneNo = null ;
String name = null;
// getData() method will have the Content Uri of the selected contact
Uri uri = data.getData();
//Query the content uri
cursor = getContentResolver().query(uri, null, null, null, null);
cursor.moveToFirst();
// column index of the phone number
int phoneIndex =cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER);
// column index of the email
int mailIndex =cursor.getColumnIndex(ContactsContract.CommonDataKinds.Email.ADDRESS);
// column index of the contact name
int nameIndex =cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME);
mail = cursor.getString(mailIndex);
phoneNo = cursor.getString(phoneIndex);
name = cursor.getString(nameIndex);
// Set the value to the textviews
txtMailContacto.setText(mail);
txtTelefono.setText(phoneNo);
txtNombreContacto.setText(name);
} catch (Exception e) {
e.printStackTrace();
}
}
}
中命名相同的匹配器,那么您应该能够将两个gem保留在Gemfile中。
如果不是这种情况并且两者相互冲突,并且假设你仍然在2.x线上,那么我担心你无能为力。 3.0包含一个修复程序,其中只有模型匹配器混合到模型示例组中,控制器匹配器混合到控制器示例组中,尽管它还包含您希望了解的other backward incompatible changes。